View Single Post
Posts: 2,153 | Thanked: 8,462 times | Joined on May 2010
#1
There was a bug https://bugs.maemo.org/show_bug.cgi?id=7019 about relicensing getbootstate - critical part of booting Maemo. After discusion Nokia decided to not release source code...

Year later developers/users could find source code of program getbootstate on gitorious which is now part of harmattan DSME:
https://meego.gitorious.org/meego-mi...getbootstate.c

I asked if this code is compatible with fremantle. Answer from bugtracker:
"Maemo5 and Harmattan getbootstate are quite similar but with one major difference: in maemo5, getbootstate accesses the battery information. In Harmattan, battery checks are moved to the boot loader (NOLO)."

I used strace and gdb to see what exactly fremantle getbootstate doing. bootreason and bootmode read from files /proc/bootreason and /proc/component_version (instead /proc/cmdline - so it is fully incompatible).

Next, a lot of syscalls is about access to partition /dev/mtd1. When I spend time on it I find out that getbootstate using libcal.so for checking if R&D mode state - nothing more from cal.

Last part was somethink about battery (major difference as written in bugtracker). This was only one syscall iocl 0x6000 (with magic param) for device /dev/twl4030-adc. But it was handled by (open source) kernel module twl4030-madc. With source code from:
http://mxr.maemo.org/fremantle/sourc...030-madc.h#117
http://mxr.maemo.org/fremantle/sourc...030-madc.c#394
I was able to decode magic ioctl param. Fremantle getbootstate set channel to 4 and average to 1 and check result.

If result (of ioctl) is 32..85 it say SERVICE battery and LOCAL bootstate. If result is 87..176 it say TEST battery and TEST state. If result is 280..568 it say normal battery and continue checking state. And last if it not set R&D mode (yes, only here it is used) set state to SHUTDOWN and write error.

With all this info I was able to patch harmattan getbootstate for compatibility with fremantle on Nokia N900. I'm attaching source code of patched getbootstate. I tested it only in qemu and here it worked. USE IT AT YOUR OWN RISK.


If Nokia does not release source code of core programs, we can rewrite it...

Note: For checking if R&D mode is set, my patched version use cal.h and libcal.so library for acces to /dev/mtd1 partiotion. This library is closed source (but stable). I do know now about any open source method how to check if R&D mode is set... Maybe somebody know it..

EDIT:
Source code is now in my bzr repository on launchpad: https://code.launchpad.net/~pali/+ju...o_getbootstate

Last edited by pali; 2011-08-11 at 19:24.
 

The Following 55 Users Say Thank You to pali For This Useful Post: