ELC2009 – 5 Second Boot
Speaker
Gregory Clement
Links
http://www.celinuxforum.org/CelfPubWiki/ELCEurope2009Presentations http://www.adeneo-embedded.com/srt/en/home
Introduction
Gregory’s talk was presented on Thursday 15th October 2009 to a crowd of about 100 attendees. In it he talked about how he and his collegues had taken a ARM9 based (Atmel AT92SAM9261-EK) board and managed to reduce the boot time from 30 seconds to just under 5 seconds.
Main points
- Reducing boot times is a hugely popular subject at the moment.
- There are a lot of initiatives aimed towards this effort.
- Some techniques for boot time optimisation can save a lot of time such
as the use of UBIFS. - Some techniques are hardware dependant (loop per jiffies).
Background
Gregory started off by explaining a common problem that embedded developers face, that of excessive boot times for their devices. The consumer doesn’t want to wait for their device to boot and this is even more evident when consumers are using an embedded device.
Device used
- Atmel AT92SAM9261-EK board
- ARM9 based running at 200MHz
- 64MB SDRAM
- Dataflash (SPI)
The boot process
The boot process was discussed. To begin, a first stage boot loader is run which is responsible for setting up the basic hardware, GPIO, clocks, SDRAM and so forth. This in turn calls the second stage boot loader, U-Boot for instance which then takes care of the bulk of the remaining initialisation. The second stage loader will initialise any remaining hardware. Funny fact, the name U-Boot is also given to a Polish and Flemish beer mix made from beer and vodka (one bottle of beer and one shot of vodka.
From there the Kernel is loaded by the second stage boot loader. The kernel is responsible for loading drives, mounting filesystems and finally calling the userspace process, init.
Time measurement
Gregory went on to talk about different measuring tools such as the global measurement tool, serialchrono (in-house script), kernel level measuring tools printk-times and initcall_debug and user-space tools such as bootchart.
- serialchrono just adds timestamp to the start of every message from the serial port.
- Printk-time adds a time stamp to the beginning of each console output. Activated with: printk.time=1 on the kernel command line or by setting CONFIG_PRINTK_TIME=y in the kernel config.
- initcall_debug measures the time spent in each initcall during boot. Activated by adding ‘initcall_debug’ to the kernel command line. Results are available through dmesg. This can be changed into a readable graph by using Arjan van de Ven’s script, bootgraph.pl. Note that initcall_debug significantly increases boot time.
Bootchart-lite
Bootchart-lite is a user-space boot measuring tool which collects data from /proc
to produce a readable boot chart. It is written in C. Another alternative is timechart.
Optimisation techniques
Gregory detailed the techniques his team used to reduce the boot time from 30 seconds to just under 5 seconds. These were:
- Use UBIFS instead of JFFS2 (saved 15.5 seconds). Good article on UBIFS http://www.lwn.net/Articles/276025/
- Remove unneeded rc scripts such as udev. Process essential scripts later if possible (saved 4 seconds)
- Statically link some applications where space isn’t an issue (saved 1.4 seconds)
- Replace /sbin/init with an alternative such as Upstart
- Remove unneeded features from the kernel
- Use deferred modules with echo 1 > /proc/deffered_initcalls
- Set CONFIG_EMBEDDED=’y’
- Disable printk’s (they can be seen with dmesg)
- Preset loops per jiffies (hardware dependant)
- Store the bad block table in flash
- Use ‘fastboot’
- Customize U-Boot for only the necessary items
Hi, my name is Jamie Bennett. I'm a technologist, programmer, researcher, tech evangelist, open source monkey, Linux lover, Mac user and self confessed gadget freak.
