Monday, June 18, 2012

Arch Linux on a WM8650 netbook

UPDATE 20th November 2012: Due to recent changes in the Arch Linux boot process, this tutorial is no longer valid. You can still download an old pre-built image and install it, as I explained here. But with this old image, updating the distro (with pacman -Syu) will most likely throw some errors and maybe even break the system. Also installing applications without updating the distro (with pacman -S application_name) will likely fail because of the not updated dependencies.

If you have searched the net for a very cheap tablet, maybe you have seen a lot of 7" chinese ones featuring the WM8650 SoC. This SoC has an ARM9 CPU running at 800 MHz, a DSP, a 2D graphics accelerator and a lot of peripherals.

I don't like tablets at all, but I found some cheap chinese netbooks containing pretty much the same hardware, removing the touchscreen and replacing it with a keyboard + touchpad. I couldn't resist and bought one of these netbooks in Aliexpress. It costed me around 50€, shipping costs included. The specs of this machine are:

Wondermedia WM8650 SoC at 800 MHz.

256 MiB DDR RAM (I think it runs @ 800 MHz, but I'm not sure).

2 GB internal NAND Flash.

7" 800x480 pixels TFT screen.

3 USB Host ports.

1 Ethernet port.

WiFi.

Headphones and microphone ports.

Internal 7,4V 1800mAh LiPo battery.

9V 1,5A power adapter.

Android 2.2.

The Android distro that comes pre-installed is pretty usable even without a touchscreen. As the specs of this machine are really far from being impressive, it doesn't run butter smooth, but works very well.

Android is OK, but as an Arch Linux fan I am, I wanted to make this netbook run it, so I started searching the net to see if anybody had already made it. The only thing I found was a Debian port for these netbooks, using the kernel from a preinstalled Android distro. This Debian port works, but isn't very well optimized, and for example, boot time takes almost 2 long minutes.

The closest thing I found is an Arch Linux port for a WM8650 based tablet. This tutorial is really great and very well detailed, and my work getting the kernel built is almost entirely based on it. John has made a really good job getting the Linux kernel built for these tablets.

In this post, I will detail the process I have followed to get a base Arch Linux system running in this netbook, but I will skip the kernel build process (maybe I'll detail it in a later blog post).

OK, let's get our hands dirty. You will need a SD card. The minimum required size of the SD card is 2 GB, but I recommend using at least a 4GB card, unless you don't need a desktop environment. The steps to get Arch Linux running are:

Partition and format the card. To do it, I have used gparted application. First create a very small FAT32 partition, and name it BOOT. The smallest partition gparted allowed me to create was 33 MiB, more than enough (we need less than 4 MiB). Then create a ext3 partition using the remaining space, and label it ARCH_SYS.

Partitions created in the SD card

Copy the boot script (wmt_scriptcmd) and kernel (uzImage.bin) to the BOOT partition. Download them here. Then run:

tar -xjf alarm-wm8650-boot.tar.bz2 -C /run/media/doragasu/BOOT/

Make sure to replace "/run/media/doragasu/BOOT/" with the directory where the BOOT partition of the SD card is mounted.

Make sure you replace "/run/media/doragasu/ARCH_SYS/" with the directory where the Arch Linux system partition is mounted, here and from now on. Also make sure to run it as root (write sudo before the tar command if you are not root).

Copy the kernel modules to the ARCH_SYS partition. Download them here, and run (as root):

We are ready for the first boot. Unmount the SD card, insert it in the netbook and power it on. You should see the Android robot, and then the messages Loading Kernel... and Starting Linux... should appear. In a few seconds, you should be able to see the boot messages, and finally get the login prompt. The first boot will take a lot of time because udev has some problems and eats almost all the CPU. We will fix these proplems in the next step. Default password for the root user is root.

Udev needs the accept4() OS call, that is not supplied by the Android kernel I have built. To fix this, you have to install libaccept4. Download this package and put it inside the SD card (for example in /root). Then start Linux, login as root and in the console change to the directory containing the downloaded package and type:

Accept the installation of the library, and reboot. Udev should be working fine from now on, and boot time will be a lot shorter.

To extend battery life, power to the internal WiFi dongle is off by default. To enable it, you need to toggle the GPIO pin controlling its power. Download this package, copy it to the SD and install it with the following command:

pacman -U wmt-gpio-1.0-1-arm.pkg.tar.xz

Upon installing this package, to enable the WiFi chip, you have to input the command:

gpio 1:6:d8110040:d8110080:d81100c0

And to disable the WiFi chip:

gpio 0:6:d8110040:d8110080:d81100c0

You can create two scripts with these commands, or if you always use WiFi, you can add the first one to /etc/rc.local, to enable WiFi each time the system boots.

To read the battery charge level, use the following command:

cat /sys/class/power_supply/wmt-battery/capacity

To change the screen brightness, you have to write a number between 0 and 255 (the greater, the brighter) to /sys/class/leds/lcd-backlight/brightness. For example:

echo 200 > /sys/class/power_supply/wmt-battery/capacity

You can also add this line to rc.local to set the screen brightness to your favorite level each time the system boots.

Now you have a fully functional base Arch Linux install. It's highly recommended to update your system (pacman -Syu). Then you can start installing your favorite utilities, window manager, etc., by following the instructions documented in the awesome Arch Linux Wiki.

I'll give you some hints for Arch Linux newbies. Skip them all if you are experienced with this distro. You can start by editing /etc/rc.conf. This file contains some basic configuration parameters, like for example the timezone (TIMEZONE), the hostname (HOSTNAME) and some basic network configuration parameters (that default to DHCP on the Ethernet port). Very important in this file is the last line, detailing the services started when the system boots, and the order in which they are started. I usually remove netfs from the list, replace network with networkmanager (you'll have to install it first) and add dbus (you'll need it for the window manager and some more programs). If you use networkmanager instead of network daemon, make sure you put it after dbus.

To set the locale (in case you don't want the default en_US.UTF8), you have to follow these steps:

Edit /etc/locale.gen. This file details the locales generated by the system. You can replace/add the desired locales to this file. For example, to generate locales for spanish language, add:

es_ES.UTF-8 UTF-8
es_ES ISO-8859-1
es_ES@euro ISO-8859-15

Generate the new locales by running (with root privileges):

locale-gen

Edit /etc/rc.conf and change the default locale to the desired one. Of course, the locale must be one of the included in /etc/rocale.gen. For example, for spanish:

LOCALE=es_ES.UTF-8

To change the root password, use the command passwd. To create a new user, use the command adduser. Leave the default parameters, but when asked for additional groups, enter the following:

audio,lp,storage,video,wheel,games,power,scanner

It's highly recommended to install sudo and add the user to the sudoers. Just follow these steps:

Install sudo:

pacman -S sudo

Allow all the users in the wheel group to use sudo. Run the visudo command, and uncomment (remove the '#') the following line:

# %wheel ALL=(ALL) ALL

If you don't know how to use the vi editor, press the [I] key to [I]nsert text, when you finish, press [ESC] to enter command mode and write :wq to write the file and quit the editor. If you mess something up, just press [ESC] to switch to command mode, and write :!q to quit without saving changes. Then try again the visudo command.

And that's all for today. If you followed this tutorial to the end, congratulations! You should be able to launch GNU/Linux in your shiny WM8650 laptop, with the locale, timezone and (hopefully) Ethernet network properly configured. You should be also able to login as a non privileged user, and use sudo to run tasks as root. If you have questions, feel free to ask them.

What? You don't like the console? Don't worry. In the next chapter, we will learn how to install a graphical desktop environment. Stay tuned!

TROUBLESHOOTING:

I have patched the kernel to make it compatible with the environment of the Android distro that comes pre-installed in some netbooks. You should be able to boot Android (without the SD card inserted) and GNU/Linux (with the SD card inserted). It works on my netbook, but it looks like there are different hardware revisions of these netbooks, and some of them, may require to change some variables in the environment stored inside the internal Flash memory. Typical problems that may arise are for example not being able to use the Ethernet port, or losing the ability to read the internal battery level. If you experience these problems, I can provide you with a modified wmt_scriptcmd that changes some variables of the environment stored in Flash, to make the broken things work. But I'll not post it here unless someone asks for it, because if you overwrite some variables, you may break things in the Android kernel (i.e. you can loose the battery level information in Android). And if you didn't back up that variables first, you might not be able to fix these problems.

Other problem that may arise, is that WiFi may not work. WiFi in these netbooks is implemented using an internal USB WiFi dongle. The one used in my unit has a Realtek RT8188CU chipset. I had to search the net for a compatible driver (rtl8192cu) and merge it into the kernel drivers. If your netbook uses a dongle with a different chipset, WiFi may not work. Enable WiFi with the gpio command, run lsusb and show me its output. I'll try to help you to get the dongle working.

thanks for this my daughter received on for Christmas and imho the android os on there is fairly unusable. The app store didnt even have facebook (not great for a teenage girl) so look like this is the way forward

Nevermid, I was asking for some info on the buying from Spain, but bought one already (less than 60 euros at Ebay). So, in a month or so, I will be asking things here ;) (Hopefully just few things, have worked with this kind of SoCs before (Beagleboards, Pandaboards and so, but this is kinda great, as it has screen, keyboard and enclosure. And I do not need 3D accel, so...

Well, it's ordered and will come in 3/5 weeks, so be sure I will be right back to ask some questions. I am hardware engineer, so I am more confident when I need to route a board or design a little add-on than messing with the software. But I can't resist when I see gadgets this cheap. And, as you, hate tablets, so...

Now I need to read some info about the SoC, but having a little experience with uBoot & friends, I hope it will be easy enough.

WARNING: Using the script attached to this comment, could make the Android distro unable to use Ethernet port. As this scripts overwrites a variable stored in the nand flash, it's HIGHLY recommended to backup variables first. To do so, you can follow this tutorial I wrote on Slatedroid: http://www.slatedroid.com/topic/34131-help-to-get-default-environment-for-wm8650-netbooks/

Once you have made a backup, follow these steps:1.- Download the modified script: http://www.mediafire.com/?dcyg78ap2dk599h2.- Replace the default wmt_scriptcmd in the BOOT partition of the SD with downloaded one.3.- Start Linux on your netbook, Ethernet port should be working now.4.- Power off the netbook and restore the original wmt_scriptcmd to the BOOT partition. If you fail to do this step, everything should continue working, but each time you boot Linux, U-Boot config will be overwritten (with the same configuration, but overwritten anyway) and in the long run, you can damage the flash partition used to store U-Boot environment.

Please let me know if the script works, and if is compatible with the Android distro in your netbook.

It looks like it isn't, but I'm not experienced with aircrack-ng. Might be PEBCAK:

$ airmon-ng start wlan0

Interface Chipset Driver

$ airodump-ng wlan0ioctl(SIOCSIWMODE) failed: Invalid argument

ARP linktype is set to 1 (Ethernet) - expected ARPHRD_IEEE80211,ARPHRD_IEEE80211_FULL or ARPHRD_IEEE80211_PRISM instead. Makesure RFMON is enabled: run 'airmon-ng start wlan0 <#>'Sysfs injection support was not found either.

It is probably just an UART for debugging purposes, so if you want to mess with uBoot, you just probably need to hook that to a transceiver and to a serial port in your PC (If you have any ;) ). The boards i've seen use to comunicate at 115200 bauds.

If someone is trying, remember the transceiver part, or you will probably fry the netbook...

PS (Mine arrived yesterday. Have ARCH up & running, with LXDE, and just need to compile a driver for wifi (Came with RT5370)

Hi, thanks for the great tutorial!:)Do you happen to know which parameters in wmt_scriptcmd you need to modify to make the battery indicator work? I tried to set wmt.io.ts to 1:uor6150..., according to John's guidelines - but I get tons of "ERR: UOR_IICRead() Failed, errno=.5" messages, and a constant capacity of 0 then... Probably because the netbook doesn't have a touchscreen, but I have no idea what should I put there instead.I'd appreciate any hints, thanks!

Are you using the kernel from John Williams? I had that problem with his kernel. I had to disable the UOR chip in the kernel configuration, and patch the battery reading code. You should not have that problem with my kernel build. For battery readings, these two variables must be set like this:

WOW, after updating wmt.gpi.bat it works, and it didn't break the Android's battery indicator!:) Many, many thanks!

For the record, my former wmt.gpi.bat was:[0:0:00020000:d8110040:d8110080:d8110000:d8110480:d81104C0][1:0:00000020:d8110040:d8110080:d8110000:d8110480:d81104C0][2:1:00010000:d8110040:d8110080:d8110000: d8110480:d81104C0]

BTW, would it be a problem for you to share your .config file & patches you have made to the kernel source? Your build is working great, except for the fact that I have a different WiFi adapter and would have to compile the appropriate driver - if I take John Williams' precompiled binary or try to compile with unpatched kernel sources, I get a "module_layout mismatch" while trying to load this module..

If course I'm planning to share it, but I wanted first to fix some things. Right now there are two problems inside the kernel I have not been able to solve:

1.- Bogomips count is not properly calculated in /proc/cpuinfo. It should be about 800, but is reported as 299. I know the CPU is working at 800MHz because the programs take the same time with my kernel and with the Android one (that properly reports bogomips near to 800).2.- The terminals lack cursor. Cursor is working in virtual terminals inside X-Windows, but text terminals lack it. I have tried several hacks, but I can't switch it on.

Anyway, I have not much time to continue investigating the sources, so I think I'll release them as they currently are, and maybe somebody will be able to solve this problems.

I'm booting Arch to a SD card. I left the internal Flash untouched, so it boots Android unless I insert the SD card with the Arch install.

Unfortunately I don't have time to dig the kernel searching where does it expose those parameters. If you have programming skills, you can try to build the kernel yourself, and patch it to your needs. I wrote a tutorial about compiling the kernel:http://kernelhacks.blogspot.com.es/2012/06/building-wm8650-netbook-kernel.html

Have you enabled WiFi with the gpio command? If it's enabled and is not working, maybe you have a different WiFi dongle inside your netbook (mine is RT8188 based). Install hwids and enable WiFi with the gpio command:

Your WiFi dongle is based on the RT5370 chipset. Unfortunately the driver for that chip is not included in the available kernel. There are sources available, if you don't know how to do it, I can try to build them when I get some time.

I assumed that would be the case I am a little more experianced using Ubuntu and have seen a guide on the chip set so I may give it a try. Is it a case of compiling the driver then loading as a module ?

I've got the same WiFi device in my netbook like pete.Can anyone help me to implent the driver? i'm familiar with programming...but just for embedding systems with microcontrollers and not even arm...I'm not sure what is necessary to get this work done, but if anyone can help me at the beginning, that would be a relief.

Well, the ethernet is working now, thank you for your help, but WiFi seems not to be working, but that's not that bad at all. there are another problems, LXDE is working, but only if i start x manually.If i type my login into slim lxde won't start, i have to press ctrl + alt + F1, then i see the standard terminal which is asking for login.another problem is, that i can't install the libfm and pcmanfm packages, pacman is showing this and abord all actions:

well, i solved the problem with installing pcmanfm.the only two things to solve are the WiFi that isn't working, dmesg says "rt2870: probe of 1-4:1.0 failed with error -1"Another Problem is, that I can't mount usb drives. lsusb either doesn't show them or show them wrong, e.g. my maxell 1GiB flash drive is listed as a Kingston 4GiB...any suggestion?

Are you using the updated kernel and modules I pointed in my earlier post? Have you tried manually loading the rt5370 driver using insmod?

Also have you upgraded your system using "pacman -Syu"? I had problems with module auto-loading when I did it last time. I solved it by manually moving everything in "/lib" to "/usr/lib", and then creating a "lib" symlink pointing to "/usr/lib".

I did everything what you mentioned in your tutorials. after i configured to autoload the module at startup and toggle the GPIO to activate WiFi, it seems to work, with "iwlist ra0 scan" i found my router.So now, the wlan device seems to work.I put the line "@nm-applet" to the startup file, but it doesn't start the nm-applet, so i can't use the network manager. rc.conf is exactly like yours except of the netfs daemon...maybe i could delete this one.and slim won't start lxde at all, but one thing at a time.ArchLinux is exciting, of course, and the last days i read a lot about it, but a little bit help at the beginning isn't that bad :D

You mentioned a Debian port but did not give a reference. I prefer Debian over Arch. The Olimex single board uses the same ARM 926J processor. Previously, I could not find a Debian or Fedora port for it. Could you please give a link to the Debian port?

I have a very similar looking Crystalview 1GHZ netbook. I can't seem to get it to boot off the SD Card. Might I have to modify the boot script to get it to work on the slightly different hardware? I get a little picture of tux in the upper left corner then the android boot animation logo and then it boots into android like always.

Sorry for the late reply. Unfortunately I don't have a netbook like yours to play with, so I don't think I can help you too much. I suppose that netbook is not WM8650 SoC based. If I'm right, to get it working you will need a different kernel, suited to the SoC in your netbook.

And repeat steps 2 and 3 of the tutorial, but with these files instead of the original ones. I hope this solves Ethernet problem.

I'm not sure how we can get the complete amount of RAM working. Maybe we only need to pass the right value to the memtotal variable in the boot script. Have you installed other Linux/Android distros to your netbook? If you did, maybe other bootscripts could have overwritten the right value. In any case, you can try getting the values stored in the Flash. Repeat the steps depicted in this post (http://www.slatedroid.com/topic/34131-help-to-get-default-environment-for-wm8650-netbooks/) and post the results.

Now ethernet works . But the memory problem , I think that you could make a version of the wmt_scriptcmd but with the mem=512M for testing. Maybe that work. I dont have yet install android on this netbook and the factory WinCE its not working after use Arch.

I am reading the link with the steps but looks for profecional , maybe chaging the wmt.. first and them try the other... ??

I was happy , and begin the problems ... I use a micro SD inside a transfer SD card and a USB cheap MMC card reader . I format the first time fat and ext3 , no problem . But now that I want to test the new file that you make , its getting an error on the ext3 partition . I/O error and dont copy nothing to it. I try to reformat but still the same. Any help for this or maybe use a USB device for test the Arch again...

The wmt_scriptcmd file I uploaded must be copied to the FAT partition. Failing to copy files to the EXT3 partition could be because of a lot of reasons. I/O error sounds to me like a filesystem or hardware problem. Maybe there's a problem with the SD/MMC card reader, maybe the filesystem and/or the partition table got corrupted. Or maybe the SD card is one of that fake/counterfeit chinese SD cards that rise all kind of problems (did you buy the card at eBay?).

You can try clearing the partition table and creating again the partitions from scratch. If that doesn't solve the problems, my guess is that either the SD or the SD/MMC card reader is damaged.

Maybe you can do that by replacing "root=/dev/mmcblk0p2" with "root=/dev/sdX", with X = the node in which USB device gets mounted. But I'm not sure you can achieve this without rebuilding the kernel, because usb_storage is built as a module, and I suppose you need to build it inside the kernel. Also I would recommend you increasing the rootdelay (i.e. "rootdelay=10").

The RAM its not solve yet I find a patch for Uberoid that works . But linux is more complicate I dont really know where I have to change memory amount . Because all the wmt_scriptcmd files from Uberoid or linux or even WINCE7 , all have 214 or similar amount in mem boot area so the thing should be change in other file or kernel or... thats where I dont know. For example the patch ( http://www.sendspace.com/file/sqcpcz ) for uberoid have this file , env_boot that have this:

Testing and Testing.... I dont find the right amount for memory on the wmt_scriptcmd only 212 or 244 works . WinCE7 show memory size of 368 mb . But forget that, now I really want to boot this Arch version from a USB drive but I cant . I think its the kernel (uzlmg.bin) that not have that option. Could you make a new version of the kernel with that?

I'm sorry but I'm not building customized kernels anymore. It takes time I don't have right now. You can try building it yourself. Once you set up a cross compiler, it should be easy to do following the tutorial in this blog.

I suppose both netbooks should work as long as they are WM8650 based, but maybe you will have to do some tweaks to the 10.1 inch one to get the right video mode and the front camera working. It's difficult to know without having one to test.

About the 600 MHz CPU clock, I don't know if it will make a big difference. Maybe the 600 MHz CPU speed is a typo. These WM8650 based netbooks and tablets usually have a small board with the CPU + Memory soldered to a bigger PCB with the peripherals. It would be a bit strange if this netbook wouldn't use this "standard" CPU board with the "standard" CPU speed.

I guess I buy the 7inch one, because of the higher battery life (4h).About the CPU clock, i don't think that it's a typo, because many more sellers are offering it and everyone of them has the same specifications, 600Mhz.

hi, I asked in your video some time ago which system run better, uberoid or arch, as I see it arch looks better (I bought my netbook some days ago) but gee, I don't understand all this fancy codes, I know ubuntu and the commands it uses, but arch is a whole different history, from my understanding I can't use pacman in ubuntu, so how do I execute the codes that use that? I don't know but of course I'm willing to get a bump in the right direction

Can you please apply the required patches to the tar you are letting everyone download on the page http://kernelhacks.blogspot.in/2012/06/arch-linux-on-wm8650-netbook-ii.htmlso that the changes in the Arch Linux boot process after 20th nov 2012 wont stop user from updating dependencies and packages. Or just write a tutorial for the same

I have the same but black computer than you! but i can pass from first boot, the message is: unit ssh services entered failed! hope you can help me! my mail is luisascoobydoo (at) gmail .ccom thank you!

i am using ubuntu to do this. but i enter the first command tar -xjf alarm-wm8650-boot.tar.bz2 -C /media/ubuntu/boot. but it gives me this error. ar (child): alarm-wm8650-boot.tar.bz2: Cannot open: No such file or directorytar (child): Error is not recoverable: exiting nowtar: Child returned status 2tar: Error is not recoverable: exiting now.

PS. I delved into the comments and found a post by Wicnx (pardon me if I make a mistake but I think this was the name), and I found that I have to make wmt_scriptcmd file. When I opened it in vi, it contains strange characters, meaning it's a compiled file. How can I build one such file on my PC?

I have manually flashed my device from thwindows ce 7 that came on it to the modroid 2.2 and that worked fine but i noticed linux is a much more powerful os than android aqnd to be quite frank android sucks without aq touchscreen so i followed steps all the way up to first boot and it gives me "kernel panic - not syncing:no init found. Try passing init= option to kernel. then it freezes

Do you have any info on how to enter ANDROID RECOVERY MODE on these netbooks? I have one that no matter what, won't boot. It boots to a black screen to be exact. Many tutorials said to enter android Recovery Mode upon boot by pressing certain Volume-up key + power button but these netbooks do not have volume buttons!.. I also read about Fn+F2+Home. Doesn't work for me.

Would this same kernel also work for a Wondermedia 8880 netbook? are these chipsets backwards compatible?. I have one WM888 netbook w 1GB RAM and 8GB flash storage, which came with Android Kitkat. -TIA