Upload
others
View
6
Download
0
Embed Size (px)
Citation preview
Chapter 4Chapter 4Embedded Software ArchitecturesEmbedded Software Architectures
Professor Professor RueiRuei--Xi ChenXi ChenEE--mail: mail: [email protected]@mail.sju.edu.tw
Http://Http://www.csie.sju.edu.twwww.csie.sju.edu.twSJU/CSIESJU/CSIE
P-2/162教育部顧問室PAL聯盟/系統雛型與軟硬體整合設計 第四章:嵌入式軟體架構
OutlineOutline4.1 4.1 BootloaderBootloader4.2 Embedded Operating System4.2 Embedded Operating System4.3 Root 4.3 Root FilesystemFilesystem4.4 Graphic User Interface of Embedded system4.4 Graphic User Interface of Embedded system
P-3/162教育部顧問室PAL聯盟/系統雛型與軟硬體整合設計 第四章:嵌入式軟體架構
Software Component Images of Embedded SystemsSoftware Component Images of Embedded SystemsThree Software Component Images
Bootloder imageKernel imageRoot Filesystem image
P-4/162教育部顧問室PAL聯盟/系統雛型與軟硬體整合設計 第四章:嵌入式軟體架構
Root Filesystem
TypicalTypical Embedded SW Image MapsEmbedded SW Image MapsPre-fixed instructions
Can be Fetched from fixed locations during power up.
Ex: Start from 0x00000000Pre-allocated Solid Devices:
FLASHROMOr EEPROM
Typical image map is as shown.
Kernel
Boot ParametersBootloader
P-5/162教育部顧問室PAL聯盟/系統雛型與軟硬體整合設計 第四章:嵌入式軟體架構
4.1 4.1 BootloaderBootloader4.1 4.1 BootloaderBootloader4.2 Embedded Operating System4.2 Embedded Operating System4.3 Root 4.3 Root FilesystemFilesystem4.4 Graphic User Interface of Embedded system4.4 Graphic User Interface of Embedded system
P-6/162教育部顧問室PAL聯盟/系統雛型與軟硬體整合設計 第四章:嵌入式軟體架構
4.1 What is a 4.1 What is a BootloaderBootloader??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.
P-7/162教育部顧問室PAL聯盟/系統雛型與軟硬體整合設計 第四章:嵌入式軟體架構
4.1 The Linux 4.1 The Linux BootloaderBootloaderTo initialize platform:
Load the Linux kernelKernel can be downloaded by using tftp/bootp.Kernel is accessed from flash if it resides in Flash.
Run the Linux kernelSetup various initialization parameters:
Command line: root=/dev/nfs ….Platform ID (stored in r1)
P-8/162教育部顧問室PAL聯盟/系統雛型與軟硬體整合設計 第四章:嵌入式軟體架構
4.1 Available 4.1 Available BootloadersBootloaders for ARM Platformsfor ARM PlatformsU-Boot: Universal Bootloader
A firmware for many CPU architectures and boards with full source code under GPL. http://sourceforge.net/projects/u-boot
RedBootA comprehensive debug and bootstrap firmware solution for the development, deployment, and management of embedded devices. http://www.ecoscentric.com/ecos/redboot.shtml
…
P-9/162教育部顧問室PAL聯盟/系統雛型與軟硬體整合設計 第四章:嵌入式軟體架構
4.1 4.1 BootBoot ProcessesProcesses
P-10/162教育部顧問室PAL聯盟/系統雛型與軟硬體整合設計 第四章:嵌入式軟體架構
4.1 Categories of 4.1 Categories of BootloaderBootloader Processing Processing 1. Single-Stage boot loaders2. Multi-Stage boot loaders
Capable of offering good functionality and portabilityOften used
P-11/162教育部顧問室PAL聯盟/系統雛型與軟硬體整合設計 第四章:嵌入式軟體架構
4.1 Coding Style of Multi4.1 Coding Style of Multi--Stage Stage BootloadersBootloadersA Two-Stage Boot Loader is employed.Coding Styles in Stage 1
Mostly coding with assembly languagesFor the efficiency purpose
Coding Styles in Stage 2Coding in C languages
Well readability and portabilityFor ease of complex function realization
P-12/162教育部顧問室PAL聯盟/系統雛型與軟硬體整合設計 第四章:嵌入式軟體架構
4.1 Mission of Two4.1 Mission of Two--stage stage BootloadersBootloadersStage 1:
Hardware Initializing & Load PreparingDuring Power up or System Reset
Assembly languageStage 2:
Load Kernel ImageLaunch Kernel Boot
P-13/162教育部顧問室PAL聯盟/系統雛型與軟硬體整合設計 第四章:嵌入式軟體架構
4.1 Hardware Initialization (Stage 1)4.1 Hardware Initialization (Stage 1)Detect the machine typeInitialization
Mask(阻擋) all Interrupt requestSet Processor’s clock rateMemory & Register InitializationInitialize required peripheralsInitialize the Interrupt controller and Install Interrupt handler.Initialize the indicators (LED etc.)Disable Data and Instruction Cache Memory.
P-14/162教育部顧問室PAL聯盟/系統雛型與軟硬體整合設計 第四章:嵌入式軟體架構
4.1 Load Preparing (Stage 1)4.1 Load Preparing (Stage 1)Prepare RAM space for Stage 2Setup 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
P-15/162教育部顧問室PAL聯盟/系統雛型與軟硬體整合設計 第四章:嵌入式軟體架構
Stage1 allocated RAMsapce for Stage 2
ramdisk
Kernel Image
Stage2, 64K(Image of boorloader)
Stage1, 1K(Image of boorloader)
0x0000,0000
0x0000,0400(1KB)
0x0001,0000(64KB)
stage2_end
stage2_startRAM
Flash(Blank)
(Blank)
Stack_Pointer: stage2_end - 4
4.1 Memory Map4.1 Memory Map
P-16/162教育部顧問室PAL聯盟/系統雛型與軟硬體整合設計 第四章:嵌入式軟體架構
4.1 Initialization (Stage 2)4.1 Initialization (Stage 2)Initial
Initialize the Stage 2 required hardwareAt least initialize one serial portInitialize Timers
Examine memory mapAssure the mapping address is accessible
Clear memoryLoader Enabled
Loader: a section code of Boot image
P-17/162教育部顧問室PAL聯盟/系統雛型與軟硬體整合設計 第四章:嵌入式軟體架構
4.1 Load Kernel Images (Stage 2)4.1 Load Kernel Images (Stage 2)Memory allocation
Allocate Kernel image spaceMEM_START + 0x800032k for boot parameters, kernel page table
Allocate Root filesystem spaceMEM_START + 0x00100000
LoadingLoad and extract Kernel image from flash to RAM. Load and extract the root filesystem image from flash to RAM.
P-18/162教育部顧問室PAL聯盟/系統雛型與軟硬體整合設計 第四章:嵌入式軟體架構
4.1 Launch Kernel Boot (Stage 2)4.1 Launch Kernel Boot (Stage 2)Set the starting parameters of kernel.
Tagged list methodsStart kernelInitialize System
By calling kernel functions
P-19/162教育部顧問室PAL聯盟/系統雛型與軟硬體整合設計 第四章:嵌入式軟體架構
4.1 Starting Parameters (Stage 2)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 tagEnding with ATAG_NONE tag
(After version 2.4.x)The starting parameters that need to be set by the Bootloader:
ATAG_COREATAG_MEMATAG_CMDLINE,ATAG_RAMDISKATAG_INITRD
P-20/162教育部顧問室PAL聯盟/系統雛型與軟硬體整合設計 第四章:嵌入式軟體架構
4.1 Start Kernel (Stage 2)4.1 Start Kernel (Stage 2)Jump to MEM_START + 0x8000Setting the CPU registers
R0=0R1=machine type ID
Linux/arch/arm/tools/mach-typesR2=Base address of the starting parameter list in RAMs
CPU modeThe interrupt needs to be inhibited (IRQs and FIQs).It needs to set the CPU as SVC (Switch Virtual Circuit) mode.
Cache and MMU settingDisable MMU
Neglect if the embedded system has no MMU (memory management unit).
Disable data cache
P-21/162教育部顧問室PAL聯盟/系統雛型與軟硬體整合設計 第四章:嵌入式軟體架構
4.1 Initializing System4.1 Initializing SystemCalling kernel functions
Various objects and services functions of kernel:Task objectsTimer servicesMemory management services…
Loading system device driversInitialize hardware devices
P-22/162教育部顧問室PAL聯盟/系統雛型與軟硬體整合設計 第四章:嵌入式軟體架構
4.1 4.1 XSBase255B XSBase255B BootloaderBootloader OperationsOperationsObject
To finish the preparing work properly before the kernel starting.Stage1 :
Devices initialization with the Assembly languageStage2 :
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 mainExternal 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.
P-23/162教育部顧問室PAL聯盟/系統雛型與軟硬體整合設計 第四章:嵌入式軟體架構
4.1 4.1 Some SSome Secondecond--Stage Boot LoadersStage Boot LoadersUsed for Stage 2
bootmanGRUBLILOMasterBooterNTLDRXOSLBootXloadlinGujinOSL2000 Boot ManagerBoot CampSyslinuxGAG (Graphical Boot Manager)
P-24/162教育部顧問室PAL聯盟/系統雛型與軟硬體整合設計 第四章:嵌入式軟體架構
4.1 The 4.1 The BootloadersBootloaders SupportSupport
P-25/162教育部顧問室PAL聯盟/系統雛型與軟硬體整合設計 第四章:嵌入式軟體架構
4.1 Sites of the Embedded X86 4.1 Sites of the Embedded X86 BootloadersBootloadersalios
http://www.telos.de/linux/alios/default.htmLinuxBIOS
http://www.acl.lanl.gov/linuxbios/index.htmlNILO(netboot,etherboot)
http://nilo.sourceforge.netTinyBIOS
http://www.pcengines.ch/tinybios.htmROLO
ftp://www/elinos/pub/elinos/rolo
P-26/162教育部顧問室PAL聯盟/系統雛型與軟硬體整合設計 第四章:嵌入式軟體架構
4.1 Other Embedded 4.1 Other Embedded BootloaderBootloader SitesSitesLILO/GRUB
http://lilo.go.dyndns.orghttp://www.gnu.org/software/grub/
Blob :LART projecthttp://www.lart.tudelft.nl/lartwareblob/
U-Boothttp://u-boot.sourceforge.net/http://www.denx.de/re/DPLG.htmlhttp://sourceeforge.net/projects/u-boothttp://armboot.sourceforge.net/
RedBoothttp://www.ecoscentric.com/snapshots/
P-27/162教育部顧問室PAL聯盟/系統雛型與軟硬體整合設計 第四章:嵌入式軟體架構
4.1 The Typical 4.1 The Typical BootloadersBootloadersNTLDR (NT Loader )
For 2000/XP/Server 2003Does not appear in Windows VistaTo 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)PortableEasy to port and debug
P-28/162教育部顧問室PAL聯盟/系統雛型與軟硬體整合設計 第四章:嵌入式軟體架構
4.1 The Typical 4.1 The Typical BootloaderBootloader SupportingSupporting
★★★★RedBoot*
★★★★★★U-Boot*
★Blob
★GRUB
★LILO
★NTLDR
Microblaze(Xilinx)
NIOS(Altera)PPCMIPSARMx86
P-29/162教育部顧問室PAL聯盟/系統雛型與軟硬體整合設計 第四章:嵌入式軟體架構
4.1 NTLDR Boot Process4.1 NTLDR Boot ProcessAccesses the file system on the boot drive (FAT/NTFS)Check if hiberfil.sys exist?
Yes, and its hibernation image is foundLoad its contents into memory and the system resumes where it left off.
OtherwiseReads boot.ini and prompts the user with the boot menu accordingly.
Is a NT-based OS selected?Yes, then NTLDR runs ntdetect.com, which gathers information about the computer's hardware. No, a non NT-based OS is selected, then NTLDR loads the associated file listed in boot.ini and gives it control.
Starts Ntoskrnl.exe, passing to it the information returned by ntdetect.com
P-30/162教育部顧問室PAL聯盟/系統雛型與軟硬體整合設計 第四章:嵌入式軟體架構
4.1 An NTLDR Boot Menu4.1 An NTLDR Boot Menu
P-31/162教育部顧問室PAL聯盟/系統雛型與軟硬體整合設計 第四章:嵌入式軟體架構
4.1 LILO Boot4.1 LILO BootLILO is a versatile boot loader for Linux.
It does not depend on a specific file system.It can boot Linux kernel images from floppy disks and hard disks.It can even boot other operating systems.One of up to sixteen different images can be selected at boot time.Various parameters, such as the root device, can be set independently for each kernel.
LILO can be used as the master boot record.Lately LILO has become a second choice in favor of the GRUBbootloader.
P-32/162教育部顧問室PAL聯盟/系統雛型與軟硬體整合設計 第四章:嵌入式軟體架構
4.1 LILO Boot Features4.1 LILO Boot Features
Linux loaderPlatform
x86Boot device
Floppy,HD,CDROM,CFSupport multi-OS bootingLocation
MBR or 1st sector of Boot partitionConfig file (/etc/lilo.conf)
P-33/162教育部顧問室PAL聯盟/系統雛型與軟硬體整合設計 第四章:嵌入式軟體架構
4.1 The Master Boot Record of LILO4.1 The Master Boot Record of LILOThe first sector of your hard disk
This is where your computer's BIOS will look for instructions onhow to load an operating system.
If you just had Win95 or DOS installedIt would just be an instruction to load that one OS.
LILO gives us the versatility to load more then one OS.
P-34/162教育部顧問室PAL聯盟/系統雛型與軟硬體整合設計 第四章:嵌入式軟體架構
4.1 Standard LILO Display4.1 Standard LILO Display
http://lilo.go.dyndns.org/Website:BSD licenseLicense:BootloaderUse:22.7.3 / August 11, 2006Latest release:
John CoffmanWerner Almesberger
Developer:Original developer:
P-35/162教育部顧問室PAL聯盟/系統雛型與軟硬體整合設計 第四章:嵌入式軟體架構
4.1 Configure LILO4.1 Configure LILOby Manually Editing the lilo.conf File
vi /etc/lilo.confExampleboot=/dev/had1install=/boot/boot.bmap=/boot/mapdefault=linuxtimeout=300image=/boot/vmlinuz-2.4.20label=linux-2.4.20root=/dev/hda1initrd=/boot/initrd.imgother=/dev/hdb1label=WindowsXP
P-36/162教育部顧問室PAL聯盟/系統雛型與軟硬體整合設計 第四章:嵌入式軟體架構
4.1 GNU GRUB 4.1 GNU GRUB GRUB is the reference implementation of the MultibootSpecification.GRUB can be used to:
Select different kernel imagesPass boot-time parameters to such kernels.
the GNU GRUB logo
P-37/162教育部顧問室PAL聯盟/系統雛型與軟硬體整合設計 第四章:嵌入式軟體架構
4.1 GRUB Boot Features4.1 GRUB Boot FeaturesGRand Unified BootloaderPlatform
x86Boot device
Floppy,HD,CDROMSupport multi-OS bootingBoot Location
MBR or 1st sector of Boot partitionConfig file:/boot/grub/menu.lst
P-38/162教育部顧問室PAL聯盟/系統雛型與軟硬體整合設計 第四章:嵌入式軟體架構
4.1 GRUB 4.1 GRUB BBoot Process 1oot Process 1Given the small size of the MBR (master boot record )
MBR: the first 512 bytes of the hard diskStage 1:
Load Stage 2 directlyOr load stage 1.5:
Which located in the first 30 kilobytes of hard disk immediately following the MBR, then Stage 1.5 loads Stage 2.
P-39/162教育部顧問室PAL聯盟/系統雛型與軟硬體整合設計 第四章:嵌入式軟體架構
4.1 GRUB Boot Process 24.1 GRUB Boot Process 2Presents an user interface (UI) to be selected which operating system to boot.
Show graphical menu or a command prompt.For the user to specify the boot parameters
GRUB can also be set to automatically load a particular kernel after a timeout period.
Loads the selected kernel into memory.Passes control on to the kernel
Can pass control of the boot process to another loader using chain loading.
P-40/162教育部顧問室PAL聯盟/系統雛型與軟硬體整合設計 第四章:嵌入式軟體架構
4.1 Configure GRUB4.1 Configure GRUB/boot/grub/memu.lstExampletimeout 10default 0title linuxroot (hd0,0)kernel /vmlinux-2.4.20-8 root=LABEL=/ initrd /initrd-2.4.20-8.imgtitle windows …
P-41/162教育部顧問室PAL聯盟/系統雛型與軟硬體整合設計 第四章:嵌入式軟體架構
4.1 Comparison of GRUB and LILO 4.1 Comparison of GRUB and LILO Different disk partition
GRUB: (hdN,p)LILO: hdaN
ExamplesIDE 1 master drive
LILO :/dev/hda1GRUB:(hd0,0)
IDE 1 slave driveLILO:/dev/hda2GRUB:(hd0,1)
Advantage of GRUBEditable and modifiable boot settingMore flexible
P-42/162教育部顧問室PAL聯盟/系統雛型與軟硬體整合設計 第四章:嵌入式軟體架構
4.1 U4.1 U--BootBootUniversal Boot LoaderOpen source firmware for embedded
PowerPC, ARM, XScale, MIPS, x86, NIOS, MicroBlaze …For Embedded OS
Linux, NetBSD, VxWorks, QNX, RTEMS, ARTOS, LynxOS
P-43/162教育部顧問室PAL聯盟/系統雛型與軟硬體整合設計 第四章:嵌入式軟體架構
4.1 U4.1 U--Boot FeaturesBoot FeaturesUniversal Boot LoaderOpen source firmware for embedded Platform:
PowerPC, ARM, XScale, MIPS, x86, Nios, MicroBlaze …For Embedded OS
Linux, NetBSD, VxWorks, QNX, RTEMS, ARTOS, LynxOSReliableConfigurableDevice driverNetworking abilitiesWell documentation
P-44/162教育部顧問室PAL聯盟/系統雛型與軟硬體整合設計 第四章:嵌入式軟體架構
4.1 U4.1 U--Boot SupportBoot SupportNFS/TFTP
KernelRamdisk
Many commandsStore Parameter blocks:
FLASH、NVRAM、EEPROMCRC32 checking
FLASH Kernel, RAMDISKDevice driver:
Serial、SDRAM、FLASH、Ethernet、LCD、NVRAM、EEPROM、keyboard、USB、PCMCIA、PCI、RTC
Post:SDRAM、FLASH size, SDRAM error check, CPU model
P-45/162教育部顧問室PAL聯盟/系統雛型與軟硬體整合設計 第四章:嵌入式軟體架構
4.1 U4.1 U--Boot Directories (1)Boot Directories (1)Board
Board supportSmdk2410/smdk2410.c, config.mk, Makefile, flash.c ,u-boot.lds etc.
Common U-Boot commandsA shell interpreter
hush.c, a prototype Bourne shell grammar parserCpu
Sub-directories including:Serial、networking IC、LCD driverInterrupt initialization
Start.sSetup system stack for jumping to the entry point of C program
Driver For Network Card、CFI Flash、serial and USB…。
Doc U-Boot document
FsU-Boot supported filesystem, such as “jffs2”
P-46/162教育部顧問室PAL聯盟/系統雛型與軟硬體整合設計 第四章:嵌入式軟體架構
4.1 U4.1 U--Boot Directories (2)Boot Directories (2)Examples
For U-Boot executable program examplesHello_world.c, timer.c etc.
IncludeThe “Configs” needed to be modified during porting phase
Lib_xxxXxx: archtecture
NetBootp,nfs,tftp etc.
Post Power on self test
RtcTools
P-47/162教育部顧問室PAL聯盟/系統雛型與軟硬體整合設計 第四章:嵌入式軟體架構
4.1 U4.1 U--Boot Porting ReferencesBoot Porting ReferencesSource codehttp://sourceforge.net/projects/U-BootDULG(The DENX U-Boot and Linux Guide)http://www.denx.de/twiki/bin/view/DULG/ManualU-Boot mail listshttp://lists.sourceforge.net/lists/listinfo/u-boot-usershttp://sourceforge.net/mailarchive/forum.php?forum_id=12898
P-48/162教育部顧問室PAL聯盟/系統雛型與軟硬體整合設計 第四章:嵌入式軟體架構
4.1 Porting/Customizing u4.1 Porting/Customizing u--bootbootFiles familiarization
Architecture (core) specific filesCPU specific filesBoard specific filesCommon to all platforms
General ModificationsBoard specific Source files & MakefilesConfiguration files
Build, Install & Deploy
P-49/162教育部顧問室PAL聯盟/系統雛型與軟硬體整合設計 第四章:嵌入式軟體架構
4.1 U4.1 U--Boot Boot ProcessBoot Boot ProcessInvoke U-BootStarts running from ROMRelocates itself to RAMInitial setup and environment checksLocate the kernel and decompress itCheck CRC of kernelTransfer control to kernel imageKernel boots
P-50/162教育部顧問室PAL聯盟/系統雛型與軟硬體整合設計 第四章:嵌入式軟體架構
4.1 U4.1 U--Boot booting (1)Boot booting (1)Preliminary setup
CPUMemory
Relocate self to RAMInitialize ARM boot
FlashEnvironmentIP & MAC address
P-51/162教育部顧問室PAL聯盟/系統雛型與軟硬體整合設計 第四章:嵌入式軟體架構
4.1 U4.1 U--Boot booting (2)Boot booting (2)Initialize ARM boot (continued)
DevicesConsoleInterruptsEthernet
Boot kernelRead image headerDecompress imageTransfer control to kernel
P-52/162教育部顧問室PAL聯盟/系統雛型與軟硬體整合設計 第四章:嵌入式軟體架構
4.1 U4.1 U--Boot SecurityBoot SecurityOnly knows CRCBasically a sophisticated checksumCRC good for finding random errors in a transmissionLittle protection against malicious attacks
P-53/162教育部顧問室PAL聯盟/系統雛型與軟硬體整合設計 第四章:嵌入式軟體架構
4.1 U4.1 U--Boot Command CategoriesBoot Command CategoriesInformation commandsMemory commandsFlash memory commandsExecution commandsDownloadEnvironment variablesSpecialMiscellaneous
P-54/162教育部顧問室PAL聯盟/系統雛型與軟硬體整合設計 第四章:嵌入式軟體架構
4.1 Some U4.1 Some U--Boot CommandsBoot CommandsHelp:
Print online helpFlinfo:
Print FLASH memory information
Protect:Enable or disable FLASH write
Protection
Erase:Erase FLASH memory
Loadb:Loadb binary file over serial line (kermit mode)
Md:Memory display
Cp:Memory copy
Command usage:Help + commands
P-55/162教育部顧問室PAL聯盟/系統雛型與軟硬體整合設計 第四章:嵌入式軟體架構
4.1 U4.1 U--BootCommandBootCommand Lists (1)Lists (1)
print FLASH memory informationflinfoerase FLASH memoryeraseecho args to consoleechochecksum calculationcrc32memory copycpmemory comparecmpboot default, i.e., run 'bootcmd'bootdboot image via network using BootP/TFTP protocolbootpboot application image from memorybootmprint Board Info structurebdinfoprint or set address offsetbaserun script from memoryautoscrFunctionCommand
P-56/162教育部顧問室PAL聯盟/系統雛型與軟硬體整合設計 第四章:嵌入式軟體架構
4.1 U4.1 U--BootCommandBootCommand Lists (2)Lists (2)
memory write (fill)mwsimple RAM testmtestmemory modify (auto-incrementing)mmmemory displaymdinfinite loop on address rangeloopload S-Record file over serial lineloadsload binary file over serial line (ymodem-g mode)loadgload binary file over serial line (ymodem-c mode)loadcload binary file over serial line (kermit mode)loadbprint header information for application imageiminfoprint online helphelpstart application at address 'addr'goFunctionCommand
P-57/162教育部顧問室PAL聯盟/系統雛型與軟硬體整合設計 第四章:嵌入式軟體架構
4.1 U4.1 U--BootCommandBootCommand Lists (3)Lists (3)
alias for 'help'?print monitor versionversion
boot image via network using TFTP protocol and envvariables ipaddr and serverip
tftpbootdelay execution for some timesleepset environment variablessetenvsave environment variables to persistent storagesaveenvrun commands in an environment variablerunperform RESET of the CPUresetboot image via network using RARP/TFTP protocolrarpbootenable or disable FLASH write protectionprotectprint environment variablesprintenvmemory modify (constant address)nmFunctionCommand
P-58/162教育部顧問室PAL聯盟/系統雛型與軟硬體整合設計 第四章:嵌入式軟體架構
4.1 Examples of U4.1 Examples of U--BOOT Command UsageBOOT Command Usagehelp USBsetenv serverip xxx.xxx.xxx.xxxsetenv ipaddr yyy.yyy.yyy.yyysetenv bootcmd ‘tftp 33000000 uImage_2410; go 33000000tftp: tftp 33000000 uImage_2410go 32000000bootm 33000000mw 33000000 ff 10000nfs 33000000 xxx.xxx.xxx.xxx:aa.txt
P-59/162教育部顧問室PAL聯盟/系統雛型與軟硬體整合設計 第四章:嵌入式軟體架構
4.1 Operation Modes of Boot Loaders4.1 Operation Modes of Boot Loaders1. Boot loading Mode
Autonomous ModeLoading during power on
2. Downloading Mode
P-60/162教育部顧問室PAL聯盟/系統雛型與軟硬體整合設計 第四章:嵌入式軟體架構
4.1 The Downloading mode4.1 The Downloading modeAn alternative of the Boot loading modeThe bootloader often use the following protocols are to connect the Target and Host:
UART Protocol Usually as xmodem, ymodem, zmodemThe speed is limited
TFTP Protocol (network transferring)The Host needs to provide TFTP service
Downloading documents from the HostSuch as the image
P-61/162教育部顧問室PAL聯盟/系統雛型與軟硬體整合設計 第四章:嵌入式軟體架構
4.2 Embedded Operating System4.2 Embedded Operating System4.1 4.1 BootloaderBootloader4.2 Embedded Operating System4.2 Embedded Operating System4.3 Root 4.3 Root FilesystemFilesystem4.4 Graphic User Interface of Embedded system4.4 Graphic User Interface of Embedded system
P-62/162教育部顧問室PAL聯盟/系統雛型與軟硬體整合設計 第四章:嵌入式軟體架構
4.2 Architecture of Embedded Systems4.2 Architecture of Embedded Systems
P-63/162教育部顧問室PAL聯盟/系統雛型與軟硬體整合設計 第四章:嵌入式軟體架構
4.2 4.2 Typical Embedded OTypical Embedded Operating Systemsperating SystemsWindows CE /Mobile WindowsPalm OSEPOCuC/OS-IISymbian OSRTOS:
VxWorks, pSOS…Linux:
uClinux, Montavista Linux, ARM-Linux…
P-64/162教育部顧問室PAL聯盟/系統雛型與軟硬體整合設計 第四章:嵌入式軟體架構
4.2 WinCE Architectures4.2 WinCE Architectures
P-65/162教育部顧問室PAL聯盟/系統雛型與軟硬體整合設計 第四章:嵌入式軟體架構
4.2 Advantages of WinCE4.2 Advantages of WinCEBenefits
Built-in NAND Flash bootloader, SD HostVarious embedded IPDesign time reduction with a supporting reference board & RTOSVarious design applications
Key ApplicationsWireless PDASmartphoneGame machinesPoint-of-Sale terminalsPortable media players
P-66/162教育部顧問室PAL聯盟/系統雛型與軟硬體整合設計 第四章:嵌入式軟體架構
4.2 Memory Map of WinCE4.2 Memory Map of WinCE
64MB physical address and 4GB virtual addressCPU
– MIPS和SHXThe mapping of physical
address is made by CPU– x86和ARM
All physical addresses are mapped to the virtual addresses above 0x80000000Above 0x80000000 is used by kernelBelow 0x80000000 is used by applications
P-67/162教育部顧問室PAL聯盟/系統雛型與軟硬體整合設計 第四章:嵌入式軟體架構
4.2 Memory Allocations4.2 Memory Allocations0x0000 0000~0x41FF FFFF
Used by all applications33 slots, every one is 32MB
Slot0(Slot 0)used by the current ProcessSlot1 is used by XIP DLL(in .NET)Other slot is for Processes,each process use a slotMaximum 32 Processes simultaneously
0x4200 0000~0x7FFF FFFFCommon area of all the applicationsFor creating the stacks, the image documents, and the patch of large space
0xC000 0000~0xC1FF FFFFSystem reserved
0xC200 0000~0xC3FF FFFFUsed by the kernel program nk.exe
0xE000 0000~0xFFFF FFFFVirtual space used by the kernel for configuring a larger virtual space
P-68/162教育部顧問室PAL聯盟/系統雛型與軟硬體整合設計 第四章:嵌入式軟體架構
4.2 Linux Kernel4.2 Linux Kernel
From http://www.xml.com/ldd/chapter/book/bookindexpdf.html (GPL)
P-69/162教育部顧問室PAL聯盟/系統雛型與軟硬體整合設計 第四章:嵌入式軟體架構
4.2 Linux and GNU Roadmap4.2 Linux and GNU Roadmap
P-70/162教育部顧問室PAL聯盟/系統雛型與軟硬體整合設計 第四章:嵌入式軟體架構
4.2 Open Source Model4.2 Open Source Model
P-71/162教育部顧問室PAL聯盟/系統雛型與軟硬體整合設計 第四章:嵌入式軟體架構
4.2 4.2 Open Source Embedded LinuxOpen Source Embedded LinuxEmbedded Debian Project
Convert Debian to an embedded OSETLinux
For PC104 SBC’suCLinux
For microprocessors that don’t have MMuLinux (muLinux)
Distro fits on a single floppy
P-72/162教育部顧問室PAL聯盟/系統雛型與軟硬體整合設計 第四章:嵌入式軟體架構
4.2 4.2 Commercial Embedded Linux (1)Commercial Embedded Linux (1)AMIRIX Embedded Linux
Derived from DebianCoollogic Coollinux
Combines Linux and Java for Internet appsCoventive Xlinux
Kernel can be as small as 143KBEsfia RedBlue Linux
400K, designed for wireless appsKYZO Pizza Box Linux
SAMBA based file, print, CD serverLineo Embedix
Supports real time and high availability appsLynuxWorks BlueCat
General purpose embedded solutionMontaVista Linux
General purpose embedded solution
P-73/162教育部顧問室PAL聯盟/系統雛型與軟硬體整合設計 第四章:嵌入式軟體架構
4.2 4.2 Commercial Embedded Linux (2)Commercial Embedded Linux (2)Neoware NeoLinux
Red Hat derived for information appliancesPalmPalm Tynux
Internet appliuance and multimediaRed Hat Embedded Linux
general purpose embedded solutionRedSonic Red-Ice Linux
runs from DiskonChip or CompactFlashRidgeRun DSP Linux
for multimedia, wireless, RT on DSPTimeSys Linux GPL
low latency enhanced kernelTuxia TASTE
distro targets Internet appliancesVital Systems vLinux
for ARM based embedded apps
P-74/162教育部顧問室PAL聯盟/系統雛型與軟硬體整合設計 第四章:嵌入式軟體架構
4.2 Kernel Space4.2 Kernel SpaceKernel structure
Data structure of ProcessProcess ID, Priority, Status, Registers used, Interrupt, Global variables
Process ManagementUser’s service routines in a forever loop
Time ManagementRequired time delay for interrupt
Inter-process Communication & SynchronizationSemaphores, message boxes, message queues
Memory ManagementMechanism of memory allocation and release
P-75/162教育部顧問室PAL聯盟/系統雛型與軟硬體整合設計 第四章:嵌入式軟體架構
4.2 Kernel Architecture of RTOS4.2 Kernel Architecture of RTOSKernel Primitive
Issue system calls for InterruptsInterfacing the processes to the system
Interrupt Service Routine (ISR)Software interrupt & hardware interrupt
Process SchedulerA dispatcher
First-come-first-serviced Scheduling (FCFS)Priority Scheduling (PS)
PreemptiveNon-preemptive
P-76/162教育部顧問室PAL聯盟/系統雛型與軟硬體整合設計 第四章:嵌入式軟體架構
4.2 Basic Kernel Program4.2 Basic Kernel ProgramSynchronization
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, readyContext switch
P-77/162教育部顧問室PAL聯盟/系統雛型與軟硬體整合設計 第四章:嵌入式軟體架構
4.2 4.2 uCLinuxuCLinux StructureStructure
P-78/162教育部顧問室PAL聯盟/系統雛型與軟硬體整合設計 第四章:嵌入式軟體架構
4.2 Building Linux Kernels4.2 Building Linux KernelsDownload reference kernel
http://www.kernel.orgDownload and apply associated ARM patch
http://www.arm.linux.org.uk/developer/This is applied on unpacked base kernelAdd additional patches as appropriate
Configure the kernel (make xconfig)Choose architecture, development platform, devices and functionality needed
Build the kernelEnsure the right link is set in main Makefile to point at the cross compiler location
P-79/162教育部顧問室PAL聯盟/系統雛型與軟硬體整合設計 第四章:嵌入式軟體架構
4.2 Running Linux kernels4.2 Running Linux kernelsBuilt image is in arch/arm/boot directoryLoading and running the image on the target:
Use BootLoaderEither via network (tftp/bootp) or from flash
Use DebuggerLoad image as raw binary:
(@0x8000 for uncompressed Image)Set platform ID in r1 and initialise r0, r2Disable semi-hosting and vector catchSet pc=0x8000 and run the kernel
P-80/162教育部顧問室PAL聯盟/系統雛型與軟硬體整合設計 第四章:嵌入式軟體架構
4.2 4.2 Building XSBase255B Linux kernelBuilding XSBase255B Linux kernelSetup KernelDirectories and filesSetup Makefile and config.inAdd applications to Kernel
P-81/162教育部顧問室PAL聯盟/系統雛型與軟硬體整合設計 第四章:嵌入式軟體架構
4.2 Kernel Directory Structure4.2 Kernel Directory Structure
P-82/162教育部顧問室PAL聯盟/系統雛型與軟硬體整合設計 第四章:嵌入式軟體架構
4.2 4.2 Description of Kernel Description of Kernel DirectoriesDirectories/usr/src/linux
Kernel directory for target system Sub directories of linux
archkernel programs of all related architecture (arm etc.)
includeHeader files (Our header files is put in asm-arm directory)
initKernel initialized programThe starting point to study kernel functions
mmMemory management related functions
kernelSystem functions of Kernel
driversDevice drivers
libLibraries
How to show kernel versions?Command: uname –r
P-83/162教育部顧問室PAL聯盟/系統雛型與軟硬體整合設計 第四章:嵌入式軟體架構
4.2 Kernel Configuration 4.2 Kernel Configuration Three part of files required1. Makefile2. Config.in3. Configuration tools(圖形介面, 用戶配置…)
P-84/162教育部顧問室PAL聯盟/系統雛型與軟硬體整合設計 第四章:嵌入式軟體架構
4.2 4.2 MakefileMakefile and and config.inconfig.inMakefile
Makefile will recursively enter every sub directory of kernel, and use their Makefile.Include arch/$(ARCH)/Makefile
The assignment of CPU architecturesConfig.in
The script file for system configuration Add the manual item to the Linux configurationMakefile use the arch/arm/config.in (scripts/Configure) to do the configuration.A .config file created after configuration
P-85/162教育部顧問室PAL聯盟/系統雛型與軟硬體整合設計 第四章:嵌入式軟體架構
4.2 Steps of Kernel Configuration4.2 Steps of Kernel Configurationmake configmake oldconfigmake menuconfig
EX: shell>make ARCH=ARM CROSS_COMPILE=arm-linuxmenuconfig
make xconfigX windows menu
P-86/162教育部顧問室PAL聯盟/系統雛型與軟硬體整合設計 第四章:嵌入式軟體架構
4.2 Make 4.2 Make menuconfigmenuconfig環境設置
P-87/162教育部顧問室PAL聯盟/系統雛型與軟硬體整合設計 第四章:嵌入式軟體架構
4.2 System Type4.2 System TypeSelect PXA25x-based CPU
P-88/162教育部顧問室PAL聯盟/系統雛型與軟硬體整合設計 第四章:嵌入式軟體架構
4.2 PCMCIA/4.2 PCMCIA/CardBusCardBus SupportSupport
P-89/162教育部顧問室PAL聯盟/系統雛型與軟硬體整合設計 第四章:嵌入式軟體架構
4.2 Flash Chip Interfaces4.2 Flash Chip InterfacesFor RAM/ROM interface drivers
P-90/162教育部顧問室PAL聯盟/系統雛型與軟硬體整合設計 第四章:嵌入式軟體架構
4.2 Mapping Drivers for CF Card Access4.2 Mapping Drivers for CF Card Access
P-91/162教育部顧問室PAL聯盟/系統雛型與軟硬體整合設計 第四章:嵌入式軟體架構
4.2 Ethernet Options (10 or 1004.2 Ethernet Options (10 or 100--Mbps)Mbps)CS8900 chip support
Support XSCALE PXA255 Ethernet
P-92/162教育部顧問室PAL聯盟/系統雛型與軟硬體整合設計 第四章:嵌入式軟體架構
4.2 Console Drivers4.2 Console DriversSupport for frame buffer devicesPXA LCD support
P-93/162教育部顧問室PAL聯盟/系統雛型與軟硬體整合設計 第四章:嵌入式軟體架構
4.2 4.2 Add Other DriversAdd Other DriversDevice drivers are typically distributed in one of three forms:
A PATCH AGAINST A SPECIFIC KERNEL VERSIONThe most common of all
#cd /usr/src/linux ; patch -p1 < patch_fileA LOADABLE MODULEAN INSTALLATION SCRIPT THAT APPLIES APPROPRIATE PATCHES
Add new functions to KernelThree steps to complete
Put new program into the kernel folderAdd the select item for the configurationCreate Makefile of Sub-directory
P-94/162教育部顧問室PAL聯盟/系統雛型與軟硬體整合設計 第四章:嵌入式軟體架構
4.2 4.2 Step1Step1Add a new folder with the Makefile and config.in to the drivers directory.Modify the config.in of the up layerModify the Makefile of the up layerAssure the initialization function is called
Direct build-in in the kernel folderUse the upload/download mode
P-95/162教育部顧問室PAL聯盟/系統雛型與軟硬體整合設計 第四章:嵌入式軟體架構
4.2 4.2 Step2Step2Drivers/test/Config.in
Arch/arm/config.inAdd the following to the last line
source drivers/test/Config.in
P-96/162教育部顧問室PAL聯盟/系統雛型與軟硬體整合設計 第四章:嵌入式軟體架構
4.2 4.2 Step3Step3Editing the makefile (drivers/test/Makefile)
P-97/162教育部顧問室PAL聯盟/系統雛型與軟硬體整合設計 第四章:嵌入式軟體架構
4.2 Modify the 4.2 Modify the MakefilesMakefilesDrivers/Makefile
Makefile
P-98/162教育部顧問室PAL聯盟/系統雛型與軟硬體整合設計 第四章:嵌入式軟體架構
4.2 4.2 Make KernelMake Kernel$make menuconfig$make dep$make zImage
P-99/162教育部顧問室PAL聯盟/系統雛型與軟硬體整合設計 第四章:嵌入式軟體架構
4.2 Burning the 4.2 Burning the BootloaderBootloader via JTAGvia JTAG./Jflash-XSBASE x-boot255
--------------------------------------------------------------------------------XSCALE-R1Copyright (C) 2004 Chhnet Co,. ltd.Support: http://www.hhnet.com.twAutoboot in progress, press any key to stop .Autoboot abortedType "help" to get a list of commandsXSBASE> ……….--------------------------------------------------------------------------------
P-100/162教育部顧問室PAL聯盟/系統雛型與軟硬體整合設計 第四章:嵌入式軟體架構
4.2 Load the Kernel & 4.2 Load the Kernel & FilesystemFilesystemXSBASE> tftp zImage kernelXSBASE> flash kernelXSBASE> tftp rootfs.img rootXSBASE> flash root
P-101/162教育部顧問室PAL聯盟/系統雛型與軟硬體整合設計 第四章:嵌入式軟體架構
4.2 Target Initialization Sequence4.2 Target Initialization Sequence
P-102/162教育部顧問室PAL聯盟/系統雛型與軟硬體整合設計 第四章:嵌入式軟體架構
4.2 Documentation4.2 DocumentationEmbedded Linux Consortium(ELC)http://www.embedded-linux.org
Linux Deviceshttp://www.linuxdevices.com
Embedded Linux journal(ELJ)http://embedded.linuxjournal.com
P-103/162教育部顧問室PAL聯盟/系統雛型與軟硬體整合設計 第四章:嵌入式軟體架構
4.2 Some Linux Kernel Sites4.2 Some Linux Kernel Sites
ftp,httphttp://www.linux-m68k.org/M68k
cvshttp://linuxsh.sourceforge.net/SuperH
cvshttp://www.linux-mips.org/MIPS
ftp,http,…http://penguinppc.org/PowerPC
ftp,synchttp://www.arm.linux.org.uk/developARM
ftp,http,synchttp://www.kernel.org/X86
DownloadurlProcessor
P-104/162教育部顧問室PAL聯盟/系統雛型與軟硬體整合設計 第四章:嵌入式軟體架構
4.2 ARM Linux kernel (Examples)4.2 ARM Linux kernel (Examples)Originalhttp://www.kernel.org
Patch filehttp://www.arm.linux.org.uk
P-105/162教育部顧問室PAL聯盟/系統雛型與軟硬體整合設計 第四章:嵌入式軟體架構
4.2 Additional open source links4.2 Additional open source linksGnu Debugger
http://www.gnu.org/software/gdb/gdb.htmlLinux Test Project - Test coverage of the kernel
http://ltp.sourceforge.net/Linux Trace Toolkit - Acquire and display kernel trace information
http://www.opersys.com/LTT/Guide to porting Linux on new ARM hardware
http://vega.soi.city.ac.uk/~es728/pdf/aleph.pdfGuide to building Linux system from scratch
http://www.opersys.com/quickref.htmlOther useful resources
http://www.debian.orghttp://www.handhelds.org/
P-106/162教育部顧問室PAL聯盟/系統雛型與軟硬體整合設計 第四章:嵌入式軟體架構
4.3 Root 4.3 Root FilesystemFilesystem4.1 4.1 BootloaderBootloader4.2 Embedded Operating System4.2 Embedded Operating System4.3 Root 4.3 Root FilesystemFilesystem4.4 Graphic User Interface of Embedded system4.4 Graphic User Interface of Embedded system
P-107/162教育部顧問室PAL聯盟/系統雛型與軟硬體整合設計 第四章:嵌入式軟體架構
4.3 Root 4.3 Root FilesystemFilesystem TypesTypes
ynnnyRAMDISK/Ext2
nnyyyNFTL/Ext3
nnnyyNFTL/Ext2nnyyyJFFS
nyyyyJFFS2
nynnnCRAMFS
In RAM
CompressPowerDownreliability
AlwaysWriteFilesystem
NFTL:NAND Flash Transfer Layer
P-108/162教育部顧問室PAL聯盟/系統雛型與軟硬體整合設計 第四章:嵌入式軟體架構
4.3 The 4.3 The cramfscramfs FilesystemFilesystemCramfs
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
P-109/162教育部顧問室PAL聯盟/系統雛型與軟硬體整合設計 第四章:嵌入式軟體架構
4.3 The ext2 4.3 The ext2 FilesystemFilesystemAdvantages:
Support up to 4TB memorySupport 1012 bytes long file namesymbolic link : index table speed up
Disadvantages :IDE device design: 1block=512, 1024, 2048…NAND FLASH not support ERASE/WriteNo balance management
P-110/162教育部顧問室PAL聯盟/系統雛型與軟硬體整合設計 第四章:嵌入式軟體架構
4.3 The JFFS2 4.3 The JFFS2 FilesystemFilesystemJFFS2
A log-structured file system designed for use on flash devices in embedded systems.
FeaturesCompression ratio < cramfsBetter than ext2 in (r/w/erase)Power down no crashIf full slow down performance
P-111/162教育部顧問室PAL聯盟/系統雛型與軟硬體整合設計 第四章:嵌入式軟體架構
4.3 The 4.3 The InitrdInitrd (Initial RAM Disk)(Initial RAM Disk)Initrd
The initial ramdiskIt is a temporary file system used by the Linux kernel during boot.A root filesystem
UsageKernel config options
RAM disk supportInitial RAM disk (initrd) support (CONFIG_BLK_DEV_INITRD)
/dev/ram0
P-112/162教育部顧問室PAL聯盟/系統雛型與軟硬體整合設計 第四章:嵌入式軟體架構
4.3 Linux 4.3 Linux FilesystemFilesystemContains system utilities and applications
Busybox for base utilities (http://www.busybox.net/)Need C library – either Glibc or NewlibAdditional utilities such as:
Sysvinit, shells, ftpd, telnet…Graphical windowing system and applications:
X11 environment: http://www.xfree86.org/Microwindows: http://www.microwindows.org/Qt/Qtopia: http://www.trolltech.com
Access from Flash or via NFSFrom Flash can use cramfs, romfs…
P-113/162教育部顧問室PAL聯盟/系統雛型與軟硬體整合設計 第四章:嵌入式軟體架構
4.3 How to Build Root 4.3 How to Build Root FilesystemFilesystem??LddBuildrootfilesystemCopyOthers tools
P-114/162教育部顧問室PAL聯盟/系統雛型與軟硬體整合設計 第四章:嵌入式軟體架構
4.3 4.3 Other toolsOther toolsBusyBox
http://www.busybox.net/Tinylogin
http://tinylogin.busybox.net/Embutils
http://www.fefe.de/embutils/
P-115/162教育部顧問室PAL聯盟/系統雛型與軟硬體整合設計 第四章:嵌入式軟體架構
4.3 4.3 Samba ServerSamba Server(Linux Host) file share with (Windows Host)Setup (Linux Host)
modify /etc/samba/smb.confadd next 2 lines in smb.conf file
[creator]Path=/usr/src/creator
P-116/162教育部顧問室PAL聯盟/系統雛型與軟硬體整合設計 第四章:嵌入式軟體架構
4.3 4.3 NFS (Network File System)NFS (Network File System)(Linux Host) share folder for (Linux Target) mountSetup(Linux host)
edit /etc/exports file with“/user/src/creator/nfs *(rw,no_root_squash)”edit /etc/host.allow file with“portmap:all”build the kernel with NFS supportmake menuconfig
P-117/162教育部顧問室PAL聯盟/系統雛型與軟硬體整合設計 第四章:嵌入式軟體架構
4.3 Linux NFS v4 Architecture4.3 Linux NFS v4 Architecture
Tony .Tony .ReixReix at at bull.netbull.net
P-118/162教育部顧問室PAL聯盟/系統雛型與軟硬體整合設計 第四章:嵌入式軟體架構
4.3 4.3 FilesystemFilesystem Design ToolsDesign ToolsEasyReliableReal-timeOpen and portableExtensible and configurableOpen architectureResource availableComplete functionality
P-119/162教育部顧問室PAL聯盟/系統雛型與軟硬體整合設計 第四章:嵌入式軟體架構
4.3 MTD Support4.3 MTD Support
P-120/162教育部顧問室PAL聯盟/系統雛型與軟硬體整合設計 第四章:嵌入式軟體架構
4.3 RAM/ROM/Flash Chip Drivers4.3 RAM/ROM/Flash Chip Drivers
P-121/162教育部顧問室PAL聯盟/系統雛型與軟硬體整合設計 第四章:嵌入式軟體架構
4.3 Mapping drivers for chip access4.3 Mapping drivers for chip access
P-122/162教育部顧問室PAL聯盟/系統雛型與軟硬體整合設計 第四章:嵌入式軟體架構
4.3 RAMDISK Support4.3 RAMDISK Support
P-123/162教育部顧問室PAL聯盟/系統雛型與軟硬體整合設計 第四章:嵌入式軟體架構
4.3 4.3 FilesystemFilesystem Format Jffs2Format Jffs2
P-124/162教育部顧問室PAL聯盟/系統雛型與軟硬體整合設計 第四章:嵌入式軟體架構
4.3 4.3 CreatCreat FilesystemFilesystem ImageImageSwitch to the File System folder
Filesystem/Use mkfs.jffs2 tool to pack the folder
./mkfs.jffs2 –o rootfs.img –e 0x40000 –r root_XSBase255B –p -l
P-125/162教育部顧問室PAL聯盟/系統雛型與軟硬體整合設計 第四章:嵌入式軟體架構
4.4 Graphic User Interface of Embedded system4.4 Graphic User Interface of Embedded system4.1 4.1 BootloaderBootloader4.2 Embedded Operating System4.2 Embedded Operating System4.3 Root 4.3 Root FilesystemFilesystem4.4 Graphic User Interface of Embedded system4.4 Graphic User Interface of Embedded system
P-126/162教育部顧問室PAL聯盟/系統雛型與軟硬體整合設計 第四章:嵌入式軟體架構
4.4 Future Multi4.4 Future Multi--mode IA Terminalmode IA Terminal
P-127/162教育部顧問室PAL聯盟/系統雛型與軟硬體整合設計 第四章:嵌入式軟體架構
4.4 4.4 Common Features: Graphic User InterfaceCommon Features: Graphic User Interface
3D Graphics
Typical GUI
HP HP iPAQiPAQ rz1710 Navigatorrz1710 Navigator203 MHz S3C2410
7,0 x 1,3 x 11,4 cm
PDA:PPT 8846
P-128/162教育部顧問室PAL聯盟/系統雛型與軟硬體整合設計 第四章:嵌入式軟體架構
4.4 Embedded System GUI More4.4 Embedded System GUI More
www.cybervision.com.tw/
TinyTiny--X GUI Fundamentals X GUI Fundamentals GUI Builder for Linux: the GladeGUI Builder for Linux: the Glade
P-130/162教育部顧問室PAL聯盟/系統雛型與軟硬體整合設計 第四章:嵌入式軟體架構
Glade and GTK+ Glade and GTK+ What is GTK?
GTK+: GIMP Tool KitGIMP: GNU Image Manipulation Program
GTK+ is a set of Graphical User Interface (GUI) toolGTK+ 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,…
P-131/162教育部顧問室PAL聯盟/系統雛型與軟硬體整合設計 第四章:嵌入式軟體架構
Installation of Installation of ““GladeGlade”” on on XSBase255XSBase255At 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
P-132/162教育部顧問室PAL聯盟/系統雛型與軟硬體整合設計 第四章:嵌入式軟體架構
Installation of Installation of ““gtk+gtk+--develdevel--1.21.2””At the /home/Packages/RPM/ folder, type the command:rpm –ivh gtk+-devel-1.2.10-39.i386.rpm
P-133/162教育部顧問室PAL聯盟/系統雛型與軟硬體整合設計 第四章:嵌入式軟體架構
Start the GladeStart the GladeApplication Menu:
Command lineglade
1
32
Command: glade
P-134/162教育部顧問室PAL聯盟/系統雛型與軟硬體整合設計 第四章:嵌入式軟體架構
The The Start Windows of Glade Start Windows of Glade When Glade started, the following windows is appear
Project Window
Palette Window Properties Window
P-135/162教育部顧問室PAL聯盟/系統雛型與軟硬體整合設計 第四章:嵌入式軟體架構
The Project WindowThe Project WindowIn Glade, the menu bar contains all commands you need to work with
P-136/162教育部顧問室PAL聯盟/系統雛型與軟硬體整合設計 第四章:嵌入式軟體架構
The Palette WindowThe Palette WindowThe palette contains widgets that can be used to build the user interface.
P-137/162教育部顧問室PAL聯盟/系統雛型與軟硬體整合設計 第四章:嵌入式軟體架構
WinCE Develop EnvironmentWinCE Develop Environment
MPEGMPEG--2 Technologies2 TechnologiesMPEGMPEG--2 Decoder Implementation2 Decoder Implementation
P-139/162教育部顧問室PAL聯盟/系統雛型與軟硬體整合設計 第四章:嵌入式軟體架構
MPEGMPEGMPEG ( Motion Picture Experts Group)
Established in 1988A working group of ISO/IEC in charge of the development of standards for coded representation of digital audio and videoMPEG Standards: System, Video, Audio
ProductsMPEG-1: Video CD and MP3 are basedMPEG-2: Digital Television set top boxes and DVDMPEG-4: multimedia for the fixed and mobile webMPEG-7: for description and search of audio and visual content MPEG-21: the Multimedia Framework
Reference siteshttp://www.mpeg.org/http://www.chiariglione.org/mpeg/
P-140/162教育部顧問室PAL聯盟/系統雛型與軟硬體整合設計 第四章:嵌入式軟體架構
MPEG System SpecificationsMPEG System SpecificationsProvide timing information for:
Buffer managementAudio/video synchronization...
Multiplex bit streams of:Audio, video, data and control
Supporting:Access control (security)Program specific informationDigital storage control...
MPEG-2 system applicationsBroadcast digital TV, Cable digital TV, Interactive TV, DVD, ... etc.
P-141/162教育部顧問室PAL聯盟/系統雛型與軟硬體整合設計 第四章:嵌入式軟體架構
H.264/AVC MPEGH.264/AVC MPEG--4 Applications4 Applications
(資料來源:工研院經資中心 經濟部ITIS計畫,2000、資料整理:MIC)
P-142/162教育部顧問室PAL聯盟/系統雛型與軟硬體整合設計 第四章:嵌入式軟體架構
MPEGMPEG--2 Video Compression2 Video CompressionTopics
MPEG Coder/Decoder DiagramProfiles and LevelsFrames, Fields, Pictures (I: Intraframe, P: Predicted, B: Bi-directional)I P B Picture ReorderingPixel PositioningCompression toolsMPEG 2 Video Data Structures
MPEG-2 Toturial Web Sites http://www.bretl.com/mpeghtml/MPEGindex.htm
P-143/162教育部顧問室PAL聯盟/系統雛型與軟硬體整合設計 第四章:嵌入式軟體架構
Basic MPEG Basic MPEG DiagramDiagram
(a) MPEG encoder block diagram
Block of Current Frame
Block of Previous Frame
Vector
Coded Macro-Block
Data
Video signal
+ +
+ -
QDCT
MC
VLC
FrameBuffer
IDCT
IQ
ME
+
+
Motion VectorsCoded
Macro-Block Data
Decoded Video Signal
MC
VLD
FrameMemory
(b) MPEG decoder block diagram
IDCTIQ +BUF
P-144/162教育部顧問室PAL聯盟/系統雛型與軟硬體整合設計 第四章:嵌入式軟體架構
Profiles and Levels of MPEGProfiles and Levels of MPEG--22MPEG-2 is divided into several profiles, the Main profile features are:
4:2:0 chroma sampling formatI, P, and B picturesNon-scalable
Main Profile is subdivided into levelsMP@ML (Main Profile Main Level)MP@HL (Main Profile High Level)ATSC
P-145/162教育部顧問室PAL聯盟/系統雛型與軟硬體整合設計 第四章:嵌入式軟體架構
Levels of Main ProfileLevels of Main ProfileMP@ML (Main Profile Main Level)
Designed with CCIR601 standard for interlaced standard definition digital video in mind.This is the output of current standard definition MPEG-2 decoder chips (DSS).Upper bound:
720 x 576 (PAL) or 720 x 483 (NTSC)30 Hz progressive, 60 Hz interlacedMaximum bit rate is 15 Mbits/s
MP@HL (Main Profile High Level)Upper bounds:
1152 x 1920, 60Hz progressive80 Mbits/s
P-146/162教育部顧問室PAL聯盟/系統雛型與軟硬體整合設計 第四章:嵌入式軟體架構
ATSC Compliant Formats for MPEGATSC Compliant Formats for MPEG--221080 x 1920
1080i: 60 Hz interlaced1080p: 30 Hz progressive
480 x 70460 Hz progressive/interlaced30 Hz progressive
720 x 1280720i: 60 Hz interlaced720p: 30 Hz progressive
480 x 64060 Hz progressive/interlaced30 Hz progressive
P-147/162教育部顧問室PAL聯盟/系統雛型與軟硬體整合設計 第四章:嵌入式軟體架構
ChromaChroma SubsamplingSubsamplingEncoding images by implementing more resolution for luminanceinformation than for color informationTypes of subsampling:(Luma [Y] : Chroma [Cb] : Chroma [Cr])
8:4:4 Y'CbCr4:4:4 Y'CbCr4:4:4 R'G'B' (no subsampling)4:2:24:2:14:1:14:2:04:1:03:1:1
P-148/162教育部顧問室PAL聯盟/系統雛型與軟硬體整合設計 第四章:嵌入式軟體架構
Encoded pictures: I, P, B FramesEncoded pictures: I, P, B FramesI frame
An MPEG picture that is intra coded, i.e. not coded differentially with respect to other pictures
P framePredicted PicturesMacroblocks may be coded with forward prediction from references made from previous I and P pictures or may be intra coded
B frameBi-directionally predicted picturesMacroblocks may be coded with:
Forward/backward prediction from previous/next I or P referencesPrediction from next I or P referenceInterpolated prediction from past and future I or P referencesIntra coded (no prediction)
P-149/162教育部顧問室PAL聯盟/系統雛型與軟硬體整合設計 第四章:嵌入式軟體架構
Frames, FieldsFrames, Fields, Pictures, PicturesGroup of Pictures (GOP)
The group of pictures layer is optionalFirst encoded picture in a GOP is always an I pictureTypical length is 15 pictures with the following structure:
I B B P B B P B B P B B P B BFrame Fields
Non-interlace:2 fields of a frame is encoded together as a frame picture
Interlace:A frame is encoded with two Fields
P-150/162教育部顧問室PAL聯盟/系統雛型與軟硬體整合設計 第四章:嵌入式軟體架構
Mpeg2 Encode ProfilingMpeg2 Encode Profiling
14%Other kernels1%Variable length encoding1%Quantisation1%Predication2%Subsampling9%Discrete cosine transform
71%Motion estimation (dist1)% exe timeOperation
P-151/162教育部顧問室PAL聯盟/系統雛型與軟硬體整合設計 第四章:嵌入式軟體架構
Execution profile of mpeg2decodeExecution profile of mpeg2decode
P-152/162教育部顧問室PAL聯盟/系統雛型與軟硬體整合設計 第四章:嵌入式軟體架構
MPEG2 Encoding TechnologiesMPEG2 Encoding Technologies
http://www.tomshw.it/guides/graphic/20040414/images/mpeg2-encoding.jpg
P-153/162教育部顧問室PAL聯盟/系統雛型與軟硬體整合設計 第四章:嵌入式軟體架構
MPEG2 Decoding TechnologiesMPEG2 Decoding Technologies
P-154/162教育部顧問室PAL聯盟/系統雛型與軟硬體整合設計 第四章:嵌入式軟體架構
FilesystemFilesystem Directories for XSBaseDirectories for XSBase--255 Lab255 Lab
Filesystem folder
P-155/162教育部顧問室PAL聯盟/系統雛型與軟硬體整合設計 第四章:嵌入式軟體架構
Steps of Making MPEGSteps of Making MPEG--2 Decoder for XSBase2 Decoder for XSBase--2525Download the mpeg2_modify.tar.gzUnpack
tar –zxvf mpeg2_modify.tar.gzMake the files
makeDownload the exection file “mpeg2decode” from mpeg2/src/mpeg2dec forder to the XSBASE-255 target
P-156/162教育部顧問室PAL聯盟/系統雛型與軟硬體整合設計 第四章:嵌入式軟體架構
MakefileMakefile ModificationsModificationsmpeg2/src/mpeg2dec/Makefile
CC = arm-linux-gccAdd yuv2rgb.o to OBJ item
Add yuv2rgb.o : yuv2rgb.c config.h global.h mpeg2dec.h relationUse LIBS for hybus installation folder, and use the libX11.a library
mpeg2/src/mpeg2dec/display.cInitialize_Display_Processes()
Use the DefaultVisual and the DefaultDepth to get the related information of the screenExploit the XCreateColormap to create the color mappingNeglect the XMatchVisualInfo
Adjust the color depth of XShmCreateImage to be 16 bitIt needs double space of memory allocation for XCreateImageAt the Initialize_Dither_Matrix(), adding the InitColorDither()In the Dither(), replace the Dither_Frame to the Color16DitherImage()
mpeg2/src/mpeg2dec/yuv2rgb.cThe color space conversion of YUV to RGB (16-bit)
P-157/162教育部顧問室PAL聯盟/系統雛型與軟硬體整合設計 第四章:嵌入式軟體架構
Run mpeg2decoderRun mpeg2decoder$ ./mpeg2decode –o4 –b foreman.m2v
o output format0: YUV1: SIF2: TGA3: PPM4: X115: X11 HiQ
P-158/162教育部顧問室PAL聯盟/系統雛型與軟硬體整合設計 第四章:嵌入式軟體架構
Result in Target LCD DisplayResult in Target LCD DisplayOn the target TFT-LCD panel display, the result of “mpeg2decoder”video is demonstrated.
P-159/162教育部顧問室PAL聯盟/系統雛型與軟硬體整合設計 第四章:嵌入式軟體架構
Example: DIGITAL AV MPEG2 DecoderExample: DIGITAL AV MPEG2 Decoder
www.am.necel.com/common/images/block_d6113x.gif
NEC: uPD61132NEC: uPD61132
P-160/162教育部顧問室PAL聯盟/系統雛型與軟硬體整合設計 第四章:嵌入式軟體架構
MB86V00 / MB86V01 Block Diagram (MPEG4)MB86V00 / MB86V01 Block Diagram (MPEG4)
FujitsuFujitsu
P-161/162教育部顧問室PAL聯盟/系統雛型與軟硬體整合設計 第四章:嵌入式軟體架構
MPEG4: Power Reduction TechniquesMPEG4: Power Reduction TechniquesAlgorithmic Breakthrough to Reduce the Volume of Executions
Scene adaptive-motion estimation algorithm to reduce execution volume to 1/10 or less
Adaptive Clock GatingAutomatic clock gating for each individual internal block according to the operation mode
Complete Hard-wired LogicFull compliant of MPEG-4 simple profile
P-162/162教育部顧問室PAL聯盟/系統雛型與軟硬體整合設計 第四章:嵌入式軟體架構
Comparison of MPEG4 VideoComparison of MPEG4 Video--Codec Power Dissipation Codec Power Dissipation
QCIF 15fps full-duplexcodecARM9 Software Operation drives all internal logic and external SDRAM at 108MHz. (SDRAM:3.3V)Media Accelerator drives all internal logic and external SDRAM at 38.1MHz (SDRAM: 1.8V)Dedicated MPEG4 Codec drives all internal logic and external SDRAM at 13.5MHz (SDRAM: 1.8V)
Fujitsu Microelectronics America, Inc.