Ramya Ravichandran, Prabhuraj Tavag (Pathpartner Technology Pvt Ltd)
Embedded systems are fast becoming part of day to day life for comfort, convenience, entertainment, health care and security. With most of the pros like the increased use of smartphones, decreased hardware chip set cost, ease of use and availability of free and open source OS like Linux has enabled the use of embedded systems in multitudes.
Be it phones, automobiles, home appliances and consumer targeted drones everything is getting “smart” and connected.
One common and most crucial requirement for any device based on Linux is to boot as quickly as possible. For many of the applications like automobiles and health care devices it becomes very critical for a device to boot fast and resume few end user services.
At Pathpartner, we have invested significant amount of efforts and time to anlalyse and provide optimum boot time solutions catering different segments on multiple platforms.
In the modern world, booting a device quickly is very important for any system ,be it a consumer appliance /automotive infotainment systems or the upcoming home appliance like camera-drones.
LINUX DEVICE BOOT SEQUENCE:
Typically, a linux device boots in three phases. At power on, a basic hardware specific code loads from ROM, executes few instructions, initializes peripherals needed to run the bootloader.
Bootloader will do a basic initialization of peripherals required to load the kernel into the memory. The kernel takes control, once it gets loaded to RAM from secondary memory storage. After kernel, device drivers are loaded and initialized with the devices as per sponsor requirements/applications. The kernel then initializes the file system, runs the init scripts and finally starts the user interactive layer.
Let us look into three major components of boot sequence :
Bootloader is a program that loads the operating system to memory. The primary
services provided by a bootloader are initializing peripherals and loading the kernel to memory.
Typical boot loader in Linux based systems is Das U-Boot.
There are many methods and techniques to optimize various parts of u-boot, interms of code, size and load time from secondary storage like flash.
The operating system after performing basic initializations and loads the device drivers included in the kernel.
The Linux kernel is a monolithic kernel, supporting true preemptive multitasking (both in user mode and in kernel mode), virtual memory, shared libraries, demand loading, shared copy-on-write executables, memory management, the Internet protocol suite, and threading.
The methods to optimize the linux kernel include configuring the kernel for the target end user applications, removing unwanted driver initializations, reducing the kernel size, deferring and loading the drivers at later time.
File system and Applications
The root file system when mounted, executes a set of init scripts which are part of it and are run by the init process. The scripts executed are generic and device specific initialization is also performed here. Applications are started towards the end of init scripts.
We can optimize by removing unused/non executed legacy scripts/processes and optimizing time dependent services, rearranging the scripts init sequence and by optimizing application for quick loading.
HARDWARE REFERENCE PLATFORMS:
We have extensively worked on various platforms for boot time optimization. For reference we have considered following platforms :
- Freescale i.MX 6 quad core – automotive infotainment
- Texas instruments Da vinci media platform- consumer application
- Sigma Designs SX series – Home entertainment
METHODS AND TECHNIQUES
Kernel Features related to performance that are removed for improving boot-time optimisation in SX configuration file:
1. HIGH_RES_TIMERS - High Resolution Timer Support asks if high resolution timer support can be enabled
2. BSD_PROCESS_ACT - BSD Process Accounting is kernel feature logs a variety of information for each process that closes.
3. DEBUG_PERF_USE_VMALLOC - Debug: use vmalloc to back perf mmap() buffers ().
4. CONFIG_OPROFILE, CONFIG_HAVE_OPROFILE - Profiling support
5. CONFIG_HAVE_KPROBES - Kernel probe
6. CONFIG_HAVE_DMA_API_DEBUG - Debug support for DMA API
7. CONFIG_CFG80211_REG_DEBUG - Debug support for wireless
8. CONFIG_LIB80211_DEBUG - Debug support for wireless library.
9. CONFIG_DEBUG_KERNEL - Debug kernel
10.CONFIG_KALLSYMS - Kernel symbols
Features added for optimisation:
- CC_OPTIMIZE_FOR_SIZE - Optimize for size
- SCHED_MC - Multicore schedule
2. Changing the device driver load sequence:
Loading the modules in certain priority does optimise boot time .It heavily depends upon the usecase.
Generally, Consumer applications have the following priority :
- Power management
- Inter communication module(Synchronisation)
- Bus related devices
- Network Connectivity
3. Invoking quiet mode
Disabling the console/logs would provide efficient decrease in boot time for production .
4. U-Boot size reduction
For automotive applications :
- Use Systemd
- Proper selection of filesystem
- Increasing Throughput of storage drivers,.
- Careful selection of peripherals
- U-Boot optimisation
BOOT TIME OPTIMISATION RESULTS :
In TI Platform: Minimal configs without usb/wifi/BT - DM36x (450Mhz single core cpu, 340MHz DDR, u boot ver.2011, kernel 2.6.37+)
- U-boot optimised to 400ms
- Kernel loading optimised to 900ms
- File systems mounting and loading apps to 2.4 seconds
In iMX 6 dual core - Tizen (Automotive infotainment reference platform) (1GHz dual core, Tizen 2.0, Genivi compliance 1.0, kernel 3.0.35, U-boot ver. 2012)
- U-boot optimised to 300ms
- Kernel loading optimised to 1 second
- File systems mounting and loading apps + display - 3 seconds
In SX series – Consumer electronics Applications (Kernel 3.10, U-boot ver. 2012)
- About 20% of boot time optimisation via appropriate kernel features selection and removal
- About 10% improvement using change of sequence in module loading.
- About 20% improvement by identification of platform specific issues.
CHARTS AND GRAPHS
Figure 1: iMX platform – Boot time optimisation chart
Figure 2:Davinci platform- Boot time optimisation
The feature has a high scope of future considering any embedded system. As Linux kernel evolves, performance of the system improves with boot time optimization feature.
It is possible to reduce the boot time based upon the target applications and customer's requirements. Further reduction in boot time is also possible on the above mentioned hardware platforms
If you wish to download a copy of this white paper, click here