Modified initfs with onscreen boot menu
=======================================

ABOUT

This is modification of initfs partition which optionally removes extra stuff
to gain free space (testserver - used for factory testing) and with boot menu
that allows you to select boot/root device via tablet keys on each boot.


HOWTO

 Run initfs_flash script on your tablet and follow instructions. You can also
 use jffs2 image as a parameter to reflash previously prepared image. You
 must reboot the device after flashing (script will do this for you).

 ! WARNING !
 
 Do not extract flasher archive to SD/MMC card or run it from there. It won't
 work. Do not copy already extracted archive from SD/MMC card to internal flash.
 It will be incomplete. What you should do instead is to extract tgz archive
 directly to internal flash (or other unix filesystem) and run it from there.
 
ROOT DEVICE

Root device name is stored with various other flags (like R&D mode etc.) in
config partition on the device and determines what device contains main (root)
filesystem that should be booted when the device is powered on.

Original root device possibilities:

flash - boot from internal flash (/dev/mtd4 partition called 'rootfs')
mmc - first mmc partition (/dev/mmcblk0p1)
      since 2006-38 it searches also next partitions and boots first suitable one
usb - usb storage device (harddisk) in usb host mode

New options added by bootmenu:

ask - show bootmenu everytimes and let user select
ask:xxx - show bootmenu, preselect item xxx (with timeout)
off - turn device off (works only when charger is not connected)
mmc2 - second mmc partition (/dev/mmcblk0p2)

and any other option you add yourself, see below for bootmenu customizations

Root device can be set either by linux flasher on PC over USB cable [1]
or directly on device via cal-tool command [2].

1. # ./flasher --set-root-device ask:mmc2

2. Nokia770-39:~# chroot /mnt/initfs cal-tool --set-root-device ask:mmc2


CUSTOMIZATIONS

 See bootmenu.conf.nXXX.example for details. Copy example to file named
 bootmenu.conf and customize it. initfs_flasher script searches for this file
 in current directory. If found, it asks you to include it in final initfs image.

USB NETWORK RECOVERY MODE

If you answer yes to dropbear and/or utelnetd installation prompt, bootmenu allows you
to press Home key when in menu to start usb networking and dropbear and telnet daemon.
This mode allows you to log in, mount rootfs on mmc or internal flash and fix the system
or recover data.

Device IP address is by default 192.168.10.1. You can change it in your bootmenu.conf
via USB_IP variable.

You also need to setup usb networking on your PC, guides for Windows XP and linux: 
http://maemo.org/community/wiki/usbnetworkingwinxp/
http://maemo.org/development/documentation/how-tos/3-x/howto_usb_networking_bora.html
http://maemo.org/development/documentation/how-tos/2-x/howto_usb_networking.html
or use Google. You also need to assign IP address of PC to be from same network as
the tablet. For default tablet USB_IP value of 192.168.10.1 you can pick 192.168.10.2
for your PC.


Procedure for using recovery mode is:

1. press home key and let the tablet start networking
2. attach usb cable
3. install drivers on PC side or otherwise bring up usb networking on PC side
4. log in (telnet 192.168.10.1 or ssh root@192.168.10.1 rootme)
5. ???
6. log out
7. disconnect cable
8. press escape key to stop usb networking and go back to bootmenu

Random tips:
If your initfs is full, only /tmp is writable when you log in.
If you don't have dropbear installed in rootfs, ssh server keys are generated to /tmp
on each boot. You can copy those keys to permanent location in /etc/dropbear/
If you have drobbear in rootfs, ssh server keys are reused (=copied to initfs).
Telnet daemon sometimes misses keypresses when typing fast (autorepeat - arrows in vi),
dropbear is better.

Some example commands when logged in
mkdir /tmp/mnt
mount -t jffs2 /dev/mtdblock4 /tmp/mnt
insmod /lib/modules/2.6.*/mbcache.ko
insmod /lib/modules/2.6.*/ext2.ko
mount -t ext2 -o noatime /dev/mmcblk0p2 /tmp/mnt
umount /tmp/mnt

For further details search http://www.internettablettalk.com forum for "bootmenu usb recovery"


GENERAL TIPS

If you reboot frequently to different rootfs, enable reboot item in /etc/systemui/systemui.xml
This gives you additional item in Power key menu.

Create your own bootmenu.conf, do not edit bootmenu.sh directly (especially in /mnt/initfs)

After crash reboot to different rootfs and run e2fsck on the crashed one if you use ext2 filesystem.

Consider using ext3 if you don't want to e2fsck after crashes. See example bootmenu.conf.xxxx


ISSUES

- OS2006 and OS2008 initfs partition is completely full, you need to remove
  extra stuff if you want to write to /mnt/initfs/ with OS2008 it may still
  remain unwritable if you install advanced stuff
- Due to small total size and low free space in initfs and due to journaling
 nature of jffs2 system it may happen that you run out of free space in initfs
 even if 'df' reports some free space. This is caused by big eraseblock size
 (128Kb) for NAND flash memory. If there is no complete 128kb free block to
 erase, free space cannot be reclaimed. if this happens save yor changes
 elsewhere and reflash initfs.
- initfs filesystem is mounted all the time and cannot be unmounted due to dsme
 daemon running from it. Reflashing initfs while it is mounted may cause
 inconsistencies and crash. Flashing script tries to force linux kernel to
 cache importants bits of initfs in RAM and also remounts initfs read only
 before reflashing but still reboot is needed sooner or later to get rid of the
 inconsistency.
 

TODO

- allow to set selected item as a default for next boot (use cal-tool -R inside menu)
- package mtd-utils and then package also bootmenu, add dependency to patch and store only linuxrc diffs

CHANGES

August 12, 2008
- flasher now renames old initfs.*.jffs2 image files if found
  this prevents flashing old image if new image creation fails (thanks tolou)

March 4, 2008
- workaround for inconsistent mmc names
  http://bugs.maemo.org/show_bug.cgi?id=2747
- default menu items for external and internal mmc cards

September 11, 2007
- USB network recovery mode added

October 29, 2007
- allow any answer starting with y or Y as yes
- check for oversized images
- exit when running directly from card
- added screen dimming to examples

CONTACT

Frantisek Dufka <dufkaf@seznam.cz> 