Chapter 4 Embedded Software Architectures Professor RueiXi Chen
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 教育部顧問室PAL聯盟/系統雛型與軟硬體整合設計 第四章:嵌入式軟體架構 P-2/80
Software Component Images of Embedded Systems u Three Software Component Images n Bootloder image n Kernel image n Root Filesystem image 教育部顧問室PAL聯盟/系統雛型與軟硬體整合設計 第四章:嵌入式軟體架構 P-3/80
Typical Embedded SW Image Maps u Pre-fixed instructions n Can be Fetched from fixed locations during power up. l Ex: Start from 0 x 0000 u Pre-allocated Solid Devices: n FLASH n ROM n Or EEPROM u Typical image map is as shown. Bootloader Boot Parameters Kernel Root Filesystem 教育部顧問室PAL聯盟/系統雛型與軟硬體整合設計 第四章:嵌入式軟體架構 P-4/80
4. 1 Bootloader 4. 2 Embedded Operating System 4. 3 Root Filesystem 4. 4 Graphic User Interface of Embedded system 教育部顧問室PAL聯盟/系統雛型與軟硬體整合設計 第四章:嵌入式軟體架構 P-5/80
4. 1 What is a Bootloader? u A special small program n that also called a bootstrap loader. u The only job of a boot loader: n To load other software for the operating system to start. 教育部顧問室PAL聯盟/系統雛型與軟硬體整合設計 第四章:嵌入式軟體架構 P-6/80
4. 1 The Linux Bootloader u To initialize platform: n Load the Linux kernel l Kernel can be downloaded by using tftp/bootp. l Kernel is accessed from flash if it resides in Flash. n Run the Linux kernel n Setup various initialization parameters: l Command line: root=/dev/nfs …. l Platform ID (stored in r 1) 教育部顧問室PAL聯盟/系統雛型與軟硬體整合設計 第四章:嵌入式軟體架構 P-7/80
4. 1 Available Bootloaders for ARM Platforms u U-Boot: Universal Bootloader n A firmware for many CPU architectures and boards with full source code under GPL. n http: //sourceforge. net/projects/u-boot u Red. Boot n A comprehensive debug and bootstrap firmware solution for the development, deployment, and management of embedded devices. n http: //www. ecoscentric. com/ecos/redboot. shtml u… 教育部顧問室PAL聯盟/系統雛型與軟硬體整合設計 第四章:嵌入式軟體架構 P-8/80
4. 1 Categories of Bootloader Processing Single-Stage boot loaders 2. Multi-Stage boot loaders n Capable of offering good functionality and portability n Often used 1. 教育部顧問室PAL聯盟/系統雛型與軟硬體整合設計 第四章:嵌入式軟體架構 P-10/80
4. 1 Coding Style of Multi-Stage Bootloaders u A Two-Stage Boot Loader is employed. u Coding Styles in Stage 1 n Mostly coding with assembly languages l For the efficiency purpose u Coding Styles in Stage 2 n Coding in C languages l Well readability and portability l For ease of complex function realization 教育部顧問室PAL聯盟/系統雛型與軟硬體整合設計 第四章:嵌入式軟體架構 P-11/80
4. 1 Mission of Two-stage Bootloaders u Stage 1: n Hardware Initializing & Load Preparing l During Power up or System Reset n Assembly language u Stage 2: n Load Kernel Image n Launch Kernel Boot 教育部顧問室PAL聯盟/系統雛型與軟硬體整合設計 第四章:嵌入式軟體架構 P-12/80
4. 1 Hardware Initialization (Stage 1) u Detect the machine type u Initialization n Mask(阻擋) all Interrupt request n Set Processor’s clock rate n Memory & Register Initialization n Initialize required peripherals n Initialize the Interrupt controller and Install Interrupt handler. n Initialize the indicators (LED etc. ) n Disable Data and Instruction Cache Memory. 教育部顧問室PAL聯盟/系統雛型與軟硬體整合設計 第四章:嵌入式軟體架構 P-13/80
4. 1 Load Preparing (Stage 1) u Prepare RAM space for Stage 2 u Setup stack n The stack space had better be times of the memory page (4 KB) n Set stack pointer: sp = stage 2_end - 4 u Jump to the Entry-point of Stage 2 教育部顧問室PAL聯盟/系統雛型與軟硬體整合設計 第四章:嵌入式軟體架構 P-14/80
4. 1 Memory Map 0 x 0000, 0000 0 x 0000, 0400(1 KB) Stage 1, 1 K (Image of boorloader) Stage 2, 64 K 0 x 0001, 0000(64 KB) (Image of boorloader) (Blank) Flash Kernel Image (Blank) ramdisk stage 2_start Stack_Pointer: stage 2_end - 4 Stage 1 allocated RAM sapce for Stage 2 stage 2_end 教育部顧問室PAL聯盟/系統雛型與軟硬體整合設計 第四章:嵌入式軟體架構 RAM P-15/80
4. 1 Initialization (Stage 2) u Initial n Initialize the Stage 2 required hardware l At least initialize one serial port l Initialize Timers n Examine memory map l Assure the mapping address is accessible n Clear memory u Loader Enabled n Loader: a section code of Boot image 教育部顧問室PAL聯盟/系統雛型與軟硬體整合設計 第四章:嵌入式軟體架構 P-16/80
4. 1 Load Kernel Images (Stage 2) u Memory allocation n Allocate Kernel image space l MEM_START + 0 x 8000 l 32 k for boot parameters, kernel page table n Allocate Root filesystem space l MEM_START + 0 x 00100000 u Loading n Load and extract Kernel image from flash to RAM. n Load and extract the root filesystem image from flash to RAM. 教育部顧問室PAL聯盟/系統雛型與軟硬體整合設計 第四章:嵌入式軟體架構 P-17/80
4. 1 Launch Kernel Boot (Stage 2) u Set the starting parameters of kernel. n Tagged list methods u Start kernel u Initialize System n By calling kernel functions 教育部顧問室PAL聯盟/系統雛型與軟硬體整合設計 第四章:嵌入式軟體架構 P-18/80
4. 1 Starting Parameters (Stage 2) u Set the starting parameters of kernel n Use the tagged list to pass the starting parameters l Starting with ATAG_CORE tag l Ending with ATAG_NONE tag (After version 2. 4. x) n The starting parameters that need to be set by the Bootloader: l ATAG_CORE l ATAG_MEM l ATAG_CMDLINE, l ATAG_RAMDISK l ATAG_INITRD 教育部顧問室PAL聯盟/系統雛型與軟硬體整合設計 第四章:嵌入式軟體架構 P-19/80
4. 1 Start Kernel (Stage 2) u Jump to MEM_START + 0 x 8000 u Setting the CPU registers n R 0=0 n R 1=machine type ID l Linux/arch/arm/tools/mach-types n R 2=Base address of the starting parameter list in RAMs u CPU mode n The interrupt needs to be inhibited (IRQs and FIQs). n It needs to set the CPU as SVC (Switch Virtual Circuit) mode. u Cache and MMU setting n Disable MMU l Neglect if the embedded system has no MMU (memory management unit). n Disable data cache 教育部顧問室PAL聯盟/系統雛型與軟硬體整合設計 第四章:嵌入式軟體架構 P-20/80
4. 1 Initializing System u Calling kernel functions n Various objects and services functions of kernel: l Task objects l Timer services l Memory management services l… u Loading system device drivers n Initialize hardware devices 教育部顧問室PAL聯盟/系統雛型與軟硬體整合設計 第四章:嵌入式軟體架構 P-21/80
4. 1 XSBase 255 B Bootloader Operations u Object n To finish the preparing work properly before the kernel starting. u Stage 1 : n Devices initialization with the Assembly language u Stage 2 : n Complex initialization implemented by the C language, but never call any function of glibc. n How to jump to the main()? l Directly jump to the entry point of the main l 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. 教育部顧問室PAL聯盟/系統雛型與軟硬體整合設計 第四章:嵌入式軟體架構 P-22/80
4. 1 Some Second-Stage Boot Loaders u Used for Stage 2 n bootman n GRUB n LILO n Master. Booter n NTLDR n XOSL n Boot. X n loadlin n Gujin n OSL 2000 Boot Manager n Boot Camp n Syslinux n GAG (Graphical Boot Manager) 教育部顧問室PAL聯盟/系統雛型與軟硬體整合設計 第四章:嵌入式軟體架構 P-23/80
4. 1 Sites of the Embedded X 86 Bootloaders u alios u u n http: //www. telos. de/linux/alios/default. htm Linux. BIOS n http: //www. acl. lanl. gov/linuxbios/index. html NILO(netboot, etherboot) n http: //nilo. sourceforge. net Tiny. BIOS n http: //www. pcengines. ch/tinybios. htm ROLO n ftp: //www/elinos/pub/elinos/rolo 教育部顧問室PAL聯盟/系統雛型與軟硬體整合設計 第四章:嵌入式軟體架構 P-25/80
4. 1 Other Embedded Bootloader Sites u LILO/GRUB n http: //lilo. go. dyndns. org n http: //www. gnu. org/software/grub/ u Blob : LART project n http: //www. lart. tudelft. nl/lartwareblob/ u U-Boot n http: //u-boot. sourceforge. net/ n http: //www. denx. de/re/DPLG. html n http: //sourceeforge. net/projects/u-boot n http: //armboot. sourceforge. net/ u Red. Boot n http: //www. ecoscentric. com/snapshots/ 教育部顧問室PAL聯盟/系統雛型與軟硬體整合設計 第四章:嵌入式軟體架構 P-26/80
4. 1 The Typical Bootloaders u NTLDR (NT Loader ) n For 2000/XP/Server 2003 n Does not appear in Windows Vista n To load an NT-based OS u LILO (LInux LOader) n A generic boot loader for Linux u GRUB (GNU GRUB) n A boot loader package from the GNU Project u U-Boot (universal bootloader) n Portable n Easy to port and debug 教育部顧問室PAL聯盟/系統雛型與軟硬體整合設計 第四章:嵌入式軟體架構 P-27/80
4. 1 The Typical Bootloader Supporting x 86 NTLDR ★ LILO ★ GRUB ★ Blob ARM MIPS PPC NIOS (Altera) Microblaze (Xilinx) ★ ★ ★ U-Boot* ★ ★ Red. Boot* ★ ★ 教育部顧問室PAL聯盟/系統雛型與軟硬體整合設計 第四章:嵌入式軟體架構 P-28/80
4. 1 Operation Modes of Boot Loaders Boot loading Mode n Autonomous Mode l Loading during power on 2. Downloading Mode 1. 教育部顧問室PAL聯盟/系統雛型與軟硬體整合設計 第四章:嵌入式軟體架構 P-29/80
4. 1 The Downloading mode u An alternative of the Boot loading mode u The bootloader often use the following protocols are to connect the Target and Host: n UART Protocol l Usually as xmodem, ymodem, zmodem l The speed is limited n TFTP Protocol (network transferring) l The Host needs to provide TFTP service u Downloading documents from the Host n Such as the image 教育部顧問室PAL聯盟/系統雛型與軟硬體整合設計 第四章:嵌入式軟體架構 P-30/80
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 教育部顧問室PAL聯盟/系統雛型與軟硬體整合設計 第四章:嵌入式軟體架構 P-31/80
4. 2 Typical Embedded Operating Systems Windows CE /Mobile Windows Palm OS EPOC u. C/OS-II Symbian OS RTOS: n Vx. Works, p. SOS… u Linux: n u. Clinux, Montavista Linux, ARM-Linux… u u u 教育部顧問室PAL聯盟/系統雛型與軟硬體整合設計 第四章:嵌入式軟體架構 P-33/80
4. 2 Advantages of Win. CE u Benefits n Built-in NAND Flash bootloader, SD Host n Various embedded IP n Design time reduction with a supporting reference board & RTOS n Various design applications u Key Applications n Wireless PDA n Smartphone n Game machines n Point-of-Sale terminals n Portable media players 教育部顧問室PAL聯盟/系統雛型與軟硬體整合設計 第四章:嵌入式軟體架構 P-35/80
4. 2 Linux Kernel From http: //www. xml. com/ldd/chapter/bookindexpdf. html (GPL) 教育部顧問室PAL聯盟/系統雛型與軟硬體整合設計 第四章:嵌入式軟體架構 P-36/80
4. 2 Open Source Embedded Linux u Embedded Debian Project n Convert Debian to an embedded OS u ETLinux n For PC 104 SBC’s u u. CLinux n For microprocessors that don’t have MM u u. Linux (mu. Linux) n Distro fits on a single floppy 教育部顧問室PAL聯盟/系統雛型與軟硬體整合設計 第四章:嵌入式軟體架構 P-37/80
4. 2 Kernel Space u Kernel structure n Data structure of Process l Process ID, Priority, Status, Registers used, Interrupt, Global variables n Process Management l User’s service routines in a forever loop n Time Management l Required time delay for interrupt n Inter-process Communication & Synchronization l Semaphores, message boxes, message queues n Memory Management l Mechanism of memory allocation and release 教育部顧問室PAL聯盟/系統雛型與軟硬體整合設計 第四章:嵌入式軟體架構 P-38/80
4. 2 Kernel Architecture of RTOS u Kernel Primitive n Issue system calls for Interrupts n Interfacing the processes to the system u Interrupt Service Routine (ISR) n Software interrupt & hardware interrupt u Process Scheduler n A dispatcher l First-come-first-serviced Scheduling (FCFS) l Priority Scheduling (PS) Preemptive Non-preemptive 教育部顧問室PAL聯盟/系統雛型與軟硬體整合設計 第四章:嵌入式軟體架構 P-39/80
4. 2 Basic Kernel Program u Synchronization u u n Semaphores: Accessed by Pend() and Post() Buffer management n Request() and Release() Data transfer n Send() and Receive() Interrupt Management n Enable. INT() and Disable. INT() Process Management n Process Control Block (PCB) n Process state: running, waiting, ready n Context switch 教育部顧問室PAL聯盟/系統雛型與軟硬體整合設計 第四章:嵌入式軟體架構 P-40/80
4. 2 Building XSBase 255 B Linux kernel u Setup Kernel u Directories and files u Setup Makefile and config. in u Add applications to Kernel 教育部顧問室PAL聯盟/系統雛型與軟硬體整合設計 第四章:嵌入式軟體架構 P-42/80
4. 2 Kernel Configuration u Three part of files required 1. Makefile 2. Config. in 3. Configuration tools(圖形介面, 用戶配置…) 教育部顧問室PAL聯盟/系統雛型與軟硬體整合設計 第四章:嵌入式軟體架構 P-44/80
4. 2 Make Kernel u $make menuconfig u $make dep u $make z. Image 教育部顧問室PAL聯盟/系統雛型與軟硬體整合設計 第四章:嵌入式軟體架構 P-45/80
4. 3 Root Filesystem 4. 1 Bootloader 4. 2 Embedded Operating System 4. 3 Root Filesystem 4. 4 Graphic User Interface of Embedded system 教育部顧問室PAL聯盟/系統雛型與軟硬體整合設計 第四章:嵌入式軟體架構 P-46/80
4. 3 Root Filesystem Types Filesystem Write Always Power Down reliability Compress In RAM CRAMFS n n n y n JFFS 2 y y n JFFS y y y n n NFTL/Ext 2 y y n n n NFTL/Ext 3 y y y n n RAMDISK/ Ext 2 y n n n y NFTL: NAND Flash Transfer Layer 教育部顧問室PAL聯盟/系統雛型與軟硬體整合設計 第四章:嵌入式軟體架構 P-47/80
4. 3 The cramfs Filesystem u Cramfs n The compressed ROM filesystem (or cramfs) n A free (GPL'ed) read-only Linux file system designed for simplicity and space-efficiency u Cramfs is used on a number of embedded systems and small devices n File size <16 MB n Capacity<256 MB n Kernel’s PAGE_CACHE_SIZE=4096 B 教育部顧問室PAL聯盟/系統雛型與軟硬體整合設計 第四章:嵌入式軟體架構 P-48/80
4. 3 The ext 2 Filesystem u Advantages: n Support up to 4 TB memory n Support 1012 bytes long file name n symbolic link : index table speed up u Disadvantages : n IDE device design: 1 block=512, 1024, 2048… n NAND FLASH not support n ERASE/Write n No balance management 教育部顧問室PAL聯盟/系統雛型與軟硬體整合設計 第四章:嵌入式軟體架構 P-49/80
4. 3 The JFFS 2 Filesystem u JFFS 2 n A log-structured file system designed for use on flash devices in embedded systems. u Features n Compression ratio < cramfs n Better than ext 2 in (r/w/erase) n Power down no crash n If full slow down performance 教育部顧問室PAL聯盟/系統雛型與軟硬體整合設計 第四章:嵌入式軟體架構 P-50/80
4. 4 Graphic User Interface of Embedded system 4. 1 Bootloader 4. 2 Embedded Operating System 4. 3 Root Filesystem 4. 4 Graphic User Interface of Embedded system 教育部顧問室PAL聯盟/系統雛型與軟硬體整合設計 第四章:嵌入式軟體架構 P-51/80
4. 4 Common Features: Graphic User Interface PDA:PPT 8846 3 D Graphics Typical GUI HP i. PAQ rz 1710 Navigator 203 MHz S 3 C 2410 7, 0 x 1, 3 x 11, 4 cm 教育部顧問室PAL聯盟/系統雛型與軟硬體整合設計 第四章:嵌入式軟體架構 P-53/80
Tiny-X GUI Fundamentals GUI Builder for Linux: the Glade
Glade and GTK+ u What is GTK? n GTK+: GIMP Tool Kit l GIMP: GNU Image Manipulation Program n GTK+ is a set of Graphical User Interface (GUI) tool n GTK+ is used to build GUI-based X-window system u What is Glade? n Glade is an User Interface Builder for GTK+ n Glade is a Visual Programming Tool l Similar to the Visual tool VB, Delphi, … 教育部顧問室PAL聯盟/系統雛型與軟硬體整合設計 第四章:嵌入式軟體架構 P-56/80
Installation of “Glade” on XSBase 255 u At the /home/Packages/RPM/ folder, type the command: rpm –ivh glade-0. 6. 4 -9. i 386. rpm n rpm is the Red-Hat Package Manager n -i means install Command: rpm –ivh glade-0. 6. 4. 9. i 386. rpm 教育部顧問室PAL聯盟/系統雛型與軟硬體整合設計 第四章:嵌入式軟體架構 P-57/80
MPEG-2 Technologies MPEG-2 Decoder Implementation
MPEG u MPEG ( Motion Picture Experts Group) n Established in 1988 n A working group of ISO/IEC in charge of the development of standards for coded representation of digital audio and video n MPEG Standards: System, Video, Audio u Products n MPEG-1: Video CD and MP 3 are based n MPEG-2: Digital Television set top boxes and DVD n MPEG-4: multimedia for the fixed and mobile web n MPEG-7: for description and search of audio and visual content n MPEG-21: the Multimedia Framework u Reference sites n http: //www. mpeg. org/ n http: //www. chiariglione. org/mpeg/ 教育部顧問室PAL聯盟/系統雛型與軟硬體整合設計 第四章:嵌入式軟體架構 P-59/80
MPEG System Specifications u Provide timing information for: n Buffer management n Audio/video synchronization n. . . u Multiplex bit streams of: n Audio, video, data and control u Supporting: n Access control (security) n Program specific information n Digital storage control n. . . u MPEG-2 system applications n Broadcast digital TV, Cable digital TV, Interactive TV, DVD, . . . etc. 教育部顧問室PAL聯盟/系統雛型與軟硬體整合設計 第四章:嵌入式軟體架構 P-60/80
MPEG-2 Video Compression u Topics n MPEG Coder/Decoder Diagram n Profiles and Levels n Frames, Fields, Pictures (I: Intraframe, P: Predicted, B: Bidirectional) n I P B Picture Reordering n Pixel Positioning n Compression tools n MPEG 2 Video Data Structures u MPEG-2 Toturial Web Sites n http: //www. bretl. com/mpeghtml/MPEGindex. htm 教育部顧問室PAL聯盟/系統雛型與軟硬體整合設計 第四章:嵌入式軟體架構 P-62/80
Mpeg 2 Encode Profiling Operation % exe time Motion estimation (dist 1) 71% Discrete cosine transform 9% Subsampling 2% Predication 1% Quantisation 1% Variable length encoding 1% Other kernels 14% 教育部顧問室PAL聯盟/系統雛型與軟硬體整合設計 第四章:嵌入式軟體架構 P-64/80
- Slides: 64