Connect your device to application
Rloader,
Alternative technology to
achieve fast boot time
for ARM Linux



Matt Hsu
                   <matt@0xlab.org>
Agenda   Motivation
         Boot Time Measurement
         Reduction Approach
         Hibernation Based Technologies
         Rloader
         Demo
         Summary
         Q&A
Movitation
Why Boot Time?
Define boot time, please
Power saving
User experiences
Android's boot time is especially painful
Devices
  Tablet
  In-vechile system
  TV
  Smart Phone
  Camera
We Are Not Alone
Quick boot
  Ubiqutous

Improving meego boot-up time
  Hiroshi DOYU, Nokia Sotware Architect

Boosting up embedded Linux device: experience on
Linux-based smarphone
  Samsung Electronics Co. Ltd.

Swap-before-hibernate: A fast-on algorithm at OS
level
  Shi-wu Lo, OS Lab, CCU
Embedd Linux Wiki
Boot Time Measurement
Kernel space
Kernel parameter
  printk.time =1
  linux-2.6/scripts/show_delta

Ftrace
  ftrace=initcall

Initcall
  Enable BOOT_TRACER config
  ./scripts/bootgraph.pl boot_time >out.svg
  initcall_debug
User Space
Bootchart
  http://www.bootchart.org/

cat /proc/uptime
2012.39 512.64
grabserial
  http://elinux.org/Grabserial
Hardware Approach
External instrument
  Scope
  Logic Analyzer

Hardware timer count
  Resolution is dependent on your clock source

ETM (Embedded Trace Microcell)
  Need assisted software such as TRACE32/OpenOCD
  New feature in ARM Cortex seies
Reduction Approach
Divide and Conquer
Bootloader
Kernel
Userland
Bootloader
Minimal bootloader
  Qi bootloader
  zboot, linux boot directly
Enable I-cache
Copy kernel into base + 0x2000000 offset
DMA-capable copy
Multi-block read (MMC)
Kernel
Kernel parameter
  quiet
Preset LPJ
  Loop per jiffy
Deferred initcall
  include/linux/init.h
  arch/arm/kernel/vmlinux.lds
Compressed kernel
  UCL
  XZ
Userland
Optimize linker and loader time
  Specific linker option
Parallelize rc script
Application specific optimization
Hibernation based technologies
Hibernate-Based Technologies
Swsusp, aka software suspend




Swsusp2 (TuxOnICE)
Swsusp
Natviely support in x86
Based on work by
  TI, Teerth Reddy
    https://patchwork.kernel.org/patc
    h/96442/
  Nokia, Hiroshi DOYU
    https://lists.linux-
    foundation.org/pipermail/linux-
    pm/2010-June/027422.html
Start hibernation
  echo disk >/sys/power/state
Swsusp2/TuxOnICE
Not support in main line
kernel
Provides many features
  Compression of images
  Readhead
  multiple thread I/O
  drop pagecache
Hbernation trigger
  eho 1
  >/sys/power/tuxonice/do_hib
  ernation
Rloader, (Resume Loader)
Rloader Is Nothing New
Do we really need follow normal booting process?


The implementation of Rloader could be
  Bootloader
    snapshot boot
    www.elinux.org/images/3/37/Snapshot-boot-final.pdf
  Custom kernel
    Kernel with software resume support


Different hibernation images make difference user scenario
Booting Process
 Normal booting

Boottloader
                  Kernel Init             init.rc, platform-specific rc
   init



 Kernel as Rloader

Bootloader Minimal device       Restore
   init         Init            process


 Bootloader as Rloader

Bootloader        Restore
   init           process
Make ARM Hibernated
Merge patches
  swsusp patch from TI/Nokia
  TOI patches according to your kernel version
'swap out' page as much as possible
ARM does not support ACPI
Currently, there are patches for ARM
Cortex A8/A9 provided
Hardware/Software Descripton
ARM OMAP3 Beagleboard
Kernel
  2.6.32 with corresponding TOI
  patch
Bootloader
  Qi
256MB RAM
0xdroid Eclair
Something before hibernating
echo 100 > /proc/sys/vm/swappiness


echo -2 > /sys/power/tuxonice/image_size_limit


echo 3 >/proc/sys/vm/drop_caches


busybox swapon -p 1 /dev/block/mtdX
Normal Booting Time Diagram




                            25 seconds




                                         GPIO signal of
                                         Key-guard event

                 GPIO signal of
Power On Reset   stepping into kernel
Hibernation Boot Time Diagram




                   6 seconds




Power On Reset   GPIO signal of         GPIO signal of
                 stepping into kernel   Key-gurad event
Rloader as Kernel or Bootloader?
It's a trade-off between your boot time and
management cost
Maintainence
  Once kernel/TOI changes, you need to re-implement
Complexicity
  How to restore pages?
  Resume point? PC value?
Improved room might be limited
Further Optimization
Re-construct initcall stages
Try different algorithm out on compressing
images
  http://code.google.com/p/snappy/
Lazy loading
Put driver state into hibernation image
Summary
It's still far away from being a product
File system inconstency
  Power failure as hibernation
Hardware solution is the sliver bullet?
The time of stepping into hibernation is also
needed to concern
Demo
Resource
http://elinux.org/Boot_Time
http://tuxonice.net/
http://gitorious.org/improving-meego-boot-up-time/t2t/commit/d29d8576cf7
www.kernel.org/doc/ols/2010/ols2010-pages-9-18.pdf
http://gitorious.org/+0xlab/0xlab-bootloader/qi-bootloader
http://www.oberhumer.com/opensource/ucl/
http://code.google.com/p/0xdroid/
www.kernel.org/doc/ols/2010/ols2010-pages-9-18.pdf
Sponsored
by

       http://0xlab.org




               27 May 2011

Rloader, alternative tech to achieve fast boot time for ARM Linux