Active Topics

 


Reply
Thread Tools
Posts: 2,154 | Thanked: 8,464 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:
Posts: 63 | Thanked: 27 times | Joined on Jul 2011 @ Venezuela
#2
Hello, I'm getting these errors when compiling file getbootstate.c in Scratchbox:

[sbox-FREMANTLE_X86: ~] > gcc -Wall -g getbootstate.c -o getbootstate

getbootstate.c: In function 'get_bsi':
getbootstate.c:234: warning: implicit declaration of function 'ioctl'
/var/tmp/ccmwLNCv.o: In function `get_rdmode':
/home/leli/getbootstate.c:256: undefined reference to `cal_init'
/home/leli/getbootstate.c:259: undefined reference to `cal_read_block'
/home/leli/getbootstate.c:260: undefined reference to `cal_finish'
collect2: ld returned 1 exit status

Am I doing something wrong?
 
Posts: 2,154 | Thanked: 8,464 times | Joined on May 2010
#3
compile with flag -lcal
 

The Following 4 Users Say Thank You to pali For This Useful Post:
Posts: 1,680 | Thanked: 3,685 times | Joined on Jan 2011
#4
Originally Posted by pali View Post
compile with flag -lcal
Pali, whats your paypal. I wanna buy you a beer.
__________________
N900: One of God's own prototypes. A high-powered mutant of some kind never even considered for mass production. Too weird to live, and too rare to die.
 

The Following User Says Thank You to vi_ For This Useful Post:
Posts: 2,154 | Thanked: 8,464 times | Joined on May 2010
#5
Originally Posted by vi_ View Post
Pali, whats your paypal. I wanna buy you a beer.
Why? (I do not have paypal)
 
Banned | Posts: 778 | Thanked: 337 times | Joined on Jun 2010
#6
Originally Posted by pali View Post
Why? (I do not have paypal)
he meant thanks
 
Posts: 2,225 | Thanked: 3,822 times | Joined on Jun 2010 @ Florida
#7
I just wanted to state this since no one else had: this open source getbootstate works on-device, and I personally would recommend using it. I've been running it on my N900 instead of the stock closed blob one for a few weeks now, and it works great as far as I can tell.

jvollmann has, as far as I know, also been using the open source one for a time span a few days longer than I've been using it, albeit his is a version slightly patched by Estel to hack around some battery recognition problems jvollmann's device was having.

P.S. @Pali - I think by the time you posted the "-lcal" flag we both (jvollmann and I) independently figured out to use that flag, but I always appreciate the follow-up even if it's delayed.

Personally, I recommend this as a drop in replacement to all power users who want to screw Nokia and/or stand for open source software by sticking the open source one in instead of the closed source one. I think this could very well be pushed to the CSSU as a open source replacement for getbootstate - but I and jvollmann alone aren't enough reliable verification to be sure it's safe (although it's certainly more verification than just running it in qemu was).
 

The Following 9 Users Say Thank You to Mentalist Traceur For This Useful Post:
Estel's Avatar
Posts: 5,028 | Thanked: 8,613 times | Joined on Mar 2011
#8
I'm also using this (unmodified one - Pali's version) and it's working great. +1 like to see it in CSSU.
__________________
N900's aluminum backcover / body replacement
-
N900's HDMI-Out
-
Camera cover MOD
-
Measure battery's real capacity on-device
-
TrueCrypt 7.1 | ereswap | bnf
-
Hardware's mods research is costly. To support my work, please consider donating. Thank You!
 

The Following 3 Users Say Thank You to Estel For This Useful Post:
Posts: 96 | Thanked: 105 times | Joined on Aug 2006 @ Finland
#9
It's very nice to see people getting things done and rewriting closed software. Great work. I'm all for adding it to CSSU after making sure it works as expected.
__________________
--
2x770, N810 and 2xN900, N950, 2xN9, BBZ10
Devel - twitter - blog
 
Posts: 2,154 | Thanked: 8,464 times | Joined on May 2010
#10
My patches meego version of getbootstate is for new version os dsme. I need to change some code in this version, because it do not have to work correctly.

And I think this is not for CSSU. Original package getbootstate contains:
* shell script /sbin/preinit which is non redistributable
* this getbootstate binary
* other closed source and non redistributable binary
 

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

Tags
free maemo!, getbootstate, open source


 
Forum Jump


All times are GMT. The time now is 04:20.