Adventures in “A…” September 29, 2006Posted by Florian in GPE, Source, World.
I always wondered why cellphone manufacturers using Linux for their devices do not release the kernel sources like they are expected to do. Yes there are actually quite some of them – just check linuxdevices.com. Now i found a good reason for this strange (and not really legal) behaviour:
The story began with the idea to find a device to start developing cellphone specific applications on. Of course it needs to be one running Linux. I have several smartphones laying around, but it turned out that it seems to be impossible to get the kernel sources for the Linux running ones and Linux support for the non-native Linux ones is not yet ready for cellphone use. After spending hours searching for a device that is acually available including kernel sources i end up in getting a Motorola A780. There is a quite active community around this device and even better: There is a project to create a complete free software stack for this device including an up to date Linux 2.6 already. (see http://www.openezx.org).
Because the port of the new kernel is in a quite early stage i decided to start with the original Motorola 2.4.20 one released at opensource.motorola.com. The idea was just to build a kernel image that uses a partition on the SD card as root filesystem and run this via boot_usb. In this way you can have a development filesystem without installing anything to the internal flash. Sounds easy, eh?
I knew the this kernel was a Montavista hacked one… these are known to be ugly, but it can’t be that bad, i thought…. they are a big and successful company. It didn’t take long to find out that the sources were incomplete. I applied a small patch… created a missing link to a header file, removed some drivers from the configuration and wondered what had happened to all the documentation that can be usually found in a kernel source tree. The resulting kernel image crashed instantly… did you read ‘Snow Crash’? – Then you know how it looked like.
A pile of slightly differen kernel images with the same result and several (successful!) tests by other developers i gave up on boot_usb and flashed the kernel to the device. It started – before that i couldn’t imagine that i would be happy to see the Montavista logo on a screen. ;-) Well the fun was over when i noticed that the kernel just freezed after initializing the RTC. Five compilers and some hacking around i found out the reason for this odd behaviour: I had disabled the camera driver because of some lacking files… after i found these in the older 2.4.17 source tree i enabled the camera again and the kernel booted until mounting of the root filesystem should happen.
Of course this didn’t work… same like NFS root using the USBD driver. The USBD sources didn’t offer a way to switch away from cdc_acm to cdc_ethernet but when i tried to get rid of USBD at all and use the upstream cdc_ethernet driver it turned out that some functions of it were used in a completely different place in the kernel. Yes, some developer must have loved “extern” :-( The module using these functions was used to change the USB mode – i felt lucky and so did the kernel – networking started to work after using the correct command line switch.
Unluckily “init” did not like the kernel and died very fast. After i managed to convince the kernel to wait for the SD card appear i was able to reproduce the same behaviour with the root filesystem on SD. Note that the filesystem is fine – with 2.6 it starts up and even X works fine. I’m not sure how this story continues… oh right, one more nice thing: In both published original kernels ‘menuconfig’ is broken. It starts with an error message and the menu is not updated if Config.in fils are changed. I really love to see things like
Preparing scripts: functions, parsing../MCmenu0: line 133: syntax error near unexpected token `}’
… not speaking about the ugly warnings during build.
Maybe they should have asked someone who knows about Linux?