1 / 64

Chapter 4

Chapter 4. Embedded Software Architectures. Professor Ruei-Xi Chen E-mail: sslin@mail.sju.edu.tw Http://www.csie.sju.edu.tw SJU/CSIE. Outline. 4.1 Bootloader 4.2 Embedded Operating System 4.3 Root Filesystem 4.4 Graphic User Interface of Embedded system.

sezja
Download Presentation

Chapter 4

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Chapter 4 Embedded Software Architectures Professor Ruei-Xi Chen E-mail: sslin@mail.sju.edu.tw Http://www.csie.sju.edu.tw SJU/CSIE

  2. Outline 4.1 Bootloader 4.2 Embedded Operating System 4.3 Root Filesystem 4.4 Graphic User Interface of Embedded system

  3. Software Component Images of Embedded Systems • Three Software Component Images • Bootloder image • Kernel image • Root Filesystem image

  4. Pre-fixed instructions Can be Fetched from fixed locations during power up. Ex: Start from 0x00000000 Pre-allocated Solid Devices: FLASH ROM Or EEPROM Typical image map is as shown. Typical Embedded SW Image Maps Bootloader Boot Parameters Kernel Root Filesystem

  5. 4.1 Bootloader 4.1 Bootloader 4.2 Embedded Operating System 4.3 Root Filesystem 4.4 Graphic User Interface of Embedded system

  6. 4.1 What is a Bootloader? • A special small program • that also called a bootstrap loader. • The only job of a boot loader: • To load other software for the operating system to start.

  7. 4.1 The Linux Bootloader • To initialize platform: • Load the Linux kernel • Kernel can be downloaded by using tftp/bootp. • Kernel is accessed from flash if it resides in Flash. • Run the Linux kernel • Setup various initialization parameters: • Command line: root=/dev/nfs …. • Platform ID (stored in r1)

  8. 4.1 Available Bootloaders for ARM Platforms • U-Boot: Universal Bootloader • A firmware for many CPU architectures and boards with full source code under GPL. • http://sourceforge.net/projects/u-boot • RedBoot • A comprehensive debug and bootstrap firmware solution for the development, deployment, and management of embedded devices. • http://www.ecoscentric.com/ecos/redboot.shtml • …

  9. 4.1 Boot Processes

  10. 4.1 Categories of Bootloader Processing • Single-Stage boot loaders • Multi-Stage boot loaders • Capable of offering good functionality and portability • Often used

  11. 4.1 Coding Style of Multi-Stage Bootloaders • A Two-Stage Boot Loader is employed. • Coding Styles in Stage 1 • Mostly coding with assembly languages • For the efficiency purpose • Coding Styles in Stage 2 • Coding in C languages • Well readability and portability • For ease of complex function realization

  12. 4.1 Mission of Two-stage Bootloaders • Stage 1: • Hardware Initializing & Load Preparing • During Power up or System Reset • Assembly language • Stage 2: • Load Kernel Image • Launch Kernel Boot

  13. 4.1 Hardware Initialization (Stage 1) • Detect the machine type • Initialization • Mask(阻擋) all Interrupt request • Set Processor’s clock rate • Memory & Register Initialization • Initialize required peripherals • Initialize the Interrupt controller and Install Interrupt handler. • Initialize the indicators (LED etc.) • Disable Data and Instruction Cache Memory.

  14. 4.1 Load Preparing (Stage 1) • Prepare RAM space for Stage 2 • Setup stack • The stack space had better be times of the memory page (4 KB) • Set stack pointer: sp = stage2_end - 4 • Jump to the Entry-point of Stage 2

  15. 4.1 Memory Map 0x0000,0000 Stage1, 1K (Image of boorloader) 0x0000,0400(1KB) Stage2, 64K (Image of boorloader) 0x0001,0000(64KB) Flash (Blank) Kernel Image (Blank) ramdisk stage2_start RAM Stage1 allocated RAM sapce for Stage 2 Stack_Pointer: stage2_end - 4 stage2_end

  16. 4.1 Initialization (Stage 2) • Initial • Initialize the Stage 2 required hardware • At least initialize one serial port • Initialize Timers • Examine memory map • Assure the mapping address is accessible • Clear memory • Loader Enabled • Loader: a section code of Boot image

  17. 4.1 Load Kernel Images (Stage 2) • Memory allocation • Allocate Kernel image space • MEM_START + 0x8000 • 32k for boot parameters, kernel page table • Allocate Root filesystem space • MEM_START + 0x00100000 • Loading • Load and extract Kernel image from flash to RAM. • Load and extract the root filesystem image from flash to RAM.

  18. 4.1 Launch Kernel Boot (Stage 2) • Set the starting parameters of kernel. • Tagged list methods • Start kernel • Initialize System • By calling kernel functions

  19. 4.1 Starting Parameters (Stage 2) • Set the starting parameters of kernel • Use the tagged list to pass the starting parameters • Starting with ATAG_CORE tag • Ending with ATAG_NONE tag • (After version 2.4.x) • The starting parameters that need to be set by the Bootloader: • ATAG_CORE • ATAG_MEM • ATAG_CMDLINE, • ATAG_RAMDISK • ATAG_INITRD

  20. 4.1 Start Kernel (Stage 2) • Jump to MEM_START + 0x8000 • Setting the CPU registers • R0=0 • R1=machine type ID • Linux/arch/arm/tools/mach-types • R2=Base address of the starting parameter list in RAMs • CPU mode • The interrupt needs to be inhibited (IRQs and FIQs). • It needs to set the CPU as SVC (Switch Virtual Circuit) mode. • Cache and MMU setting • Disable MMU • Neglect if the embedded system has no MMU (memory management unit). • Disable data cache

  21. 4.1 Initializing System • Calling kernel functions • Various objects and services functions of kernel: • Task objects • Timer services • Memory management services • … • Loading system device drivers • Initialize hardware devices

  22. 4.1 XSBase255B Bootloader Operations • Object • To finish the preparing work properly before the kernel starting. • Stage1 : • Devices initialization with the Assembly language • Stage2 : • Complex initialization implemented by the C language, but never call any function of glibc. • How to jump to the main()? • Directly jump to the entry point of the main • External wrappers: write a trampoline program (assembly), and let it be the entry point of the stage 2. Jump to the main from here. The reverse direction is used as it returns.

  23. 4.1 Some Second-Stage Boot Loaders • Used for Stage 2 • bootman • GRUB • LILO • MasterBooter • NTLDR • XOSL • BootX • loadlin • Gujin • OSL2000 Boot Manager • Boot Camp • Syslinux • GAG (Graphical Boot Manager)

  24. 4.1 The Bootloaders Support

  25. 4.1 Sites of the Embedded X86 Bootloaders • alios • http://www.telos.de/linux/alios/default.htm • LinuxBIOS • http://www.acl.lanl.gov/linuxbios/index.html • NILO(netboot,etherboot) • http://nilo.sourceforge.net • TinyBIOS • http://www.pcengines.ch/tinybios.htm • ROLO • ftp://www/elinos/pub/elinos/rolo

  26. 4.1 Other Embedded Bootloader Sites • LILO/GRUB • http://lilo.go.dyndns.org • http://www.gnu.org/software/grub/ • Blob :LART project • http://www.lart.tudelft.nl/lartwareblob/ • U-Boot • http://u-boot.sourceforge.net/ • http://www.denx.de/re/DPLG.html • http://sourceeforge.net/projects/u-boot • http://armboot.sourceforge.net/ • RedBoot • http://www.ecoscentric.com/snapshots/

  27. 4.1 The Typical Bootloaders • NTLDR (NT Loader ) • For 2000/XP/Server 2003 • Does not appear in Windows Vista • To load an NT-based OS • LILO (LInux LOader) • A generic boot loader for Linux • GRUB (GNU GRUB) • A boot loader package from the GNU Project • U-Boot (universal bootloader) • Portable • Easy to port and debug

  28. 4.1 The Typical Bootloader Supporting

  29. 4.1 Operation Modes of Boot Loaders • Boot loading Mode • Autonomous Mode • Loading during power on • Downloading Mode

  30. 4.1 The Downloading mode • An alternative of the Boot loading mode • The bootloader often use the following protocols are to connect the Target and Host: • UART Protocol • Usually as xmodem, ymodem, zmodem • The speed is limited • TFTP Protocol (network transferring) • The Host needs to provide TFTP service • Downloading documents from the Host • Such as the image

  31. 4.2 Embedded Operating System 4.1 Bootloader 4.2 Embedded Operating System 4.3 Root Filesystem 4.4 Graphic User Interface of Embedded system

  32. 4.2 Architecture of Embedded Systems

  33. 4.2 Typical Embedded Operating Systems • Windows CE /Mobile Windows • Palm OS • EPOC • uC/OS-II • Symbian OS • RTOS: • VxWorks, pSOS… • Linux: • uClinux, Montavista Linux, ARM-Linux…

  34. 4.2 WinCE Architectures

  35. 4.2 Advantages of WinCE • Benefits • Built-in NAND Flash bootloader, SD Host • Various embedded IP • Design time reduction with a supporting reference board & RTOS • Various design applications • Key Applications • Wireless PDA • Smartphone • Game machines • Point-of-Sale terminals • Portable media players

  36. 4.2 Linux Kernel From http://www.xml.com/ldd/chapter/book/bookindexpdf.html (GPL)

  37. Embedded Debian Project Convert Debian to an embedded OS ETLinux For PC104 SBC’s uCLinux For microprocessors that don’t have MM uLinux (muLinux) Distro fits on a single floppy 4.2 Open Source Embedded Linux

  38. 4.2 Kernel Space • Kernel structure • Data structure of Process • Process ID, Priority, Status, Registers used, Interrupt, Global variables • Process Management • User’s service routines in a forever loop • Time Management • Required time delay for interrupt • Inter-process Communication & Synchronization • Semaphores, message boxes, message queues • Memory Management • Mechanism of memory allocation and release

  39. 4.2 Kernel Architecture of RTOS • Kernel Primitive • Issue system calls for Interrupts • Interfacing the processes to the system • Interrupt Service Routine (ISR) • Software interrupt & hardware interrupt • Process Scheduler • A dispatcher • First-come-first-serviced Scheduling (FCFS) • Priority Scheduling (PS) • Preemptive • Non-preemptive

  40. 4.2 Basic Kernel Program • Synchronization • Semaphores: Accessed by Pend() and Post() • Buffer management • Request() and Release() • Data transfer • Send() and Receive() • Interrupt Management • EnableINT() and DisableINT() • Process Management • Process Control Block (PCB) • Process state: running, waiting, ready • Context switch

  41. 4.2 uCLinux Structure

  42. 4.2 Building XSBase255B Linux kernel • Setup Kernel • Directories and files • Setup Makefile and config.in • Add applications to Kernel

  43. 4.2 Kernel Directory Structure

  44. 4.2 Kernel Configuration • Three part of files required • Makefile • Config.in • Configuration tools(圖形介面, 用戶配置…)

  45. 4.2 Make Kernel • $make menuconfig • $make dep • $make zImage

  46. 4.3 Root Filesystem 4.1 Bootloader 4.2 Embedded Operating System 4.3 Root Filesystem 4.4 Graphic User Interface of Embedded system

  47. 4.3 Root Filesystem Types

  48. 4.3 The cramfs Filesystem • Cramfs • The compressed ROM filesystem (or cramfs) • A free (GPL'ed) read-only Linux file system designed for simplicity and space-efficiency • Cramfs is used on a number of embedded systems and small devices • File size <16MB • Capacity<256MB • Kernel’s PAGE_CACHE_SIZE=4096B

  49. 4.3 The ext2 Filesystem • Advantages: • Support up to 4TB memory • Support 1012 bytes long file name • symbolic link : index table speed up • Disadvantages : • IDE device design: 1block=512, 1024, 2048… • NAND FLASH not support • ERASE/Write • No balance management

  50. 4.3 The JFFS2 Filesystem • JFFS2 • A log-structured file system designed for use on flash devices in embedded systems. • Features • Compression ratio < cramfs • Better than ext2 in (r/w/erase) • Power down no crash • If full slow down performance

More Related