Thread: Maemo Rewritten
View Single Post
Posts: 87 | Thanked: 40 times | Joined on May 2007
#24
I have one more idea about totally open stack.How about boot loader?Even PCs with their crappy proprietary BIOS'es still have opensource projects like CoreBoot these days.

Warning: reading further information can cause serious headache or may cause you to mess with things which are not totally safe for N8x0 devices health. You has been warned .

Nokia's NOLO is a very stupid piece of ... uhm, software. Once you managed to get device unbootable, you have to say "good bye" to all your data stored in internal device memory since you can only reflash device at this point. And this means your data are about to be deleted. Without any chance to create backup first. Not to mention it haves pretty few features and needs special proprietary software to deal with, etc . And on technical side for boot loader it is easy to fetch semi-damaged JFFS2 partition from flash and send it to flasher so it can store it into file. Then there is no prob's to mount such file using any decent Linux distro (or even live CD) to re-gain access to your data or even fix things preventing device from booting and re-upload fixed JFFS2 image rather than default one (that's what original flasher does and that's why it erases all data).

With a better boot loader it is possible to back-up data and use more convenient and standard ways to update firmware, like TFTP, HTTP, DFU, etc...

Furthermore, with a decent boot loader it could be possible to boot from alternate locations like SD card or network without custom initfs or whatever. I.e. in this way we can load custom kernel, initfs and rootfs from somewhere else. Just like you can boot complete system from CD-ROM or flash drive or network on PCs.

Some well known exmples of great and fully featured loaders are U-boot, RedBoot, etc. As a great example, you may want to take a look on how OpenMoko uses u-boot...

Caveats on this ways are at least;
  • This is undocumented. It deals with hardware and it's early initialization and some things are, uhm, unknown. Protocols, hardware initialization sequences, etc. And no, you can't strace boot loader, unfortunately (though it is possible to disassembly it and in many countries this is even completely legal and also there is "clean room" technique exists ).
  • It is possible to kill ("brick") device in this way. Once NOLO is f...d up, you're losing USB connectivity in boot mode. Since it is NOLO who listens on USB bus and communicates with flasher. But there is way to recover it, Nokia calls this "cold boot". Sadly it is not very well documented as well to the best of my knowledge. I suspect that you can use it in following way: attach serial cable to these strange pins under battery cover and use "cold boot" mode. Then boot loader part sent over serial wire to CPU regardless of lack of boot loader in flash (as far as I can guess this is powered by OMAP's internal ROM) and CPU can boot further and flasher uses this to reflash firmware parts in "cold boot" mode.
  • Ii is a very challenging task which requires to be familiar with hardware and unusual stuff which happens during early boot...

Btw, if someone cares about all this: you can find first part of boot loader, so called X-Loader on Ti's Linux related pages. It comes with sources, btw (Nokia maybe changed them a bit but basically it appears to be very similar to X-Loader from Ti sources).

What is this X-Loader stuff? OMAP CPU can't execute code from NAND directly, NAND haves too strange bus interface and too tricky blocks management to allow such things as direct code execution. So, OMAP comes with built in boot ROM. This boot ROM is quite sophisticated as far as I can guess (it is not documented for some reasons ). This boot ROM can load loader over serial cable ("cold boot mode").This boot ROM can execute "secure boot" sequence if desired (to prevent unsigned or tampered software from starting, fortunately it looks like n8x0 are not using this restrictive so-called-"feature").But most interesting, this ROM seeks for X-Loader in NAND and attempts to load it and starts it (optionally checking it's signature before, if secure boot mode desired, as I can guess, looks like in our case there is simply no signatures, though I did not checked this myself yet). X-Loader size is limited in size and should obey certain rules of it's layout so boot ROM can locate it and load it and run it. Due to limited size this loader does not executes all things itself. It only performs some hardware tests and attempts to load bigger second part from NAND flash. This bigger second part is known as "NOLO" and includes more featured module which can talk over USB with flasher and re-flash firmware parts. I guess this part can be replaced with something much better (like U-boot).
 

The Following 12 Users Say Thank You to PowerUser For This Useful Post: