Sunday, June 24, 2012

Building WM8650 netbook kernel

So you bought a WM8650 netbook, followed my previous posts and got Arch Linux working, but... the WiFi dongle inside your netbook is not a RT8188 one, or you need ipv6 support, or you want NFS support, or maybe you want to mess with the kernel code to fix some issues. Then you need to build a new kernel.

To build the kernel, I followed this great tutorial by John Williams. All the credit for finding the kernel sources and investigating how to patch them is due to him. I only did some small modifications to support WM8650 netbooks (his tutorial covers WM8650 tablets) and to avoid changing kernel variables that could break compatibility with Android Kernel. The kernel I'll show you how to build, lacks the WiFi driver. If the USB dongle inside your netbook is supported by the drivers included in the kernel, you can enable it and it will be built. If it's not supported (as happened with mine), you'll need to search for a suitable driver, and merge it in the kernel sources. I'll explain how to do it when I get some time to write a new tutorial.

The infamous menuconfig screen

You will need a compiler. You can install gcc and binutils in your WM8650 netbook and do all the process inside it. Building the kernel in the netbook takes about 15 minutes. You can also build it in your PC using a cross compiler for armv5te architecture. This will take a lot less time, but getting the compiler working can be a bit tricky. I'll not explain how to build/install a cross compiler, since there are a lot of good tutorials covering it, all over the net.

Once you have your compiler set up, we can start working. The first step is downloading the sources. Unfortunately the sources for the kernel that come with the Android distro aren't easy to find. There are some sources from Wondermedia available, but they lack the code for some drivers, and also include some binary blobs. An older version of the kernel sources included some of the missing drivers, and can still be found on the Internet. The first thing we must do is to download sources for both the older and the newer kernel, then unpack the older kernel and then unpack the newer kernel overwriting the older one. This way we get the drivers missing in the newer kernel, but with all the bugfixes and improvements of the newer kernel. Then we must clean the kernel tree:

wget http://ftp.gpl-devices.org/pub/vendors/Wondermedia/WM8650/KERNEL-DS_ANDROID_2.6.32_WM8650.111209.1514.tgz
wget http://projectgus.com/files/wm8650/KERNEL-DS_ANDROID_2.6.32_WM8650.110408.1903.tgz
tar -xzf KERNEL-DS_ANDROID_2.6.32_WM8650.110408.1903.tgz
tar -xzf KERNEL-DS_ANDROID_2.6.32_WM8650.111209.1514.tgz
cd ANDROID_2.6.32-DS/ANDROID_2.6.32
make distclean

Now we must set the kernel configuration and patch the kernel with the code to fix battery readings, ethernet, etc. Download this patch to the working directory and type in the console:

tar -xjf wm8650_netbook.patch.tar.bz2
patch -p1 < wm8650_netbook.patch
wget http://pastebin.com/download.php?i=UBZW78BW -O .config

If you want to change the kernel configuration, launch the menu based configurator:

make menuconfig

Once you finish, exit (saving changes if you want). We are ready to start building the kernel:

make uImage

This will take some time. Hopefully, there should be no errors, and when it finishes, you should have your new kernel under arch/arm/boot/uImage. Just rename it to uzImage.bin and copy it to the boot partition of your SD card. Next, we will build the kernel modules:

make modules

And finally, we have to install the modules. If you have built them in your WM8650 netbook, run, with root privileges:

make modules_install

If you have built them in your PC using a cross compiler, mount the system partition of the SD card and run (also with root privileges):

INSTALL_MOD_PATH=/run/media/doragasu/ARCH_SYS make modules_install

As always, remember to change "/run/media/doragasu/ARCH_SYS" with the directory where the system partition of your SD card is mounted. And that's all, reboot your netbook, and the new kernel and modules should run fine. If you have included new features in your kernel, they should be working from now on!

When I get some more time, I'll write a tutorial detailing how to include the driver for the RT8188/8192 wireless dongles into the kernel tree. Stay tuned!

31 comments:

  1. Again, thanks a lot, it's wonderful, I've managed to get WiFi running without loosing battery indicator - thanks to your configuration!:)

    For those who want to configure a cross-compiler, there's a nice tutorial here:
    http://briolidz.wordpress.com/2012/02/07/building-embedded-arm-systems-with-crosstool-ng/

    Thanks a LOT, I'll let you know if I manage to invent something:)

    Best regards!

    ReplyDelete
  2. Thanks for these great tutorials on the WM8650!
    One question though, I used the lazy method from your "Arch Linux on a WM8650 netbook (II)" post to install and have no ethernet or wifi.
    Is there a way to install gcc and binutils onto the SD card with a PC?

    ReplyDelete
    Replies
    1. I have updated the kernel with a patch that *should* solve problems with the Ethernet. I have also updated the modules and included a lot more drivers. It might solve some WiFi problems but not all, since driver for example for RT5370 chipsets is not included. An update is recommended. Grab the kernel and the modules:

      - Kernel: http://www.mediafire.com/?67h0mdfu0r409v0
      - Modules: http://www.mediafire.com/?1qk1era4t89va11

      Then follow steps 2 and 4 of the first tutorial, but with the updated archives. Ethernet should start working, and there's a chance to also get WiFi working.

      I suppose there must be a way to download gcc and binutils packages with a PC, from the alarm repository to the SD, and then you can install them by using "pacman -U package_name", but I think getting Ethernet working and installing it the standard way should be easier.

      Delete
  3. Thankyou, I now have ethernet working! I had trouble though, I couldn't untar it with '-xjf' so I untarred with just 'x' and renamed uImage.bin to uzImage.bin.


    This distro is great on these little netbooks. Good work, thanks again!

    ReplyDelete
  4. Thanks for the detailed instructions. When I download the sources and follow the instructions I'm getting errors when I apply the patch and the modules fail to build - errors below. Any pointers appreciated. Cheers.


    root@zoot:~/build/arch/kernel/ANDROID_2.6.32-DS/ANDROID_2.6.32# patch -p1 < wm8650_netbook.patch
    (Stripping trailing CRs from patch.)
    patching file drivers/input/touchscreen/vt1603a_ts/Kconfig
    Hunk #1 FAILED at 22.
    1 out of 1 hunk FAILED -- saving rejects to file drivers/input/touchscreen/vt1603a_ts/Kconfig.rej
    (Stripping trailing CRs from patch.)
    patching file drivers/net/arm/rhine_main.c
    (Stripping trailing CRs from patch.)
    patching file drivers/power/wmt_battery.c
    Hunk #1 FAILED at 99.
    Hunk #2 FAILED at 174.
    Hunk #3 FAILED at 338.
    Hunk #4 FAILED at 370.
    Hunk #5 FAILED at 515.
    Hunk #6 FAILED at 1021.
    6 out of 6 hunks FAILED -- saving rejects to file drivers/power/wmt_battery.c.rej
    (Stripping trailing CRs from patch.)
    patching file drivers/rtc/wmt-rtc.c
    (Stripping trailing CRs from patch.)
    patching file drivers/video/wmt/govrh.c
    Hunk #1 FAILED at 924.
    patch unexpectedly ends in middle of line
    Hunk #2 FAILED at 1010.
    2 out of 2 hunks FAILED -- saving rejects to file drivers/video/wmt/govrh.c.rej

    Errors when I then make modules anyway

    In file included from drivers/video/wmt/govrh.h:31:0,
    from drivers/video/wmt/govrh.c:34:
    drivers/video/wmt/govrh.c: In function ‘govrh_CUR_set_framebuffer’:
    drivers/video/wmt/vpp.h:828:24: error: inlining failed in call to always_inline ‘vpp_cache_sync’: function body not available
    drivers/video/wmt/govrh.c:1031:16: error: called from here
    make[3]: *** [drivers/video/wmt/govrh.o] Error 1
    make[2]: *** [drivers/video/wmt] Error 2
    make[1]: *** [drivers/video] Error 2
    make: *** [drivers] Error 2

    ReplyDelete
    Replies
    1. I have checked the build steps, and there's a problem with the patch file. It looks like something gets screwed when I upload it to pastebin and download it again. The downloaded and original files look the same when opened in an editor, but I don't know why, downloaded patch doesn't work. To solve the problem, I have compressed the patch in a .tar.bz2 package. You can download it here:
      http://www.mediafire.com/?28xor4fr7ws1c11

      Then repeat the process, but instead of doing the step "wget http://pastebin.com/download.php?i=z2sc5r7A -O wm8650_netbook.patch", download the above file, extract it, place it in the working folder ([...]/ANDROID_2.6.32-DS/ANDROID_2.6.32/) and continue with the patch command. Now everything should work fine.

      Thanks for reporting the problem, and sorry for the inconvenience. I'll update the tutorial ASAP.

      Delete
    2. All good now - that has fixed the problem and now I have ppp and my 3G dongle working, many thanks.

      In the end I used the cross compiler as per MK's reference above on Ubuntu. The only changes to the process were a) I needed to install uboot-mkimage and b) at the end of the kernel build I executed the following command:

      mkimage -A arm -O linux -T kernel -C none -a 0x8000 -e 0x8000 -n "wm8650 linux 2.6.32.9" -d arch/arm/boot/zImage uzImage.bin

      Delete
    3. I'm glad to read it's working now.

      Thanks for sharing the changes to get the cross compiler working!

      Delete
    4. I used doragasu kernel (wm8650-kernel_20120808.tar.bz2), kernel modules (wm8650-modules_20120808.tar.bz2), and rootfs (alarm-wm8650-2012.06.19.tar.bz2)
      And finally I updated arch with erich's guide Now I have a fully updated arch linux os on my netbook.

      I need my USB 3G modem & USB to serial convertor (pl2303: Prolific PL2303 USB to serial adapter) working.

      I have installed usbutils usb_modswitch wvdial

      but unfortunetly I am not getting any ttyUSBx port for both USB 3G modem & USB to serial converter.

      any help???

      @Martin Dowse
      Can I use your kernel & kernel modules with my new updated rootfs (old rootfs is alarm-wm8650-2012.06.19.tar.bz2) to get 3G dongle and usb to serial converter working?

      thanks
      jags

      Delete
  5. @Martin Dowse: Would you please share the Image with us? I´m getting tierd trying to compile the kernel

    ReplyDelete
  6. I've uploaded the kernel and also the overlaid and patched source tree

    - kernel http://www.mediafire.com/download.php?79ae66vi3orttt3
    - sources http://www.mediafire.com/download.php?0za8577mzaac9r4

    README.txt file in kernel.tar

    Cheers

    ReplyDelete
  7. @Martin:Thank you for uploading your Image. I finally managed to build the kernel. But my wifi still dont work. lsusb show me 148f:5370, so it seems that the wifi is on but with lsmod i dont see any module loaded for this device. i tried to build the driver from source but always failed. Did somebody have a solution for this problem?

    ReplyDelete
    Replies
    1. To get more detailed info about USB (and PCI) devices, you can install hwids:

      pacman -S hwids

      That VID/PID pair is for a RT5370 WiFi dongle. I was able to build its driver, but couldn't integrate it into the kernel tree. It should be usable anyway, but since I don't have that dongle, I couldn't test it myself.

      I'll try to upload it when I get home. Hope it works!

      Delete
    2. Uploaded driver I built for RT5370 dongles:
      http://www.mediafire.com/?8nnn3c3nw56c9bi

      Instructions:
      1.- Unpack the tarball.
      2.- Move/copy RT2870STA.dat to [sdcard_path]/etc/Wireless/RT2870STA/RT2870STA.dat
      3.- Move/copy rt5370sta.ko to [sdcard_path]/lib/modules/2.6.32.9-test/kernel/drivers/net/wireless/rt5370sta.ko
      4.- Start the system, and enable WiFi with the gpio command. If the module doesn't automatically load, force loading it by running (with root privileges): insmod /lib/modules/2.6.32.9-test/kernel/drivers/net/wireless/rt5370sta.ko

      The module should be listed by the lsmod command, and hopefully WiFi should start working.

      Delete
  8. @doragsu:thank you for your time and help. I´m still have problems loading the driver. i tried "modprobe" and "insmod" but always fails.
    Console output:
    for insmod: Error: could not insert module rt5370sta.ko: Unknown symbol in module
    for modprobe: FATAL: Module rt5370sta.ko not found

    -> I think the problem the module isnt load during boot. so maybe some .conf file needs to be modified. but i dont know what file do this in arch-linux. i like to try it with rc.conf-file but know idea how do insert the module.

    -> or, could you share your "lib" folder. maybe modules.dep or so must be set correct.

    ReplyDelete
    Replies
    1. I did a quick google and got here: http://www.linuxquestions.org/questions/linux-newbie-8/insmod-rtmp-error-894220/

      I'll try to patch the sources with the suggested changes when I get some time.

      To load the module every time the system boots, the simplest way I know is just by inserting the "insmod /path_to_the_module/rt5370sta.ko", but that will not work until we solve the error with insmod.

      Delete
  9. Thank you for the fast answer. By the way, on wicknix debian port the driver works.

    ReplyDelete
    Replies
    1. I tried following the tips depicted in linuxquestions forum, but unfortunately wasn't able to make the thing work :(

      I hope somebody can help you with this issue.

      Delete
  10. I have also tried and failed to get the rt5370 module built, both natively and via cross compiler. I think the Debian port uses an android kernel so is probably using a prebuilt module.

    ReplyDelete
  11. Used files and instructions from initial page to successfully get character based Linux running (but with no networking etc configured). Then saw the vid on youtube and wanted more. Created a new SD card with the original files on the root partition, and the files from the tar at the top of this page. It boots and shows the beautiful login page. I enter root then root, but instead of going to the gui desktop, I just get a black screen with the classic X-windows pointer that follows my mouse. Cannot do anything from there. Only error I saw on booting was something about being unable to open the syslog-ng.conf file. changed perms in /etc/syslog-ng directory, but that changed nothing.
    Does anyone have any ideas?
    Thanks!

    ReplyDelete
    Replies
    1. Did you create the ~/.xinitrc script as stated in the second part of the tutorial? (steps 5 & 6).

      Delete
    2. Aha! Belonging to that group you call "too impatient, too busy, or too lazy" (guilty as charged!) I assumed that the numbered steps on that page were for people building out the GUI desktop environment manually. There already was a .xinitrc file in root's home directory, though it was just a bit more involved than the single "exec" of the desktop. I edited it to the simplified version in steps 5 & 6 and tried again. Same result of the black screen & "x" cursor. I will review the other steps you outlined to try to determine if something is missing from my (copied) setup. You have obviously done an awesome job and I will keep poking around. Thanks.

      Delete
  12. This comment has been removed by the author.

    ReplyDelete
  13. Thanks for providing such a great tutorial for WM8650! :)

    I've followed the tutorial with the netbook patch, and I can get my own kernel now.
    libaccept package is installed, and system-udevd won't eat cpu resource too much anymore.
    The linux system with ArchLinux rootFS could run, but it is very slow.
    However, there is a process "events/0" occupies cpu over 50%.(I use "top".)
    "events/0" will release cpu sometimes, so I can use this very little time slice to input command.

    Did somebody have the same issue before?
    Thank you.

    ReplyDelete
  14. A hint for those building a kernel on the WM8650 itself,
    if you get the error "Make: arm-none-linux-gnueabi-gcc: Command not found"
    try the following:

    the default Makefile in the working directory has the following lines:

    ARCH ?= arm
    CROSS_COMPILE ?= arm-none-linux-gnueabi-

    which needs to be changed to

    ARCH ?= arm
    CROSS_COMPILE ?=

    to turn off the cross compilation toolchain reference which those on x86 boxes need in the makefile.

    Seems to fix it. Building now. Yawn.

    ReplyDelete
  15. I used Martin Dowse's kernel and modules

    - kernel http://www.mediafire.com/download.php?79ae66vi3orttt3
    - sources http://www.mediafire.com/download.php?0za8577mzaac9r4

    And I installed usb_modeswitch & wvdial.

    Now I get My GSM modem attach to ttyUSB0, ttyUSB1, ttyUSB2
    I modify wvdial.conf file as per my USB dongle.

    But I get The PPP daemon has died. (exit code = 4)

    Can any body help me to get my 3G USB dongle running on ny arch linux netbook

    regards
    jags

    ReplyDelete
    Replies
    1. I found Dowse's kernel dose not have built in ppp, rather has module drivers/net/ppp_async.ko. I load module ppp_async manualy. and my pppd started working.

      But in doragasu's kernel module i could not find ppp_async.ko, may be this kernel has built in ppp. but with lsmod i dint get any ppp_* module loaded. As usual PPP daemon has died. (exit code = 4).

      can any body help me how to get pppd working with doragasu's kernel module?
      Has any body test 3G USB dongle with doragasu's kernel module?\

      regards
      jags

      Delete
  16. hi..Im college student, thanks for sharing :)

    ReplyDelete
  17. pessoal me ajudem , já o meu netbook wm8650 a tela só inicia branca, eu escuto o som do windows iniciando, mais a tela fica com linhas brancas e preta e depois fica sempre toda branca. help help

    ReplyDelete
  18. Hola, siento no comentar en ingles, mii ingles es pesimo.
    Tengo un problema con mi tablet, los drivers instalados son los del vt1603 y mi tablet usa el vt1609 y tengo problemas de compatibilidad, al arrancar me da un error que cubre toda pantalla y no me deja hacer nada con la tablet.
    Estoy intentando compilar un kernel sin dicho driver (I2C, Alsa y WM touchscreen) y poder trabajar sobre el, ya que lo unico que necesito es que tenga conexion a internet para hacer un pequeño servidor. No consigo compilar el kernel de ninguna de las maneras, tengo problemas con el cross compiler y a la hora de compilar el kernel, he mirado varios tutoriales por internet de como compilar el cross compiler y no lo consigo.

    Lo hago desde ubuntu 14.04.2 de 64 bits
    PD: doragasu llevo dias intentando contactar contigo por twitter

    Gracias y espero ayudar a todos los que les haya tocado el vt1609 ;)

    ReplyDelete
    Replies
    1. Hola,

      El tema del cross compiler es complicado, y no es algo que tenga fresco (hace casi 3 años que no toco estos cacharros), así que no es algo en lo que te pueda ayudar ahora mismo.

      De todos modos, aun cuando lograses compilarlo, tal cual está mi kernel, no te iba a funcionar en distribuciones Arch actuales, porque hace mucho que cambiaron a systemd, y creo recordar que este kernel no soporta algunos requisitos de systemd (como los cgroups). Probablemente a día de hoy sea más recomendable buscar alguna distro de Debian para estas máquinas.

      Delete