4.1 Starting Parameters (Stage 2)
Download
Report
Transcript 4.1 Starting Parameters (Stage 2)
Chapter 4
Embedded Software Architectures
Professor Ruei-Xi Chen
E-mail: [email protected]
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
Three Software Component Images
Bootloder image
Kernel image
Root Filesystem image
教育部顧問室PAL聯盟/系統雛型與軟硬體整合設計
第四章:嵌入式軟體架構
P-3/80
Typical Embedded SW Image Maps
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.
Bootloader
Boot Parameters
Kernel
Root Filesystem
教育部顧問室PAL聯盟/系統雛型與軟硬體整合設計
第四章:嵌入式軟體架構
P-4/80
4.1 Bootloader
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?
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.
教育部顧問室PAL聯盟/系統雛型與軟硬體整合設計
第四章:嵌入式軟體架構
P-6/80
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)
教育部顧問室PAL聯盟/系統雛型與軟硬體整合設計
第四章:嵌入式軟體架構
P-7/80
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
…
教育部顧問室PAL聯盟/系統雛型與軟硬體整合設計
第四章:嵌入式軟體架構
P-8/80
4.1 Boot Processes
教育部顧問室PAL聯盟/系統雛型與軟硬體整合設計
第四章:嵌入式軟體架構
P-9/80
4.1 Categories of Bootloader Processing
Single-Stage boot loaders
2. Multi-Stage boot loaders
Capable of offering good functionality and portability
Often used
1.
教育部顧問室PAL聯盟/系統雛型與軟硬體整合設計
第四章:嵌入式軟體架構
P-10/80
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
教育部顧問室PAL聯盟/系統雛型與軟硬體整合設計
第四章:嵌入式軟體架構
P-11/80
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
教育部顧問室PAL聯盟/系統雛型與軟硬體整合設計
第四章:嵌入式軟體架構
P-12/80
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.
教育部顧問室PAL聯盟/系統雛型與軟硬體整合設計
第四章:嵌入式軟體架構
P-13/80
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
教育部顧問室PAL聯盟/系統雛型與軟硬體整合設計
第四章:嵌入式軟體架構
P-14/80
4.1 Memory Map
0x0000,0000
0x0000,0400(1KB)
Stage1, 1K
(Image of boorloader)
Stage2, 64K
0x0001,0000(64KB) (Image of boorloader)
(Blank)
Flash
Kernel Image
(Blank)
ramdisk
stage2_start
Stack_Pointer: stage2_end - 4 Stage1 allocated RAM
sapce for Stage 2
stage2_end
教育部顧問室PAL聯盟/系統雛型與軟硬體整合設計
第四章:嵌入式軟體架構
RAM
P-15/80
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
教育部顧問室PAL聯盟/系統雛型與軟硬體整合設計
第四章:嵌入式軟體架構
P-16/80
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.
教育部顧問室PAL聯盟/系統雛型與軟硬體整合設計
第四章:嵌入式軟體架構
P-17/80
4.1 Launch Kernel Boot (Stage 2)
Set the starting parameters of kernel.
Tagged list methods
Start kernel
Initialize System
By calling kernel functions
教育部顧問室PAL聯盟/系統雛型與軟硬體整合設計
第四章:嵌入式軟體架構
P-18/80
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
教育部顧問室PAL聯盟/系統雛型與軟硬體整合設計
第四章:嵌入式軟體架構
P-19/80
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
教育部顧問室PAL聯盟/系統雛型與軟硬體整合設計
第四章:嵌入式軟體架構
P-20/80
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
教育部顧問室PAL聯盟/系統雛型與軟硬體整合設計
第四章:嵌入式軟體架構
P-21/80
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.
教育部顧問室PAL聯盟/系統雛型與軟硬體整合設計
第四章:嵌入式軟體架構
P-22/80
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)
教育部顧問室PAL聯盟/系統雛型與軟硬體整合設計
第四章:嵌入式軟體架構
P-23/80
4.1 The Bootloaders Support
教育部顧問室PAL聯盟/系統雛型與軟硬體整合設計
第四章:嵌入式軟體架構
P-24/80
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
教育部顧問室PAL聯盟/系統雛型與軟硬體整合設計
第四章:嵌入式軟體架構
P-25/80
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/
教育部顧問室PAL聯盟/系統雛型與軟硬體整合設計
第四章:嵌入式軟體架構
P-26/80
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
教育部顧問室PAL聯盟/系統雛型與軟硬體整合設計
第四章:嵌入式軟體架構
P-27/80
4.1 The Typical Bootloader Supporting
x86
NTLDR
★
LILO
★
GRUB
★
Blob
ARM
MIPS
PPC
NIOS
(Altera)
Microblaze
(Xilinx)
★
★
★
U-Boot*
★
★
★
★
RedBoot*
★
★
★
★
教育部顧問室PAL聯盟/系統雛型與軟硬體整合設計
第四章:嵌入式軟體架構
P-28/80
4.1 Operation Modes of Boot Loaders
Boot loading Mode
Autonomous Mode
Loading during power on
2. Downloading Mode
1.
教育部顧問室PAL聯盟/系統雛型與軟硬體整合設計
第四章:嵌入式軟體架構
P-29/80
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
教育部顧問室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 Architecture of Embedded Systems
教育部顧問室PAL聯盟/系統雛型與軟硬體整合設計
第四章:嵌入式軟體架構
P-32/80
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…
教育部顧問室PAL聯盟/系統雛型與軟硬體整合設計
第四章:嵌入式軟體架構
P-33/80
4.2 WinCE Architectures
教育部顧問室PAL聯盟/系統雛型與軟硬體整合設計
第四章:嵌入式軟體架構
P-34/80
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
教育部顧問室PAL聯盟/系統雛型與軟硬體整合設計
第四章:嵌入式軟體架構
P-35/80
4.2 Linux Kernel
From http://www.xml.com/ldd/chapter/book/bookindexpdf.html
(GPL)
教育部顧問室PAL聯盟/系統雛型與軟硬體整合設計
第四章:嵌入式軟體架構
P-36/80
4.2 Open Source Embedded Linux
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
教育部顧問室PAL聯盟/系統雛型與軟硬體整合設計
第四章:嵌入式軟體架構
P-37/80
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
教育部顧問室PAL聯盟/系統雛型與軟硬體整合設計
第四章:嵌入式軟體架構
P-38/80
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
教育部顧問室PAL聯盟/系統雛型與軟硬體整合設計
第四章:嵌入式軟體架構
P-39/80
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
教育部顧問室PAL聯盟/系統雛型與軟硬體整合設計
第四章:嵌入式軟體架構
P-40/80
4.2 uCLinux Structure
教育部顧問室PAL聯盟/系統雛型與軟硬體整合設計
第四章:嵌入式軟體架構
P-41/80
4.2 Building XSBase255B Linux kernel
Setup Kernel
Directories and files
Setup Makefile and config.in
Add applications to Kernel
教育部顧問室PAL聯盟/系統雛型與軟硬體整合設計
第四章:嵌入式軟體架構
P-42/80
4.2 Kernel Directory Structure
教育部顧問室PAL聯盟/系統雛型與軟硬體整合設計
第四章:嵌入式軟體架構
P-43/80
4.2 Kernel Configuration
Three part of files required
1. Makefile
2. Config.in
3. Configuration tools(圖形介面, 用戶配置…)
教育部顧問室PAL聯盟/系統雛型與軟硬體整合設計
第四章:嵌入式軟體架構
P-44/80
4.2 Make Kernel
$make menuconfig
$make dep
$make zImage
教育部顧問室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
JFFS2
y
y
y
y
n
JFFS
y
y
y
n
n
NFTL/Ext2
y
y
n
n
n
NFTL/Ext3
y
y
y
n
n
RAMDISK/
Ext2
y
n
n
n
y
NFTL:NAND Flash Transfer Layer
教育部顧問室PAL聯盟/系統雛型與軟硬體整合設計
第四章:嵌入式軟體架構
P-47/80
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
教育部顧問室PAL聯盟/系統雛型與軟硬體整合設計
第四章:嵌入式軟體架構
P-48/80
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
教育部顧問室PAL聯盟/系統雛型與軟硬體整合設計
第四章:嵌入式軟體架構
P-49/80
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
教育部顧問室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 Future Multi-mode IA Terminal
教育部顧問室PAL聯盟/系統雛型與軟硬體整合設計
第四章:嵌入式軟體架構
P-52/80
4.4 Common Features: Graphic User Interface
PDA:PPT 8846
3D Graphics
Typical GUI
HP iPAQ rz1710 Navigator
203 MHz S3C2410
7,0 x 1,3 x 11,4 cm
教育部顧問室PAL聯盟/系統雛型與軟硬體整合設計
第四章:嵌入式軟體架構
P-53/80
4.4 Embedded System GUI More
www.cybervision.com.tw/
教育部顧問室PAL聯盟/系統雛型與軟硬體整合設計
第四章:嵌入式軟體架構
P-54/80
Tiny-X GUI Fundamentals
GUI Builder for Linux: the Glade
Glade and GTK+
What is GTK?
GTK+: GIMP Tool Kit
GIMP: GNU Image Manipulation Program
GTK+ is a set of Graphical User Interface (GUI) tool
GTK+ is used to build GUI-based X-window system
What is Glade?
Glade is an User Interface Builder for GTK+
Glade is a Visual Programming Tool
Similar to the Visual tool VB, Delphi,…
教育部顧問室PAL聯盟/系統雛型與軟硬體整合設計
第四章:嵌入式軟體架構
P-56/80
Installation of “Glade” on XSBase255
At the /home/Packages/RPM/ folder, type the command:
rpm –ivh glade-0.6.4-9.i386.rpm
rpm is the Red-Hat Package Manager
-i means install
Command: rpm –ivh glade-0.6.4.9.i386.rpm
教育部顧問室PAL聯盟/系統雛型與軟硬體整合設計
第四章:嵌入式軟體架構
P-57/80
MPEG-2 Technologies
MPEG-2 Decoder Implementation
MPEG
MPEG ( Motion Picture Experts Group)
Established in 1988
A working group of ISO/IEC in charge of the development of
standards for coded representation of digital audio and video
MPEG Standards: System, Video, Audio
Products
MPEG-1: Video CD and MP3 are based
MPEG-2: Digital Television set top boxes and DVD
MPEG-4: multimedia for the fixed and mobile web
MPEG-7: for description and search of audio and visual
content
MPEG-21: the Multimedia Framework
Reference sites
http://www.mpeg.org/
http://www.chiariglione.org/mpeg/
教育部顧問室PAL聯盟/系統雛型與軟硬體整合設計
第四章:嵌入式軟體架構
P-59/80
MPEG System Specifications
Provide timing information for:
Buffer management
Audio/video synchronization
...
Multiplex bit streams of:
Audio, video, data and control
Supporting:
Access control (security)
Program specific information
Digital storage control
...
MPEG-2 system applications
Broadcast digital TV, Cable digital TV, Interactive TV,
DVD, ... etc.
教育部顧問室PAL聯盟/系統雛型與軟硬體整合設計
第四章:嵌入式軟體架構
P-60/80
H.264/AVC MPEG-4 Applications
(資料來源:工研院經資中心 經濟部ITIS計畫,2000、資料整理:MIC)
教育部顧問室PAL聯盟/系統雛型與軟硬體整合設計
第四章:嵌入式軟體架構
P-61/80
MPEG-2 Video Compression
Topics
MPEG Coder/Decoder Diagram
Profiles and Levels
Frames, Fields, Pictures (I: Intraframe, P: Predicted, B:
Bi-directional)
I P B Picture Reordering
Pixel Positioning
Compression tools
MPEG 2 Video Data Structures
MPEG-2 Toturial Web Sites
http://www.bretl.com/mpeghtml/MPEGindex.htm
教育部顧問室PAL聯盟/系統雛型與軟硬體整合設計
第四章:嵌入式軟體架構
P-62/80
Basic MPEG Diagram
Video
signal
DCT
+
+
Q
VLC
Coded
Macro-Block
Data
-
IQ
Block of
Current
Frame
IDCT
ME
+
Vector
Block of
Previous
Frame
+
BUF
Coded
Macro-Block
Data
+
Frame
Buffer
MC
(a) MPEG encoder block diagram
Decoded Video Signal
VLD
IQ
IDCT
+
Motion Vectors
Frame
Memory
MC
(b) MPEG decoder block diagram
教育部顧問室PAL聯盟/系統雛型與軟硬體整合設計
第四章:嵌入式軟體架構
P-63/80
Mpeg2 Encode Profiling
Operation
% exe time
Motion estimation (dist1)
71%
Discrete cosine transform
9%
Subsampling
2%
Predication
1%
Quantisation
1%
Variable length encoding
1%
Other kernels
14%
教育部顧問室PAL聯盟/系統雛型與軟硬體整合設計
第四章:嵌入式軟體架構
P-64/80