Quickboot on i.MX6
-
Upload
gary-bisson -
Category
Engineering
-
view
660 -
download
9
Transcript of Quickboot on i.MX6
![Page 1: Quickboot on i.MX6](https://reader031.fdocuments.net/reader031/viewer/2022012405/55a7a0051a28ab32438b4700/html5/thumbnails/1.jpg)
Quickboot on i.MX6FTF2014
04/10/2014
Gary Bisson
Embedded Software Engineer
![Page 2: Quickboot on i.MX6](https://reader031.fdocuments.net/reader031/viewer/2022012405/55a7a0051a28ab32438b4700/html5/thumbnails/2.jpg)
SESSION OVERVIEW
1. Introduction
2. Boot Process
3. Optimizations
4. Solutions
5. Demonstrations
6. Conclusion
![Page 3: Quickboot on i.MX6](https://reader031.fdocuments.net/reader031/viewer/2022012405/55a7a0051a28ab32438b4700/html5/thumbnails/3.jpg)
ABOUT THE PRESENTER
• Embedded Software Engineer at Adeneo Embedded
(Bellevue, WA)
I Linux / Android
♦ BSP Adaptation
♦ Driver Development
♦ System Integration
I Partners with Freescale
![Page 4: Quickboot on i.MX6](https://reader031.fdocuments.net/reader031/viewer/2022012405/55a7a0051a28ab32438b4700/html5/thumbnails/4.jpg)
Introduction
![Page 5: Quickboot on i.MX6](https://reader031.fdocuments.net/reader031/viewer/2022012405/55a7a0051a28ab32438b4700/html5/thumbnails/5.jpg)
Quickboot on i.MX6 Introduction
ARE WE TALKING ABOUT FASTBOOT?
This presentation is about quick boot
• Fastboot is the protocol used by Android to communicate
with the bootloader in order to reflash a system on the
device
• Type fastboot into google: 90% hits within first 10 pages
are about android
Warning
Fastboot is not the subject here!
5
![Page 6: Quickboot on i.MX6](https://reader031.fdocuments.net/reader031/viewer/2022012405/55a7a0051a28ab32438b4700/html5/thumbnails/6.jpg)
Quickboot on i.MX6 Introduction
SPEED DOES MATTER
• Critical systems
I Automotive: need to handle CAN message within a
specific time frame after boot (typically x100ms)
I Monitoring: need to reboot ASAP in case of failure
6
![Page 7: Quickboot on i.MX6](https://reader031.fdocuments.net/reader031/viewer/2022012405/55a7a0051a28ab32438b4700/html5/thumbnails/7.jpg)
Quickboot on i.MX6 Introduction
SPEED DOES MATTER
Consumer are used to previous generation of non-smart
devices that starts immediately
• Consumer products
I TV: turn on quickly whenever pressing on the power
button
I Phones: deep sleep mode allowing to have a
aggressive power management policy while keeping
responsiveness
7
![Page 8: Quickboot on i.MX6](https://reader031.fdocuments.net/reader031/viewer/2022012405/55a7a0051a28ab32438b4700/html5/thumbnails/8.jpg)
Quickboot on i.MX6 Introduction
SPEED DOES MATTER
It is still possible to cheat
• Display splash screen early in the bootloader (x100ms)
• Animate the splash screen while booting
Those tricks give the end user the illusion of a quick boot, but
this could not apply to critical systems.
8
![Page 9: Quickboot on i.MX6](https://reader031.fdocuments.net/reader031/viewer/2022012405/55a7a0051a28ab32438b4700/html5/thumbnails/9.jpg)
Quickboot on i.MX6 Introduction
SET YOUR GOALS
• Need to have clear goals:
I Prioritize features
I Set constraints
• Boot-Time optimization = trade-offs
9
![Page 10: Quickboot on i.MX6](https://reader031.fdocuments.net/reader031/viewer/2022012405/55a7a0051a28ab32438b4700/html5/thumbnails/10.jpg)
Quickboot on i.MX6 Introduction
GOAL OF THE PRESENTATION
This presentation aims at:
• Showing different existing technics to optimize boot time
• Explaining how to integrate those technics
• Showing real customer solutions
10
![Page 11: Quickboot on i.MX6](https://reader031.fdocuments.net/reader031/viewer/2022012405/55a7a0051a28ab32438b4700/html5/thumbnails/11.jpg)
Boot Process
![Page 12: Quickboot on i.MX6](https://reader031.fdocuments.net/reader031/viewer/2022012405/55a7a0051a28ab32438b4700/html5/thumbnails/12.jpg)
Quickboot on i.MX6 Boot Process
BOOT PROCESS
12
![Page 13: Quickboot on i.MX6](https://reader031.fdocuments.net/reader031/viewer/2022012405/55a7a0051a28ab32438b4700/html5/thumbnails/13.jpg)
Quickboot on i.MX6 Boot Process
BOOT PROCESS
Typical i.MX6 boot process:
• Boot ROM
• U-Boot
• Linux Kernel
• Rootfs:
I Linux
I Android
13
![Page 14: Quickboot on i.MX6](https://reader031.fdocuments.net/reader031/viewer/2022012405/55a7a0051a28ab32438b4700/html5/thumbnails/14.jpg)
Quickboot on i.MX6 Boot Process
BOOT ROM
• Boot devices:
I NOR Flash
I NAND Flash
I OneNAND Flash
I SD/MMC
I SATA HDD (only i.MX 6Dual/6Quad)
I Serial (I2C/SPI) NOR Flash and EEPROM
14
![Page 15: Quickboot on i.MX6](https://reader031.fdocuments.net/reader031/viewer/2022012405/55a7a0051a28ab32438b4700/html5/thumbnails/15.jpg)
Quickboot on i.MX6 Boot Process
BOOT ROM
• IVT Header
I Entry point (fixed offset)
I Points to DCD table
• DCD Table
I List of init commands
• Boot data
I A table indicating the program image offset and size
15
![Page 16: Quickboot on i.MX6](https://reader031.fdocuments.net/reader031/viewer/2022012405/55a7a0051a28ab32438b4700/html5/thumbnails/16.jpg)
Quickboot on i.MX6 Boot Process
MEASUREMENT TOOLS
• Grabserial
I Serial output time-stamps
• Bootgraph
I Kernel driver graph
• Bootchart
I Init scripts graph
16
![Page 17: Quickboot on i.MX6](https://reader031.fdocuments.net/reader031/viewer/2022012405/55a7a0051a28ab32438b4700/html5/thumbnails/17.jpg)
Optimizations
![Page 18: Quickboot on i.MX6](https://reader031.fdocuments.net/reader031/viewer/2022012405/55a7a0051a28ab32438b4700/html5/thumbnails/18.jpg)
Quickboot on i.MX6 Optimizations
METHODOLOGY
18
![Page 19: Quickboot on i.MX6](https://reader031.fdocuments.net/reader031/viewer/2022012405/55a7a0051a28ab32438b4700/html5/thumbnails/19.jpg)
Quickboot on i.MX6 Optimizations
INTUITION
The first things that comes in mind are usually:
• Smaller size
I Loads faster (bandwidth of the storage mdevice)
I Loads from faster storage (NOR, MMC class 10)
• Remove uneeded features
I Smaller system (see above)
I Not wasting time
19
![Page 20: Quickboot on i.MX6](https://reader031.fdocuments.net/reader031/viewer/2022012405/55a7a0051a28ab32438b4700/html5/thumbnails/20.jpg)
Quickboot on i.MX6 Optimizations
GENERIC OPTIMIZATIONS
• lpj
I If your products are similar, you can set lpj
I Gain about 250 ms by skipping the calibration loop
• Stripping init
I Start your critical application as soon as possible: rcS
or inittab
I An idea may be to try to use your critical application as
init
20
![Page 21: Quickboot on i.MX6](https://reader031.fdocuments.net/reader031/viewer/2022012405/55a7a0051a28ab32438b4700/html5/thumbnails/21.jpg)
Quickboot on i.MX6 Optimizations
GENERIC OPTIMIZATIONS
• flash storage:
I NAND, NOR, SD
I We usually get really good performance booting from
SD cards, class 4 or class 6, but you will still have to
benchmark
• toolchains
I Not all toolchains are created equal. Changing
toolchains, will usually make you gain the last hundred
of ms
21
![Page 22: Quickboot on i.MX6](https://reader031.fdocuments.net/reader031/viewer/2022012405/55a7a0051a28ab32438b4700/html5/thumbnails/22.jpg)
Quickboot on i.MX6 Optimizations
BOOTLOADER
• U-Boot is slow? Get rid of it!
• arm-kernel-shim solutions
• Freescale platforms: configure just a few register then
passing atags
I Thanks to BootROM / DCD table
22
![Page 23: Quickboot on i.MX6](https://reader031.fdocuments.net/reader031/viewer/2022012405/55a7a0051a28ab32438b4700/html5/thumbnails/23.jpg)
Quickboot on i.MX6 Optimizations
BOOTLOADER
• Kernel may not initialize every device
I relies on the bootloader
• Should we migrate everything to the kernel?
23
![Page 24: Quickboot on i.MX6](https://reader031.fdocuments.net/reader031/viewer/2022012405/55a7a0051a28ab32438b4700/html5/thumbnails/24.jpg)
Quickboot on i.MX6 Optimizations
GENERIC SOLUTIONS
U-Boot Secondary Program Loader (SPL)
• Small binary that fits in SRAM and loads the main U-Boot
into RAM
• Within U-Boot source tree, sharing same code base
• Two scenarios:
I Fast path: SPL loads and then starts Linux kernel
I Development or maintenance mode: SPL loads
U-Boot
24
![Page 25: Quickboot on i.MX6](https://reader031.fdocuments.net/reader031/viewer/2022012405/55a7a0051a28ab32438b4700/html5/thumbnails/25.jpg)
Quickboot on i.MX6 Optimizations
KERNEL OPTIMIZATIONS
• Remove as many features as possible
I The smaller, the faster to copy from storage to RAM
I Less features means less initializations
• Not always what you want
I What about a full-featured kernel?
• Easy optimizations:
I printk and DEBUGFS
I try CONFIG_CC_OPTIMIZE_FOR_SIZE=y
I SLOB memory allocator
I KALLSYMS
25
![Page 26: Quickboot on i.MX6](https://reader031.fdocuments.net/reader031/viewer/2022012405/55a7a0051a28ab32438b4700/html5/thumbnails/26.jpg)
Quickboot on i.MX6 Optimizations
KERNEL OPTIMIZATIONS
• Stripping a lot of features from is not always possible
• Use modules!
I Load them when your critical application is ready
I Not always possible to compile as module (example:
networking)
• Kernel compression
I None
I Gzip
I LZO
26
![Page 27: Quickboot on i.MX6](https://reader031.fdocuments.net/reader031/viewer/2022012405/55a7a0051a28ab32438b4700/html5/thumbnails/27.jpg)
Quickboot on i.MX6 Optimizations
KERNEL OPTIMIZATIONS
Use of deferred_initcalls
• Kernel stills grows
• Need to patch kernel
I see http://elinux.org/Deferred_Initcall
• Need to modify drivers
I deferred_module_init
• Will execute some init only when asked for (user-space)
I cat /proc/deferred_initcalls
27
![Page 28: Quickboot on i.MX6](https://reader031.fdocuments.net/reader031/viewer/2022012405/55a7a0051a28ab32438b4700/html5/thumbnails/28.jpg)
Quickboot on i.MX6 Optimizations
SMP
• SMP is quite slow to initialize
• UP systems may be faster to boot
• Hotplug the other cores afterwards
I /sys/devices/system/cpu/cpuX/online
28
![Page 29: Quickboot on i.MX6](https://reader031.fdocuments.net/reader031/viewer/2022012405/55a7a0051a28ab32438b4700/html5/thumbnails/29.jpg)
Quickboot on i.MX6 Optimizations
ROOTFS
• Multiple challenges when building your rootfs
I May not be able to optimize the customer’s application
I Even worse, you may not have the sources (blobs)
I Sometimes not possible to reduce the size of your
rootfs
29
![Page 30: Quickboot on i.MX6](https://reader031.fdocuments.net/reader031/viewer/2022012405/55a7a0051a28ab32438b4700/html5/thumbnails/30.jpg)
Quickboot on i.MX6 Optimizations
ROOTFS
• Use an initramfs, but use it right!
• For critical tasks only
• Use of uClibc reduces the size
• Use of mklibs to further strip the libs
• Then switch_root or pivot_root to the final rootfs
30
![Page 31: Quickboot on i.MX6](https://reader031.fdocuments.net/reader031/viewer/2022012405/55a7a0051a28ab32438b4700/html5/thumbnails/31.jpg)
Solutions
![Page 32: Quickboot on i.MX6](https://reader031.fdocuments.net/reader031/viewer/2022012405/55a7a0051a28ab32438b4700/html5/thumbnails/32.jpg)
Quickboot on i.MX6 Solutions
SOLUTIONS
• Boot from SDcard
• Custom bootloader
• Stripped down kernel
• Start a custom init:
I launches critical application (CAN daemon)
I calls deferred_initcalls
I switch_root to the final rootfs and exec the final init
32
![Page 33: Quickboot on i.MX6](https://reader031.fdocuments.net/reader031/viewer/2022012405/55a7a0051a28ab32438b4700/html5/thumbnails/33.jpg)
Quickboot on i.MX6 Solutions
SOLUTIONS
• Boot from SDcard
• Custom bootloader
• Stripped down kernel
• Start a custom init that launches the OpenGL application
• Rootfs has been stripped using mklibs
• Final image (bootloader + kernel + rootfs): 5.2MB
I 3MB for HW blobs libraries
I No compression
33
![Page 34: Quickboot on i.MX6](https://reader031.fdocuments.net/reader031/viewer/2022012405/55a7a0051a28ab32438b4700/html5/thumbnails/34.jpg)
Quickboot on i.MX6 Solutions
RESULTS
• CAN messages ready for transfer in about 360ms
• OpenGL application is started in 720ms from power on
590ms from reset
34
![Page 35: Quickboot on i.MX6](https://reader031.fdocuments.net/reader031/viewer/2022012405/55a7a0051a28ab32438b4700/html5/thumbnails/35.jpg)
Quickboot on i.MX6 Solutions
NEXT STEPS
• Use of DMA to load the image
• Parallel inits
• Provide a more generic solution
35
![Page 36: Quickboot on i.MX6](https://reader031.fdocuments.net/reader031/viewer/2022012405/55a7a0051a28ab32438b4700/html5/thumbnails/36.jpg)
Demonstrations
![Page 37: Quickboot on i.MX6](https://reader031.fdocuments.net/reader031/viewer/2022012405/55a7a0051a28ab32438b4700/html5/thumbnails/37.jpg)
Quickboot on i.MX6 Demonstrations
HARDWARE SELECTION
• i.MX6Q Sabre Smart Device
• Kernel 3.0.35 release v4.1.0
• 10" LVDS display
37
![Page 38: Quickboot on i.MX6](https://reader031.fdocuments.net/reader031/viewer/2022012405/55a7a0051a28ab32438b4700/html5/thumbnails/38.jpg)
Quickboot on i.MX6 Demonstrations
SOURCE CODE
• Code for the custom bootloader:
https://github.com/alexandrebelloni/whoosh
• Code for U-Boot SPL: coming soon...
• Main inspiration was http://www.elinux.org/Boot_Time but it
needs some updates
38
![Page 39: Quickboot on i.MX6](https://reader031.fdocuments.net/reader031/viewer/2022012405/55a7a0051a28ab32438b4700/html5/thumbnails/39.jpg)
Conclusion
![Page 40: Quickboot on i.MX6](https://reader031.fdocuments.net/reader031/viewer/2022012405/55a7a0051a28ab32438b4700/html5/thumbnails/40.jpg)
Quickboot on i.MX6 Conclusion
CONCLUSION
• No one-size-fits-all solution
• Highly depends on constraints
• Generic solution progress
40
![Page 41: Quickboot on i.MX6](https://reader031.fdocuments.net/reader031/viewer/2022012405/55a7a0051a28ab32438b4700/html5/thumbnails/41.jpg)
Quickboot on i.MX6 Conclusion
QUESTIONS?
41
![Page 42: Quickboot on i.MX6](https://reader031.fdocuments.net/reader031/viewer/2022012405/55a7a0051a28ab32438b4700/html5/thumbnails/42.jpg)
Quickboot on i.MX6 Conclusion
REFERENCES
• elinux.org: http://www.elinux.org/
• Free Electrons' training: http://www.free-electrons.com/
42