Optimizing Linux Boot Time

Similar documents
Hands-on with the Sitara Linux SDK

U-Boot and Linux Kernel Debug using CCSv5

Introduction to Linux Init Scripts

Update on boot time reduction techniques

The Right Approach to Minimal Boot Times

Ottimizzare i tempi di boot di Linux. Andrea Righi -

Labs instructions for Enabling BeagleBone with TI SDK 5.x

Track Two Building an Internet Radio with the TI Sitara AM3517 using LinuxLink

Linux FastBoot. Reducing Embedded Linux Boot Times. Embedded World Conference 2012

Track Two Building an Internet Radio with the TI Sitara AM3517 using LinuxLink

A pragmatic guide to boot-time optimization

Update on boot time reduction techniques, with figures

Pengwyn Documentation

Track One Building a connected home automation device with the Digi ConnectCore Wi-i.MX51 using LinuxLink

DaVinci System Optimization

Track Three Building a Rich UI Based Dual Display Video Player with the Freescale i.mx53 using LinuxLink

D1Y - Embedded Linux with Yocto

Track Three Building a Rich UI Based Dual Display Video Player with the Freescale i.mx53 using LinuxLink

D1S - Embedded Linux with Ac6 System Workbench

1. Conventions in this tutorial Introduction Check and change configuration settings as needed Start Digi ESP...

U-Boot & Linux Kernel Board Port

User s Manual for the Boundary Devices Nitrogen R board

The Linux IPL Procedure

Achieve Fastest System Startup Sequences.

Boot time Optimization of Automotive Grade Linux. Shilu SL & Renjith G 14-Jul-2016

Use U-Boot. U-Boot Main Commands. U-Boot script capability

U-Boot Falcon Mode. Minimizing boot times using U-Boot "Falcon" mode. Stefano Babic / Wolfgang Denk. July 2012

Mentor Embedded Solutions

RakunLS1, Qseven SBC module with LS1021A

using the Texas Instruments Zoom

Linux. For BCT RE2G2. User Guide. Document Reference: BCTRE2G2 Linux User Guide. Document Issue: Associated SDK release: 1.

Kernel Internals. Course Duration: 5 days. Pre-Requisites : Course Objective: Course Outline

LTIB for i.mx28, a step-by-step guide

D1 - Embedded Linux. Building and installing an embedded and real-time Linux platform. Objectives. Course environment.

CompTIA Linux+/LPIC-1 COPYRIGHTED MATERIAL

DNP/2110 Linux Starter Kit: First Steps

Kernel Boot-Time Optimization

phycore -XScale/PXA270 Development Kit (KPCM-027) Loading a Linux Image (demo.img)

Renaming/Moving Parameter Files

Developing Environment for Intel Mainstone Board

Development Environment Embedded Linux Primer Ch 1&2

Android System Development Training 4-day session

SparkGate7 Quick startup guide

CST8177 Linux II. Linux Boot Process

Please choose the best answer. More than one answer might be true, but choose the one that is best.

DTK2410 Specification

Architect Userís Guide

Getting Started With Linux on the LPC3250 OEM Board

In this video, I will be covering DM385 IPNC RDK out of box demo-- Here, I'll be showing flashing the uboot using prebuilt binaries available in RDK--

GM8126 U-BOOT. User Guide Rev.: 0.2 Issue Date: May 2011

Oxalis Getting Started

IPL+UBI: Flexible and Reliable with Linux as the Bootloader

Lessons learnt in boot time reduction

PetaLinux SDK User Guide. Getting Started Guide

NS115 System Emulation Based on Cadence Palladium XP

MCAM335x Linux User's Guide

Introduction p. 1 Why Linux? p. 2 Embedded Linux Today p. 3 Open Source and the GPL p. 3 Free Versus Freedom p. 4 Standards and Relevant Bodies p.

LPI Exam LPI Level 1 Exam 101, Junior Level Linux Certification, Part 1 of 2 Version: 6.0 [ Total Questions: 120 ]

Linux development. Embedded Linux Optimization. Marco Stornelli. Created with OpenOffice.org Embedded Linux Optimization

Embest SOC8200 Single Board Computer

Embedded Linux Architecture

EMBEDDED LINUX ON ARM9 Weekend Workshop

Chapter 2 Booting Up and Shutting Down

M-606 Linux ARM9 Single Board Computer User Guide

Advanced Unix System Administration

Raspberry Pi Network Boot

Booting Up and Shutting Down. lctseng / Liang-Chi Tseng

Glomation. Embedded Single Board Computer GESBC-3130S User s Manual

First Steps. esom/sk4 esom/3517 Embedded Linux Starter Kit

Quick Start Guide EX-9686U/A-L(A9) Copyright TOPSCCC Technology CO., LTD. All rights reserved

Lab 3a Using the vi editor

Quick Start Guide SBC21/NSD21/EC 21 SBC21 / EC21 / NSD21. Quick Start Guide. Copyright IC Nexus Corporation. All rights reserved

400AP Application Note Uploading Firmware Images to 400AP NAND Flash Models

Avnet Zynq Mini Module Plus Embedded Design

Yocto Project and OpenEmbedded training 3-day session

SBC8140 Single Board Computer

Certification. System Initialization and Services

Keystone II guide on running IPC examples

Embedded Linux Conference Europe Sascha Hauer

Petitboot - A kexec based bootloader. Geoff Levand - Linux Plumbers Conference 2012 August 29-31, San Diego, CA

LX0-103 Exam Questions Demo CompTIA. Exam Questions LX CompTIA Linux+ [Powered by LPI] 1

CompTIA Exam LX0-103 CompTIA Linux+ [Powered by LPI] Exam 1 Version: 6.0 [ Total Questions: 120 ]

client X11 Linux workstation

HC-3120 Linux-Ready Cortex-A8 Industrial 12 HMI Computing (Hardware) User Guide

Getting Started with BeagleBoard xm

PL-I Assignment Broup B-Ass 5 BIOS & UEFI

ECE 471 Embedded Systems Lecture 16

ECE 471 Embedded Systems Lecture 16

This guide is used as an entry point into the Petalinux tool. This demo shows the following:

User Space Tracing in Small Footprint Devices. (How Low can You Go?)

Linux Operating System Environment Computadors Grau en Ciència i Enginyeria de Dades Q2

Once your USB drive is formatted for the FAT32 file system it can be mounted and tested on the GESBC To do this, use the following command:

Embedded Linux system development training 5-day session

The TinyHPC Cluster. Mukarram Ahmad. Abstract

Embedded Linux Systems

CSE A225 Linux with Beagle xm

First Steps. DNP/SK18 Embedded Linux Starter Kit

Poky Linux & OpenEmbedded based environment

CS333 Project 1 Test Report Your Name Here

UFCETW-20-2 Examination Answer all questions in Section A (60 marks) and 2 questions from Section B (40 marks)

Transcription:

Optimizing Linux Boot Time This session gives an overview of methods for optimizing the boot time of a Linux system LAB: http://processors.wiki.ti.com/index.php/sitara_linux_training July 2012

Pre-work Check List Installed and configured VMWare Player v4 or later Installed Ubuntu 10.04 Installed the latest Sitara Linux SDK and CCSv5 Within the Sitara Linux SDK, ran the setup.sh (to install required host packages) Using a Sitara EVM, followed the QSG to connect ethernet, serial cables, SD card and 5V power Booted the EVM and noticed the Matrix GUI application launcher on the LCD Pulled the ipaddr of your EVM and ran remote Matrix using a web browser Brought the USB to Serial cable you confirmed on your setup (preferable)

Agenda What is Fast Boot? Boot Process Overview Measuring Boot Time Identifying the Boot Steps Profiling U-boot Linux Kernel Optimization Techniques U-boot Linux Kernel File System 4

What is Fast Boot? Fast boot refers to minimizing the boot time of a system. The boot time of the system is the time it takes from the application of power to the system becoming available Available has a lot of different meanings depending on the user expectations. Appearance of the home screen for devices like cell phones An audible tone or LED indicator A Linux prompt Becoming discoverable on the network Having a key peripheral become available The above variances show why the Sitara Linux SDK is generally not fully optimized for boot time. Each user can have a different target and a generic SDK cannot satisfy all user targets There are also many features that make for a good development environment, but which do not make for a fast booting environment 5

Boot Process Overview 6

Measuring Boot Time There are a couple of different options for measuring boot time. You can use a C program that time stamps each line on the serial port. http://processors.wiki.ti.com/index.php/measuring_boot_time Compile with gcc tstamp.c -o tstamp This can also be invoked as cat /dev/<tty DEVICE> tstamp RealTerm for Windows supports time stamping the incoming serial data http://realterm.sourceforge.net/ Support logging in Unix date format Ability to log directly to a file Ability to stop logging after a predefined time No need to switch terminal for interactive session TeraTerm for Windows can now log time as well but does not give elapsed time measurements. 7

Measuring Boot Time - Cont Using the C program approach you will see output like: 18.066 0.093: Thu Jun 28 11:56:00 UTC 2012 INIT: Entering runlevel: 5 18.262 0.175: Starting system message bus: dbus. 18.280 0.018: Starting Hardware abstraction layer hald 19.474 1.194: Starting Dropbear SSH server: dropbear. 19.499 0.025: Starting telnet daemon. 19.538 0.039: Starting network benchmark server: netserver. 19.569 0.031: Starting syslogd/klogd: done 19.629 0.060: Starting thttpd. 19.731 0.102: Starting PVR 20.158 0.427: Starting Lighttpd Web Server: lighttpd. 20.176 0.018: 2012-06-28 11:56:02: (log.c.166) server started In the above output you can see that starting the Dropbear SSH server takes 1.194 seconds. If you do not need SSH you can save 1.194 seconds by disabling Dropbear Disabling Dropbear is as simple as removing the S10dropbear init script from the /etc/rc5.d directory 8

Identifying the Boot Steps One of the first things to help in optimizing boot time is to be able to recognize the markers indicating where a new part of the boot process starts SPL The first newline character received on the serial console marks the start of SPL U-boot The banner containing the U-boot version indicates the start of u-boot U-Boot 2011.09 (Jun 28 2012-11:20:36) Linux Kernel First line after the below line indicates the start of the Linux kernel Uncompressing Linux done, booting the kernel File System The below line indicates the transition to the file system Init process INIT: version 2.86 booting 9

Profiling the Boot Loaders There is no direct profiling support in the boot loaders, but the serial print times can still be very useful For example, when booting the kernel image you will see output like: 5.335 0.010: ## Booting kernel from Legacy Image at 80007fc0... 5.339 0.004: Image Name: Arago/3.2.0-psp04.06.00.08.sdk/a 5.344 0.005: Image Type: ARM Linux Kernel Image (uncompressed) 5.348 0.004: Data Size: 3164688 Bytes = 3 MiB 5.350 0.002: Load Address: 80008000 5.352 0.002: Entry Point: 80008000 6.273 0.921: Verifying Checksum... OK 6.276 0.003: XIP Kernel Image... OK 6.310 0.034: OK Notice that almost a second is spent verifying the kernel image checksum. If your system doesn t do anything about a bad image, why spend time verifying it? This verification can be disabled by setting the verify u-boot parameter to n at the u-boot command prompt u-boot# setenv verify n 10

Profiling the Linux Kernel One of the simplest ways to profile the Linux kernel is to configure CONFIG_PRINTK_TIME for the Linux kernel. On most recent kernels this is enabled by default. This adds the time since the kernel was booted in [ ] s before each line [ 2.029785] mmc1: card claims to support voltages below the defined range. T. [ 2.048583] mmc1: queuing unknown CIS tuple 0x91 (3 bytes) [ 2.055053] mmc1: new SDIO card at address 0001 [ 3.986724] PHY: 0:00 - Link is Up - 100/Full [ 4.015808] Sending DHCP requests., OK [ 4.036254] IP-Config: Got DHCP answer from 0.0.0.0, my address is 128.247.10 [ 4.044586] IP-Config: Complete: [ 4.047973] device=eth0, addr=128.247.105.20, mask=255.255.254.0, gw=12, [ 4.056182] host=128.247.105.20, domain=am.dhcp.ti.com, nis-domain=(non, [ 4.063781] bootserver=0.0.0.0, rootserver=0.0.0.0, rootpath= In The above output we can see that it takes almost 2 seconds to get the network Phy Link up and obtain a DHCP IP address. Depending on network speed this could be longer. In the case where there is no DHCP server this can take minutes to timeout. Setting ip=off in the bootargs will bypass kernel network configuration while still allowing you to configure the network in user space. setenv ip_method off 11

Profiling the Linux Kernel - Cont Instrument kernel initialization. This will help you find which static drivers in the kernel are taking the most time to initialize Add initcall_debug to the bootargs in u-boot. With recent u-boots this can usually be done using: setenv optargs initcall_debug saveenv When the Linux system is booted you can view these initcall lines using dmesg grep initcall [ xxxxx] initcall <init function> [<module>] returned 0 after <time> usecs These lines can be sorted using the commands below to help find the modules with the largest init times If CONFIG_PRINTK_TIME is enabled dmesg grep initcall sort -k8 -n If CONFIG_PRINTK_TIME is not enabled dmesg grep initcall sort -k6 -n It is possible to graphically view these initcall times using the bootgraph script in the Linux kernel sources. This requires CONFIG_PRINTK_TIME to be enabled cat <bootlog> perl <kernel source dir>/scripts/bootgraph.pl > boot.svg Additionaly you can use other tools to help you analyze the Linux kernel such as: Linux Trace Toolkit (LTTng) Timing for certain kernel and process events Oprofile System wide profiler Bootchart Visualizes boot process 12

Areas of Optimization Optimizations generally fall into two areas Size Reduce the size of binaries Remove features not required to reduce component size Speed Optimize for target processor Neon optimizations Use faster boot media NOR/NAND vs. MMC/USB Reduce the number tasks leading to boot Do not check MMC if booting from NAND Do not initialize network if booting from MMC Reduce initialization operations Do not bring up network during boot if not required Do not start an SSH server on a device with no network 13

U-boot Optimization Techniques Reduce environment size so that less data is read into memory CONFIG_ENV_SIZE Remove Unnecessary Console Print Statements In board config file add #define CONFIG_SILENT_CONSOLE 1 In u-boot environment do setenv silent 1 Set bootdelay to 0 Disable un-used peripherals such as USB/MMC/Ethernet/UART Modify the config file for your device in <u-boot sources>/include/configs. i.e am335x_evm.h Avoid long help text for the u-boot commands to save space #undef CONFIG_SYS_LONGHELP Use simple parser - instead of hush #undef CONFIG_SYS_HUSH_PARSER If no USB/NAND/MMC/SPI/NOR(FLASH) #undef CONFIG_USB_* #undef CONFIG_NAND #undef CONFIG_MMC #undef CONFIG_SPI #undef CONFIG_FLASH_* 14

U-boot Optimization Techniques - Cont Remove -g option from the compiler Other Ideas Disable UART boot Remove Image Verification (covered before) Perhaps try uncompressed image Verify that kernel image is read to the proper memory location 15

Linux Optimization Techniques Remove un-necessary drivers/features from kernel configuration Reduces driver initialization time Reduces kernel size Build non-fast boot drivers as modules Load them after the system is booted when there is more time Disable console output using quiet Displaying messages on console takes time Setting the quiet option in the bootargs disables display on console but messages are still logged u-boot# setenv optargs quiet Remove un-used consoles. These take time to initialize. These can be removed in the /etc/inittab file on the target file system It is possible to completely disable printk but this will eliminate a lot of debug information 16

Linux Optimization Techniques - Cont Defer module init calls It is possibly to defer module init calls without having to build the modules dynamically. This requires modifying the kernel For modules that are not needed at boot replace the module_init() function calls to deferred_module_init() Once the system booted the deferred calls can be executed by doing: echo 1 > /proc/deferred_initcalls Additional details at http://elinux.org/deferred_initcalls Remove the -g option from the compile Disable kernel debugging features Kernel debugging Debug Filesystem (NOTE: Some features may need this) Tracers Remove any instrumentation you may have added such as initcall instrumentation. 17

Linux Optimization Techniques - Cont Pre-set loops per jiffy You just need to measure this once Find lpj value in kernel boot messages Calibrating delay loop 718.02 BogoMIPS (lpj=3590144) Add the lpj=3590144 to the bootargs Use Static IP addressing where possible If you don t need networking then disable it altogether If you want networking capability but not NFS then be sure to set ip=off on the kernel command line. Set memory limit with mem= option Use only as much memory as needed to avoid DDR initialization time 18

File System Optimization Techniques Use minimal BusyBox file system Reduces forking in shell Build static of possible to reduce the need for un-used code in the file system Be careful because static linking can also cause your file system size to increase dramatically. Avoid using ramdisk or initramfs Must load entire ramdisk from flash into DDR May only need a small part at boot time i.e. may not need all of glibc but entire library will be loaded into DDR using ramdisk or initramfs Buffer cache can keep frequently used files in memory 19

File System Optimization Techniques - Cont Pre-linking Avoid run time linking penalty Drawback: If library changes app must be rebuilt. Use tmpfs file system No need to initialize file system for non-persistent data Use split file systems Have multiple file system partitions Put only the files needed for boot in the root file system partition Put other files in second file system which can be mounted after boot 20

File System Optimization Techniques - Cont Strip executables Removes un-needed symbols and reduces size Avoid udev for static systems If the system doesn t change then make device nodes manually rather than udev creating them Hotplug-daemon can still run later to add additional devices that are plugged in Disable init scripts that start unneeded services Use GNU_HASH to make dynamic linking faster (This is the default for the SDK) Use systemd for parallel initialization 21

Credits/Sources http://processors.wiki.ti.com/index.php/optimize_linux_boot_time by Sanjeev Premi http://elinux.org/boot_time 22