Kexec - Ready For Embedded Linux

1y ago
9 Views
2 Downloads
507.57 KB
40 Pages
Last View : 1m ago
Last Download : 3m ago
Upload by : Noelle Grant
Transcription

Kexec Ready for Embedded Linux Magnus Damm magnus.damm@gmail.com Renesas Electronics Corp. April 2010 Magnus Damm (magnus.damm@gmail.com) Kexec April 2010 1 / 40

Outline Bootloader Basics Overview & Use Cases Inside the Bootloader Four Examples Kexec-based Bootloaders Introduction & Motivation Hardware Setup Code Kernel Configuration & Tuning Optimizing User Space Real World Examples SH-Based Boards ARM-Based Boards Magnus Damm (magnus.damm@gmail.com) Kexec April 2010 2 / 40

Bootloader Basics Outline Bootloader Basics Overview & Use Cases Inside the Bootloader Four Examples Kexec-based Bootloaders Introduction & Motivation Hardware Setup Code Kernel Configuration & Tuning Optimizing User Space Real World Examples SH-Based Boards ARM-Based Boards Magnus Damm (magnus.damm@gmail.com) Kexec April 2010 3 / 40

Bootloader Basics Overview & Use Cases Outline Bootloader Basics Overview & Use Cases Inside the Bootloader Four Examples Kexec-based Bootloaders Introduction & Motivation Hardware Setup Code Kernel Configuration & Tuning Optimizing User Space Real World Examples SH-Based Boards ARM-Based Boards Magnus Damm (magnus.damm@gmail.com) Kexec April 2010 4 / 40

Bootloader Basics Overview & Use Cases Overview Setup Hardware Load Kernel Start Kernel Magnus Damm (magnus.damm@gmail.com) Kexec April 2010 5 / 40

Bootloader Basics Overview & Use Cases Use Cases Development: I Load Kernel Over Ethernet/USB Standalone: I Load Kernel From NAND/NOR/MMC/USB Magnus Damm (magnus.damm@gmail.com) Kexec April 2010 6 / 40

Bootloader Basics Inside the Bootloader Outline Bootloader Basics Overview & Use Cases Inside the Bootloader Four Examples Kexec-based Bootloaders Introduction & Motivation Hardware Setup Code Kernel Configuration & Tuning Optimizing User Space Real World Examples SH-Based Boards ARM-Based Boards Magnus Damm (magnus.damm@gmail.com) Kexec April 2010 7 / 40

Bootloader Basics Inside the Bootloader Inside the Bootloader Hardware Setup (Assembly C): I Setup CS Memory Windows I Initialize Caches & MMU I Configure Clocks & GPIOs I Setup System RAM I Configure I/O Devices Magnus Damm (magnus.damm@gmail.com) Kexec April 2010 8 / 40

Bootloader Basics Inside the Bootloader Inside the Bootloader Load Kernel (C only): I “Driver Model” I Network Stack / Filesystem I Kernel File Format Parser Start Kernel (C Assembly): I Prepare Kernel Parameters I Execute Kernel Magnus Damm (magnus.damm@gmail.com) Kexec April 2010 9 / 40

Bootloader Basics Four Examples Outline Bootloader Basics Overview & Use Cases Inside the Bootloader Four Examples Kexec-based Bootloaders Introduction & Motivation Hardware Setup Code Kernel Configuration & Tuning Optimizing User Space Real World Examples SH-Based Boards ARM-Based Boards Magnus Damm (magnus.damm@gmail.com) Kexec April 2010 10 / 40

Bootloader Basics Four Examples Example 1: Good Old PC BIOS: I Located in ROM / NOR Flash I Performs Hardware Setup I Loads Bootloader from HDD Bootloader: I Executes from RAM I Loads Kernel from HDD Magnus Damm (magnus.damm@gmail.com) Kexec April 2010 11 / 40

Bootloader Basics Four Examples Example 2: Embedded NOR Flash [SoC RAM NOR Flash I/O] Bootloader: I Located in NOR Flash I Performs Hardware Setup I Loads Kernel from NOR Flash Magnus Damm (magnus.damm@gmail.com) Kexec April 2010 12 / 40

Bootloader Basics Four Examples Example 3: Embedded NOR Flash NAND / MMC [SoC RAM NOR Flash NAND Flash / MMC I/O] Bootloader: I Located in NOR Flash I Performs Hardware Setup I Loads Kernel from NAND Flash / MMC Magnus Damm (magnus.damm@gmail.com) Kexec April 2010 13 / 40

Bootloader Basics Four Examples Example 4: Embedded NAND Flash / MMC [SoC RAM NAND Flash / MMC I/O] Mask ROM: I Located inside SoC I Loads Bootloader from NAND Flash / MMC Bootloader: I Executes from On-chip RAM I Performs Hardware Setup I Loads Kernel from NAND Flash / MMC Magnus Damm (magnus.damm@gmail.com) Kexec April 2010 14 / 40

Kexec-based Bootloaders Outline Bootloader Basics Overview & Use Cases Inside the Bootloader Four Examples Kexec-based Bootloaders Introduction & Motivation Hardware Setup Code Kernel Configuration & Tuning Optimizing User Space Real World Examples SH-Based Boards ARM-Based Boards Magnus Damm (magnus.damm@gmail.com) Kexec April 2010 15 / 40

Kexec-based Bootloaders Introduction & Motivation Outline Bootloader Basics Overview & Use Cases Inside the Bootloader Four Examples Kexec-based Bootloaders Introduction & Motivation Hardware Setup Code Kernel Configuration & Tuning Optimizing User Space Real World Examples SH-Based Boards ARM-Based Boards Magnus Damm (magnus.damm@gmail.com) Kexec April 2010 16 / 40

Kexec-based Bootloaders Introduction & Motivation What is Kexec? “kexec is a system call that implements the ability to shutdown your current kernel, and to start another kernel. It is like a reboot but it is indepedent of the system firmware.” Configuration help text in Linux-2.6.17 Magnus Damm (magnus.damm@gmail.com) Kexec April 2010 17 / 40

Kexec-based Bootloaders Introduction & Motivation What is Kexec? Kexec is a combination of kernel code and user space code: I Linux kernel support available through CONFIG KEXEC. I kexec-tools provides the user space tool kexec. Simple Kexec example to reboot into “zImage”: # kexec -l zImage -append "console ttySC0" # kexec -e Many thanks to: I Eric W. Biederman - Kexec and kexec-tools author. I Simon Horman - kexec-tools maintainer. I Tony Lindgren - Kexec fixes for ARM. Magnus Damm (magnus.damm@gmail.com) Kexec April 2010 18 / 40

Kexec-based Bootloaders Introduction & Motivation So what is a Kexec-based Bootloader? A Kexec-based bootloader is a combination of: I Hardware setup code (not mandatory). I A Linux kernel configured with CONFIG KEXEC y. I User space with kexec-tools. Magnus Damm (magnus.damm@gmail.com) Kexec April 2010 19 / 40

Kexec-based Bootloaders Introduction & Motivation Motivation SH-Mobile board - sh7724-based “kfr2r09” I Handset prototype I USB Gadget-only hardware design I Micro-SD slot I Upstream kernel driver for USB-Gadget I No U-boot port, no U-boot drivers Magnus Damm (magnus.damm@gmail.com) Kexec April 2010 20 / 40

Kexec-based Bootloaders Introduction & Motivation Motivation - U-boot vs the Kernel Question: Add U-boot support or extend the kernel? U-boot and Barebox: I Established I Low barrier of entry I Small The Linux Kernel: I Good hardware support I Release management Magnus Damm (magnus.damm@gmail.com) Kexec April 2010 21 / 40

Kexec-based Bootloaders Hardware Setup Code Outline Bootloader Basics Overview & Use Cases Inside the Bootloader Four Examples Kexec-based Bootloaders Introduction & Motivation Hardware Setup Code Kernel Configuration & Tuning Optimizing User Space Real World Examples SH-Based Boards ARM-Based Boards Magnus Damm (magnus.damm@gmail.com) Kexec April 2010 22 / 40

Kexec-based Bootloaders Hardware Setup Code Hardware Setup Code for SH - Overview “romImage” for SH: I Includes all setup code needed to boot the system I Supported by the boards kfr2r09 and ecovec24 I Use “make romImage” to build image I Burn to the NOR flash at the reset vector I Merged in linux-2.6.31 Magnus Damm (magnus.damm@gmail.com) Kexec April 2010 23 / 40

Kexec-based Bootloaders Hardware Setup Code Hardware Setup Code for SH - Files “romImage” files: I t - debug script I arch/sh/include/mach-xxx/mach/romimage.h - board setup code I arch/sh/boot/romimage/ - romImage wrapper for zImage I arch/sh/boot/compressed/ - standard zImage I arch/sh/configs/ - romImage configurations Magnus Damm (magnus.damm@gmail.com) Kexec April 2010 24 / 40

Kexec-based Bootloaders Kernel Configuration & Tuning Outline Bootloader Basics Overview & Use Cases Inside the Bootloader Four Examples Kexec-based Bootloaders Introduction & Motivation Hardware Setup Code Kernel Configuration & Tuning Optimizing User Space Real World Examples SH-Based Boards ARM-Based Boards Magnus Damm (magnus.damm@gmail.com) Kexec April 2010 25 / 40

Kexec-based Bootloaders Kernel Configuration & Tuning Kernel Configuration & Tuning - Iteration 1 - L-size Start with an unoptimized kernel: I Use the defconfig for your board, compile-in drivers I Compile-in the kernel cmdline using CONFIG CMDLINE OVERWRITE y I Pass “quiet” on the kernel cmdline to silence the kernel I Point out user space with CONFIG INITRAMFS SOURCE I Set CONFIG INITRAMFS COMPRESSION NONE y I Play around with CONFIG KERNEL GZIP/BZIP2/LZMA/LZO Magnus Damm (magnus.damm@gmail.com) Kexec April 2010 26 / 40

Kexec-based Bootloaders Kernel Configuration & Tuning Kernel Configuration & Tuning - Iteration 2 - M-size Base on top of Iteration 1 and. I Tune the kernel configuration for your use case I I Remove unused subsystems, filesystems and drivers Only one timer driver is needed I CONFIG SLOB y, CONFIG TINY RCU y I Remember to keep CONFIG KEXEC y Magnus Damm (magnus.damm@gmail.com) Kexec April 2010 27 / 40

Kexec-based Bootloaders Kernel Configuration & Tuning Kernel Configuration & Tuning - Iteration 3 - S-size Base on top of Iteration 2 and. I I Disable module support Disable even more kernel features (warning!) I CONFIG EMBEDDED, CONFIG BUG, CONFIG PRINTK Magnus Damm (magnus.damm@gmail.com) Kexec April 2010 28 / 40

Kexec-based Bootloaders Optimizing User Space Outline Bootloader Basics Overview & Use Cases Inside the Bootloader Four Examples Kexec-based Bootloaders Introduction & Motivation Hardware Setup Code Kernel Configuration & Tuning Optimizing User Space Real World Examples SH-Based Boards ARM-Based Boards Magnus Damm (magnus.damm@gmail.com) Kexec April 2010 29 / 40

Kexec-based Bootloaders Optimizing User Space Optimizing User Space - Iteration 1 Start with an unoptimized initramfs: I Use an existing cross toolchain (perhaps glibc to keep it simple) I Build static busybox binary using allyesconfig I Build a static kexec binary from kexec-tools I Hack up configuration files and scripts I Combine with the kernel using CONFIG INITRAMFS SOURCE Uncompressed initramfs size: 2.6 MiB ( 300 Apps, sh4) With L-size romImage, compressed with LZMA: 2.9 MiB ( 2s) With L-size romImage, compressed with LZO: 3.7 MiB ( 1.5s) Magnus Damm (magnus.damm@gmail.com) Kexec April 2010 30 / 40

Kexec-based Bootloaders Optimizing User Space Optimizing User Space - Iteration 2 Base on top of Iteration 1 and. I Trim the busybox configuration to save space I Remember to keep udhcpc and tftp if you netboot I For speedup, replace mdev with kernel option CONFIG DEVTMPFS y Uncompressed initramfs size: 1.6 MiB ( 60 Apps, sh4) With M-size romImage, compressed with LZMA: 2.0 MiB ( 1.5s) With M-size romImage, compressed with LZO: 2.6 MiB ( 1s) Magnus Damm (magnus.damm@gmail.com) Kexec April 2010 31 / 40

Kexec-based Bootloaders Optimizing User Space Optimizing User Space - Iteration 3 Base on top of Iteration 2 and. I Disable further busybox applets I Hack busybox and kexec-tools into a single static binary Uncompressed initramfs size: 1 MiB ( 30 Apps, sh4) With S-size romImage, compressed with LZMA: 1.0 MiB ( 1s) With S-size romImage, compressed with LZO: 1.4 MiB ( 0.5s) Magnus Damm (magnus.damm@gmail.com) Kexec April 2010 32 / 40

Kexec-based Bootloaders Optimizing User Space Optimizing User Space Keep on interating. I Switch to a smaller libc I Remove dead code For quicker turn around time, use zImage to test user space Magnus Damm (magnus.damm@gmail.com) Kexec April 2010 33 / 40

Real World Examples Outline Bootloader Basics Overview & Use Cases Inside the Bootloader Four Examples Kexec-based Bootloaders Introduction & Motivation Hardware Setup Code Kernel Configuration & Tuning Optimizing User Space Real World Examples SH-Based Boards ARM-Based Boards Magnus Damm (magnus.damm@gmail.com) Kexec April 2010 34 / 40

Real World Examples SH-Based Boards Outline Bootloader Basics Overview & Use Cases Inside the Bootloader Four Examples Kexec-based Bootloaders Introduction & Motivation Hardware Setup Code Kernel Configuration & Tuning Optimizing User Space Real World Examples SH-Based Boards ARM-Based Boards Magnus Damm (magnus.damm@gmail.com) Kexec April 2010 35 / 40

Real World Examples SH-Based Boards SH-Based Board MS7724 SH-Mobile board “MS7724” aka “Ecovec24”: I romImage burned to reset vector in NOR Flash I Loads kernel over Ethernet using CONFIG SH ETH y I USB Storage support with CONFIG USB R8A66597 HCD y I LCD splash screen using CONFIG FB SH MOBILE LCDC y Magnus Damm (magnus.damm@gmail.com) Kexec April 2010 36 / 40

Real World Examples SH-Based Boards SH-Based Board kfr2r09 SH-Mobile board - sh7724-based “kfr2r09”: I romImage burned to reset vector in NOR Flash I Loads kernel over USB Gadget using CONFIG USB CDC COMPOSITE y I Loads kernel from Micro-SD using CONFIG MFD SH MOBILE SDHI y Magnus Damm (magnus.damm@gmail.com) Kexec April 2010 37 / 40

Real World Examples ARM-Based Boards Outline Bootloader Basics Overview & Use Cases Inside the Bootloader Four Examples Kexec-based Bootloaders Introduction & Motivation Hardware Setup Code Kernel Configuration & Tuning Optimizing User Space Real World Examples SH-Based Boards ARM-Based Boards Magnus Damm (magnus.damm@gmail.com) Kexec April 2010 38 / 40

Real World Examples ARM-Based Boards ARM-Based Boards G3EVM & G4EVM SH-Mobile ARM Boards G3EVM & G4EVM: I U-boot burned to reset vector in NOR Flash I U-boot starts uImage kernel from NOR Flash I uImage has USB Host using CONFIG USB R8A66597 HCD y I uImage supports boot over USB Ethernet adapter Magnus Damm (magnus.damm@gmail.com) Kexec April 2010 39 / 40

Summary Summary I From power-on to shell prompt in about a second. I Unoptimized romImage needs 4 MiB Flash I Optimized romImage needs 1 MiB Flash I Size not an issue with NAND Flash / MMC Boot. Magnus Damm (magnus.damm@gmail.com) Kexec April 2010 40 / 40

Ready for Embedded Linux Magnus Damm magnus.damm@gmail.com Renesas Electronics Corp. April 2010 Magnus Damm (magnus.damm@gmail.com)KexecApril 2010 1 / 40. Outline . I Supported by the boards kfr2r09 and ecovec24 I Use "make romImage" to build image I Burn to the NOR flash at the reset vector I Merged in linux-2.6.31 Magnus Damm (magnus .

Related Documents:

Linux in a Nutshell Linux Network Administrator’s Guide Linux Pocket Guide Linux Security Cookbook Linux Server Hacks Linux Server Security Running Linux SELinux Understanding Linux Network Internals Linux Books Resource Center linux.oreilly.comis a complete catalog of O’Reilly’s books on Linux and Unix and related technologies .

Other Linux resources from O’Reilly Related titles Building Embedded Linux Systems Linux Device Drivers Linux in a Nutshell Linux Pocket Guide Running Linux Understanding Linux Network Internals Understanding the Linux Kernel Linux Books Resource Center linu

Bruksanvisning för bilstereo . Bruksanvisning for bilstereo . Instrukcja obsługi samochodowego odtwarzacza stereo . Operating Instructions for Car Stereo . 610-104 . SV . Bruksanvisning i original

Chapter 1: Getting started with embedded-linux Remarks This section provides an overview of what embedded-linux is, and why a developer might want to use it. It should also mention any large subjects within embedded-linux, and link out to the related topics. Since the Documentation for embedded-linux is new, you may need to create initial .

Perfection PC Perfection PC Inc. Philips Philips Electronics Planar Planar Systems Inc PLEXON Plexon, Inc. Pogo Linux Pogo Linux, Inc. Pogo Linux Altura M2 Pogo Linux, Inc. Pogo Linux Velocity -D50 Pogo Linux, Inc. Pogo Linux Verona 330 Pogo Linux, Inc. Pogo Linux Vor

The Linux BSP release is composed of three packages: documentation, sources and binaries. Package Name Contents linux-socfpga-13.02 -src.bsx Source code (self extracting) linux-socfpga-13.02 -bin.tar.gz Binaries Embedded Linux Getting Started Guide (this doc) Documentation Linux BSP User Manual - 13.02.pdf Linux BSP Release Notes

Thomas Petazzoni I CTO and Embedded Linux engineer at Free Electrons I Embedded Linux development: kernel and driver development, system integration, boot time and power consumption optimization, consulting, etc. I Embedded Linux training, Linux driver development training and Android system development training, with materialsFile Size: 1MB

ASTM E 989-06 (2012), Classification for Determination of Impact Insulation Class (IIC) ASTM E 2235-04 (2012) Standard Test Method for Determination of Decay Rates for Use in Sound Insulation Test Methods: Test Procedure. All testing was conducted in the VT test chambers at Intertek-ATI located in York, Pennsylvania. The microphones were calibrated before conducting the tests. The airborne .