Bootloader and Linux Kernel 於嵌入式系統發展與重要性

Bootloader and Linux Kernel 於嵌入式系統發展與重要性

Android多核心嵌入式多媒體系統設計與實作 Bootloader and Linux Kernel 於嵌入式系統發展與重要性 賴槿峰 (Chin-Feng Lai) Assistant Professor, institute of CSIE, National Ilan University Sep 22th 2012 © 2012 MMN Lab. All Rights Reserved 2012 資訊軟體技術人才培訓 Outline • Bootloader • Bootloader Introduction • Bootloader overview • Das U-Boot • OMAP boot sequence • Kernel • Kernel Introduction • Kernel architecture overview • Kernel boot step • Kernel configure 2 • Bootloader • Kernel • Lab 3 Bootloader Introduction • Role of android bootloader File System Linux Kernel Hardware Bootloader 4 Bootloader Introduction • What is Bootloader • The first software program that runs when a computer starts • Derived from the phrase “to pull oneself up by one's bootstraps 5 Bootloader Introduction • Role of a Bootloader • Initialize hardware for programs • Read/Write non-volatile storage devices • Provide interfaces for loading/running programs • Memory dumping/modifying • Bootloader Challenges • DRAM Controller • Flash and RAM • Image Complexity • Execution Context 6 Bootloader Introduction • Bootloader Challenges - DRAM Controller • Require detailed knowledge of DRAM architecture, controller, chips, and overall hardware design. • Bootloader needs to enable the memory subsystem at first to provide resource for execution environment. • Bootloader Challenges - Flash and RAM • Bootloader is stored in nonvolatile storage but is usually loaded into RAM for faster execution. • Bootloader must create its own operational context and move itself. 7 Bootloader Introduction • Bootloader Challenges - Image Complexity • Complete control over how the image is constructed and linked. • Need to organize the startup code for specific processor’s boot sequence. • Linker for constructing a binary executable image. 8 Bootloader Overview 9 Bootloader Overview - bios • Boot firmware(able to be updated) • Identify, test, and initialize system devices • Other complex functions • Booting device • System clock • ACPI (Advanced Configuration and Power Interface) • Tools for overclocking • Hardware configuration • …etc 10 Bootloader Overview – GUN GRUB • GRand Unified Bootloader • Feature • Provides the choice to boot one of multiple OS • Download OS images from a network • Support diskless systems\ • Provides a simple, bash-like, command line interface 11 Bootloader Overview – Das U-boot • Open source universal bootloader • Support many processor architectures • ARM . MIPS . X86 • http://sourceforge.net/projects/u-boot • Easy to port to new architectures • Used for interacting with users and updating images and leading the kernel 12 Das U-boot • Das U-Boot source tree . |-- api |-- doc |-- lib_mips |-- net |-- api_examples |-- drivers |-- lib_nios |-- nios2_config.mk |-- arm_config.mk |-- examples |-- lib_nios2 |-- nios_config.mk |-- avr32_config.mk |-- fs |-- lib_ppc |-- onenand_ipl |-- blackfin_config.mk |-- i386_config.mk |-- lib_sh |-- post |-- board |-- include |-- lib_sparc |-- ppc_config.mk |-- built |-- lib_arm |-- m68k_config.mk |-- README |-- CHANGELOG |-- lib_avr32 |-- MAINTAINERS |-- rules.mk |-- common |-- lib_blackfin |-- MAKEALL |-- sh_config.mk |-- config.mk |-- libfdt |-- Makefile |-- sparc_config.mk |-- COPYING |-- lib_generic |-- microblaze_config.mk `-- tools |-- cpu |-- lib_i386 |-- mips_config.mk |-- CREDITS |-- lib_m68k |-- mkconfig |-- disk |-- lib_microblaze |-- nand_spl 13 Das U-boot • Das U-Boot source tree Directory Description api U-Boot machine/arch independent API for external applications board Board dependent files/directories common Misc architecture independent functions cpu CPU specific files Disk Code for disk drive partition handling Doc Basic documentation files drivers Device drivers for common peripherals include Header files (.h) lib_xxx Files generic to the XXX architecture net Networking support (bootp,tftp, rarp, nfs, and so on) nand_spl Support for NAND Flash boot with stage 0 boot loader 14 Das U-boot • Das U-boot Porting Flow Get the U-boot source code Configure u-boot by modifying the <boardname>.h header toolchain for arm file Modify Makefile Define a physical memory map u-boot-1.X-XXX.bin Define a memory link map with the following sections load file (.bin ) , Execute 15 Das U-boot • Das U-boot Porting Flow 1. Get the source from Get the U-boot source code • ftp://ftp.denx.de/pub/u-boot/ 2. Get the toolchain from • http://www.codesourcery.com/ toolchain for arm 3. Uncompress toolchain and modify $PATH • Host $ tar -xvf arm-none-linux-guneabi.src.tar • Host $ vim ~/.bashrc ( add export PATH=$PATH:ToolPATH) • Host $ source ~/.bashrc 16 Das U-boot – Porting flow • The include directory: • Configs/<boardname>.h • includes hardware configuration for memory map and peripherals. • <core>.h for example arm926ejs.hh • contains the processor specific , register definitions. 17 Das U-boot – Porting flow • The cpu directory: • <core>/cpu.c • This file contains the cpu specific code. • <core>/interrupt.c • contains the function related to interrupt and timer • <core>/Start.S • contains startup code for ARM cpu core. <core>/cpu.c 18 Das U-boot – Porting flow <core>/interrupt.c <core>/Start.s 19 Das U-boot – Porting flow • The lib_<arch> directory: • board.c • memory map initialization , u-boot peripheral initialization. • div0.c • contains division-by zero exception handler 20 Das U-boot – Porting flow • The board directory: • < boardname >/ < boardname >.c • contains functions like board initialization routine, Timer, Serial Port, NAND flash initialization etc 21 Das U-boot – Porting flow • Modify the top level makefile Modify Makefile • to specify the new configuration. <boardname>_config : unconfig @./mkconfig $(@:_config=) <architecture> <core> <boardname> • Host $ make distclean u-boot-1.X-XXX.bin • Host $ make <board_name>_config • Host $ make 22 Das U-boot Command Command Function boot boot application image from memory bootp boot image via network using BootP/TFTP protocol bootd boot default, i.e., run 'bootcmd' go start application at address 'addr' help (or ?) print online help loadb load binary file over serial line (kermit mode) printenv print environment variable run run commands in an environment variable saveenv save environment variables to persistent storage setenv set environment variables tftpboot boot image via network using TFTP protocol and env variables ipaddr and serverip 23 OMAP Boot Sequence • Comparison of Personal Computer and Embedded system BIOS MBR Bootloader Kernel Rootfs User area Personal Computer Bootloader Kernel Rootfs User area Embedded system 24 OMAP Boot Sequence • Boot loader initial is divided into two stage • Stage1 • Initial hardware • Prepare the RAM space for Stage2 • Initial stack • Copy the bootloader Stage2 to RAM • Set the PC to the entry of stage2 • Stage2 • Enhanced initialization. • Copy Kernel image to RAM. • Give the execution permission to the kernel. 25 OMAP Boot Sequence • Bootloader of OMAP3530 contain X-loader and U-boot X-loader U-boot Kernel Rootfs User area Bootloader 1 Run Bootloader progress on the SD card 2 Run Bootloader progress on the Nand Flash 26 OMAP Boot Sequence – x-loader • a first level bootstrap program. • the ROM will copy the x-loader to internal RAM . • initialize the CPU • copy u-boot into the memory • give the control power to u-boot • a tiny first stage minimal bootloader. 27 OMAP Boot Sequence – x-loader(cont.) • The internal ROM Code will attempt to boot. Rom code loader 28 OMAP Boot Sequence – x-loader(cont.) • SD Card Boot • ROM looks for an SD Card on the first MMC controller. • The ROM then looks for the first FAT32 partition within the partition table. • Scanned for a signed file called “MLO”. • It is transfered into the internal SRAM and control is passed to it. • Nand Boot • The ROM attempts to load the first sector of Nand. • If the sector is bad, corrupt, or blank, the ROM will try the next sector (up to 4) . • The ROM transfers the contents to SRAM and transfers control to it. 29 OMAP Boot Sequence – U-boot • SD Card Boot • Looks for a first FAT32 partition on MMC. • Scans root dir for a file named "u-boot.bin". stage 2 for SD card 30 OMAP Boot Sequence – U-boot • NAND Boot • u-boot to be loaded at the 5th sector. • Transfers the image into main memory. stage 2 for NAND Flash 31 OMAP Boot Sequence – Boot Device Priority • Devkit8000 • Hold the BOOT_KEY push button, then apply power Boot priority Device 0 NAND FLASH 1 SD Card Boot key button 32 OMAP Boot Sequence – memory map Omap3530 memory map 33 • Bootloader • Kernel • Lab 34 Kernel Introduction • Role of android kernel File System Linux Kernel Hardware Bootloader 35 Kernel Introduction • What is Kernel • The "core" of any computer system. • The "software" which allows users to share computer resources. • The kernel can be thought as the main software of the Operating System • which may also include graphics management. 36 Kernel Introduction • Role of a Kernel • Provides a consistent interface to managed devices. • Protects the hardware from users of the computer. • Protects important software from users. Protect Ring 37 Kernel Introduction • Kernel Mode & User Mode • To avoid having applications that constantly crashed • Designed with 2 different operative modes: • Kernel Mode • User Mode User Implementation Mode Abstraction Detail Kernel Mode 38 Kernel Introduction • User mode • Access user-mode memory • Illegal attempts will result in • faults/exceptions • Kernel mode • I/O instructions • Access both user- and kernel-mode • memory • An instruction to change to user mode 39 Kernel Introduction • How to call kernel mode

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    78 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us