Post on 14-May-2018
Embedded Systems KUT1-1
Embedded Systems
Prof. Myung-Eui Lee (A-405)melee@kut.ac.kr
Embedded Systems KUT1-2
Boot loader
Boot loader ( & Monitor )» JTAG : Debug, Flash write» make» gcc» Binary utilities» Linker» Linker script file» Object file : Executable and Linking Format(ELF)» Boot loader make example» start.S source» ARM : mode, register, instruction» Boot loader source
Kernel compile Root file system
Embedded Systems KUT1-3
JTAG
JTAG (Joint Test Action Group) » Boundary scan = IEEE Standard 1149 = JTAG» IEEE Standard 1149.1
Standard Test Access Port and Boundary-Scan Architecture» JTAG committee was formed by test professionals within
Philips, BT, GEC and others in 1990» JTAG was standardized in 1990 as the IEEE Std. 1149.1-
1990» Objectives
Circuit test for the surface mount designs and printed circuit boards using boundary scan
Interconnection test between Integrated Circuits (ICs) installed on boards (modules)
→ could not so easily be probed by testers
» Embedding test cells within a device Examine internal board states without physical contact Program PLDs and Flash memories
Embedded Systems KUT1-4
JTAG
Conventional Board Test vs Boundary Scan Idea
Embedded Systems KUT1-5
JTAG
Basic Architecture » Test Access Port (TAP) : JTAG interface (4/5 pin)
TDI, TDO, TCK, TMS(Test Mode Select), TRST (optional)» Instruction Register
Receives an instruction through the TDI, decodes it, and selects the appropriate data register
Sets the mode of operation(TMS) for one or more data registers» Data Registers
Several different data registers can be built into boundary-scan components
→ Boundary scan reg./ Bypass reg./ Dev ID reg./ User defined reg.,,,, Two Data Registers are always required to be present on a 1149.1
component: → Boundary-Scan Register : Boundary Scan Cell (BSC)→ Bypass Register : short-cut scan path through devices that are not
involved in the test (Bypass instruction) » TAP Controller
Generates internal control signals, 16-state finite state machine 4 groups (16 states) : Reset, BIST, Data reg. update, Inst. Reg. update
Embedded Systems KUT1-6
JTAG
JTAG Components » Test Access Port (TAP)
TDI,TCK,TMS,TRST,TDO» Instruction Register» Data Registers :
Boundary Scan Cell (BSC) Bypass Register
» TAP ControllerInternal Logic
BSC
BSC
BSC
BSC
Bypass Reg.(Data Reg.)
TAP Controller
Instruction Reg.
Mux
TDOTRSTTMSTCKTDI
BSC
Embedded Systems KUT1-7
JTAG
BSC 4 different functional modes 1. Normal mode : Mode = 0 2. Update mode : Mode = 1 3. Capture mode : Shift/Load = 0 4. Scan Mode : Shift/Load = 1
DFF
QA
DFF
QAMPX
0
1
MPX
0
1
Data ln
Serial In Shift/LoadClock Update Mode
Data Out
Serial Out
DFF
QA
DFF
QAMPX
0
1
MPX
0
1
Data ln
Serial In Shift/LoadClock Update Mode
Data Out
Serial Out
Embedded Systems KUT1-8
JTAG
Host PC Interface : JTAG Cable (printer or usb)Host (PC) Parallel Port
TDO
TCK
TDI
TMS
nTRST
D0
D1
D3
D4
D5
D6
D7
D2
C1
C2
C3
C0
S3
S6
S7
S5
S4
BASE_ADDRESS : Data Register
Address Decoder
BASE_ADDRESS + 2 : Control Register
BASE_ADDRESS + 1 : Status Register
BASE_ADDRESS278 : LPT1378 : LPT23BC : LPT3
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
D0
D2D1
D3
D7
BUSY
C0C1C2C3
S7
Data register
Control register
Status register
TCK D0 LPT pin 2TDI D1 LPT pin 3 TMS D2 LPT pin 4nTRST D3 LPT pin 5TDO BUSY LPT pin 11
Embedded Systems KUT1-9
Debug
Challenges» Target system may be hard to observe» Target may be hard to control» May be hard to generate realistic inputs» Setup sequence may be complex
Tools» Logic Analyzers» Software Debuggers
Monitor Program Breakpoint Program
» In-circuit Emulators (ICE)» ARM’s EmbeddedICE» IDE (Integrated Development Environment)
Embedded Systems KUT1-10
Debug
» Logic Analyzers Used for sampling many different signals simultaneously, and display
0, 1, or changing values for each. Only offer an historical view of the action of code User cannot change variables or jump to different parts of the
program Useful to measure time intervals Fixed amount of buffer memory
→ relates to the depth of the time window for acquiring system execution history in real-time (measure in number of samples it can hold).
→ the deeper the memory, the more data you have to analyze to find the cause of the problem.
» Software Debuggers Monitor
→ A monitor program residing on the target provides basic debugging functions
→ The need to have the monitor in ROM on the target system is a significant problem
» Must either be removed from the final product» Or left in ROM at extra cost
Embedded Systems KUT1-11
Debug
Break point → A breakpoint allows the user to stop execution, examine system state,
and change state→ Replace the breakpoint instruction with a subroutine call to the monitor
program
» In-circuit Emulators (ICE) Interface
→ Host PC : RS232, Parallel Port (Printer), USB, LAN (Ethernet)→ Target : CPU replacement, JTAG, Proprietary
A microprocessor in-circuit emulator is a specially-instrumented microprocessor
Allows you to stop execution, examine CPU state, modify registers ICE is a dedicated hardware for a particular microprocessor
(different processor/different processor module or pod) ICE can be expensive
Embedded Systems KUT1-12
Debug
ICE Example
Device Adapter
Host Cable
Emulator Pod
ProcessorModule
Device Socket
Embedded Systems KUT1-13
Debug
» ARM’s EmbeddedICE JTAG-based debugging channel for ARM microprocessors An EmbeddedICE-compatible ARM core with a boundary scan
interface and debug enhancements An external EmbeddedICE Interface Box which links the host
development machine with the debug compatible ARM No target resources or special hardware Low cost solution that does not require dedicated ICE Debug can be performed at full processor speed Full host system access including screen, keyboard and storage for
the target Requires no extra communication channel to debug Host software development and debug tools -> RealView Multi ICE
» IDE (Integrated Development Environment)
Embedded Systems KUT1-14
Flash Fusing
Application S/W : /pxa270/jflashmm/jflashmm-5.01.007-h2
Boot loader source : /pxa270/bootloader/bboot-1.0.1
Boot loader fusing» cd /pxa270/bootloader/bboot-1.0.1» make clean, make» ./jflashmm pxa27x32.dat boot
PXA270FlashMemory
jflashmm
Host
Parallel cable
JTAG interface
Line Driver3.3v↔5.0v
123Boot
LoaderDownload
Registers TAP
Chip74HC541
bootboot
JTAG pin
Embedded Systems KUT1-15
Flash Fusing
Using tftp and flash at boot monitor» cd /pxa270/bootloader/bboot-1.0.1/src (host)» vi main.c <- logo change
» cd ..» make» cp boot /tftpboot» tftp boot loader (target)» flash loader
Embedded Systems KUT1-16
Overview of source translation
Library Files
Object Files
Assembly Source
Files
C/C++ Source and Header
FilesMakefile
C Source and HeaderFiles .c .h
Assembly Source Files .S
Linker Command File .lds
User-created files
preprocessor
compiler gcc assembler as
Make Utility make
Object Files
Shared Object
File
Linkable Image File
Executable Image File
Link Map File
Linker and Locator ldLibrary Files
Archive Utility ar
Embedded Systems KUT1-17
GNU toolchains
GNU toolchains» GNU Compiler : gcc» GNU C Library » GNU Binary Utilities
ld, as, ar, gdb, make, objcopy, objdump, readelf, …
GNU Binutils» make – flexible rule-based project builder which helps
maintaining large software systems» ar – create and maintain archives (libraries)» objdump – extract and display information from an
object file : slide #33, #34» objcopy –translate object files to a different format :
slide #42 ( from ELF to Binary or ihex)
Embedded Systems KUT1-18
gcc
gcc hello.c» compile hello.c, produce executable a.out
gcc -o hello hello.c (gcc hello.c -o hello)» compile hello.c, produce executable hello
gcc -o hello hello.c func-a.c func-b.c...» compile hello.c func-a.c and func-b.c, … produce
executable hello gcc -c hello.c copy hello.c to funcs.c and change main() to myfunc()
gcc -c funcs.cgcc -o hello hello.o funcs.o» produce an object file to be linked in later to an executable
ar rc mylib.a funcs.oar t mylib.a
gcc –shared -o hello.so hello.c file hello.o & hello.so
Embedded Systems KUT1-19
gcc
Basic options : refer to gcc manual p.21» -g : include debugging symbols in the output» -l<name> : include a library called libname.a» -I<path> : look for include files in this directory» -L<path> : look for library files in this directory
Define» set preprocessor defines on the command linegcc -DDEBUG -o prog prog.c» conditional parts based on define#ifdef DEBUGprintf(“value of var is %d”, var);#endif
Embedded Systems KUT1-20
make
Reads a file called makefile or Makefile, which contain rules for building a “target”
make automates this process» Type commands to compile all the files correctly each
time» Keep track of which files have been changed» Keep track of files’ dependencies on other files
Types of lines in Makefiles : refer to make manual» Dependencies » Commands» Macro assignments» Special variables in Command line» Suffix rules» Comments ( begin with a ‘#’)
Embedded Systems KUT1-21
make
Dependencies / Commands» Specify a target and a list of prerequisites (optional) for
that target» Command lines must start with a TAB
target : prereq1 prereq2 prereq3 …command1command2
» prog : main.c func-a.c func-b.cgcc -o prog main.c func-a.c func-b.c
» More detail prog : main.o func-a.o func-b.o
gcc -o prog main.o func-a.o func-b.omain.o : main.c
gcc -c main.cfunc-a.o : func-a.c
gcc -c func-a.cfunc-b.o : func-b.c
gcc -c func-b.c
Embedded Systems KUT1-22
make
Macros» Represent other text in a Makefile» Assignment : MACRONAME = macro value» Usage : ${MACRONAME}
OBJS = main.o func-a.o func-b.oCC = /usr/bin/gccprog : ${OBJS}
${CC} -o $@ ${OBJS}main.o : main.c
${CC} -c $?func-a.o : func-a.c
${CC} -c $?func-b.o : func-b.c
${CC} -c $?
Embedded Systems KUT1-23
make
Build-in macros : make -p» CC, AR, AS, LD, CXX» CFLAGS, CXXFLAGS - compiling flags (options) : slide #37» LDFLAGS, ASFLAGS - linking, assembler flags» .SUFFIXES - store suffixes (make –p | grep .SUFFIXES)
.out .o .c .cpp …..
Special variables in commands:» $@ represents the target» $? represents the prerequisite that are newer than target» $< represents the prerequisite file name in a suffix rule
Refer to Slide #24» $$ represents the process number of current shell
Embedded Systems KUT1-24
make
Suffix rules» Still tedious to specifically tell make how to build each .o
file from a .c file» Default suffix rule turns .c files into .o files by running the
command: gcc -c $<» .SUFFIXES: .o .c - store suffixes in the .SUFFIXES macro» .c.o: (make –p | grep .c.o)
gcc -c $< - rule for generating *.o from *.c» %.o: %.c
gcc -c $< - %.c means every file with suffix .c» Final Makefile using suffix
OBJS = main.o func-a.o func-b.oCC = /usr/bin/gccprog : ${OBJS}
${CC} -o $@ ${OBJS}%.o: %.c
${CC} -c $<
2 ways
Embedded Systems KUT1-25
make
Invoking make» make : builds the first target in the file» make target : builds target
Make options:» -n : don’t run the commands, just list them» -f file : use file instead of Makefile or makefile
clean node (Label)» Usually to remove unnecessary files
clean:rm -f *.o
» make clean» make proper: make clean + remove dot config file(.depend)
all node» Include a target to build multiple programs
all: prog1 prog2 prog3» By default make command would execute all node
Embedded Systems KUT1-26
Linker
Object file : gcc –c hello.c → hello.o The linker combines object modules which may be
available in a variety of file formats» Executable and Linking Format (ELF) : de facto standard
» Common Object File Format (COFF) : former binary format
» Debug With Arbitrary Record Format (DWARF) : Debug Information Format
.bss1.data1
.text1
Linkable file 1
.bss2.data2
.text2
.bss
.data
.text
Linkable file 2
Embedded Systems KUT1-27
Linker
The most important sections» .text - contains code and constants » .data - initialized data» .bss - un-initialized data (block starting at symbol, block started by
symbol, block start symbol, blank storage space, block storage segment)
Give a name to the beginning of a block of data» .rodata - ROM variables» .common - shared overlayed data sections» .vector - interrupt vector table » .got – global offset table
stores the final (absolute) location of a function calls symbol, used in dynamically linked code
located in the .got section of an ELF executable or shared object » .comment - documenting comments
Embedded Systems KUT1-28
Segment
Segments : Segmented memory» A technique used in computer hardware to divide
memory up into smaller, more manageable units » Memory segments are managed by a memory
management unit (MMU), under operating system control
Sections vs Segments refer to slide #30» Sections : Linker» Segments : OS (MMU)
Embedded Systems KUT1-29
Program’s Address Space
A program’s address space is defined by linker and operating system
variables sections .text .rodata .data .bss stack
global
staticinitialized ∨
non-initialized ∨
non-static(auto)
initialized ∨
non-initialized ∨
const define ∨
local
staticinitialized ∨
non-initialized ∨
non-static(auto)
initialized ∨
non-initialized ∨
const define ∨
Embedded Systems KUT1-30
ELF file
Four major parts in an ELF file» ELF header
Virtual Memory Entry Point Program header table file offset Section header table file offset
» Program header Describe segments directly related to
program loading Program header is for ELF loader in Linux
kernel» Section header
Describe contents of the file Section header is for linker
» Data itself .text, .rodata, .data, .bss
Section header table
.bss
.data
.rodata
.text
Programheader table
ELF header
seg. 0
seg. 1
Embedded Systems KUT1-31
ELF file
3 types of ELF» Relocatable (*.o) for linker –file hello.o not stripped for debug
» Executable (*. no attribute) for loader : running –file hello» Shared object (*.so) : dynamic linking –file hello.so
Shared / Static Library» shared : .so
malloc(), free() – runtime memory allocation
dll : dynamic linking lib. – runtime lib. linking
» static : .a ar –t /usr/lib/libc.a : archive manager
app.app. app.app.
lib. lib.
shared static
Program header Section header
Relocatable ∨
Executable ∨ ∨
Shared object ∨ ∨
gcc –shared -o hello.so hello.c
*Stripped gcc –s –o hello.s hello.c file hello.s
Embedded Systems KUT1-32
ELF header
/usr/src/linux-2.4.20-8/include/linux/elf.htypedef struct elf64_hdr {unsigned char e_ident[16]; /* ELF "magic number" */Elf64_Half e_type;Elf64_Half e_machine;Elf64_Word e_version;Elf64_Addr e_entry; /* Entry point virtual address */Elf64_Off e_phoff; /* Program header table file offset */Elf64_Off e_shoff; /* Section header table file offset */Elf64_Word e_flags;Elf64_Half e_ehsize;Elf64_Half e_phentsize;Elf64_Half e_phnum;Elf64_Half e_shentsize;Elf64_Half e_shnum;Elf64_Half e_shstrndx;} Elf64_Ehdr;
Embedded Systems KUT1-33
ELF Program header
/usr/src/linux-2.4.20-8/include/linux/elf.h
Program header» objdump –p hello-x86
typedef struct elf64_phdr {Elf64_Word p_type;Elf64_Word p_flags;Elf64_Off p_offset; /* Segment file offset */Elf64_Addr p_vaddr; /* Segment virtual address */Elf64_Addr p_paddr; /* Segment physical address */Elf64_Xword p_filesz; /* Segment size in file */Elf64_Xword p_memsz; /* Segment size in memory */Elf64_Xword p_align; /* Segment alignment, file & memory */
} Elf64_Phdr;
Embedded Systems KUT1-34
ELF Section header
/usr/src/linux-2.4.20-8/include/linux/elf.h
Section Information» objdump –h hello.o
typedef struct elf64_shdr {Elf64_Word sh_name; /* Section name, index in string tbl */Elf64_Word sh_type; /* Type of section */Elf64_Xword sh_flags; /* Miscellaneous section attributes */Elf64_Addr sh_addr; /* Section virtual addr at execution */Elf64_Off sh_offset; /* Section file offset */Elf64_Xword sh_size; /* Size of section in bytes */Elf64_Word sh_link; /* Index of another section */Elf64_Word sh_info; /* Additional section information */Elf64_Xword sh_addralign; /* Section alignment */Elf64_Xword sh_entsize; /* Entry size if section holds table */
} Elf64_Shdr;
Embedded Systems KUT1-35
Section Information
LMA / VMA» LMA (load memory address): the address at which a
section will be loaded» VMA (virtual memory address): the runtime address of a
section» In most cases the two addresses will be the same» An example of different
a data section is loaded into ROM, and then copied into RAM when the program starts up
Embedded Systems KUT1-36
Linker script
Linker script : slide #43» The originally UNIX based GNU gcc compiler has been
ported to a large number of environments» gcc does not define memory models but instead works
with linker script files» Linker script files describe the which sections will be part
of the final program and in which order they appear» Define additional symbols for use in your code» Built-in default linker script which commonly works for
the majority of simple applications ld –verbose
» The most important sections are .text, .data, .bss,.common, .vector, and .comment
» ‘.’ is the VMA location counter, which always refer to the current location in a output object
» ‘*’ is a wildcard to match the filenames of all input objects
Embedded Systems KUT1-37
boot loader/monitor
1. Makefile in bboot-1.0.1 directoryCROSS = /opt/iwmmxt-1.0.0/bin/arm-linux-CC = $(CROSS)gccOBJCOPY = $(CROSS)objcopyCFLAGS = -Wall -O2 -nostdinc -fomit-frame-pointer -fPIC -fno-strict-aliasing -mstructure-size-boundary=8
-mcpu=xscale -mtune=xscaleexport CC OBJCOPY CFLAGS
HOSTCC = gccexport HOSTCC
TOPDIR := $(shell if test -n $$PWD; then echo $$PWD; else pwd; fi)HPATH := $(TOPDIR)/includeexport TOPDIR HPATH
BOOTADDR = $(shell utils/bootaddr) # shell script to get BOOTADDR at include/board.hexport BOOTADDR # define BOOTADDR 0xA3F00000 include/board.h
include config # myipaddr=192.168.100.50 / destipaddr=192.168.100.100 at config file
#.SILENT :all : setup
make -C src
clean :make clean -C srcmake clean -C utils
proper :make proper -C src
Embedded Systems KUT1-38
boot loader/monitor
Note:» test –n STRING : the length of STRING is nonzero» test –x FILE : FILE exists and is executable» patsubst PATTERN, REPLACEMENT, TEXT
Finds whitespace-separated words in text that match pattern and replaces them with replacement.
Pattern may contain a `%' which acts as a wildcard, matching any number of any characters within a word.
dep :make dep -C src
setup : utils/inetaddr configperl -pi -e "s/(\.myipaddr =)[^\n]*/\$\1 `utils/inetaddr $(myipaddr)`,/" src/setup.cperl -pi -e "s/(\.destipaddr =)[^\n]*/\$\1 `utils/inetaddr $(destipaddr)`,/" src/setup.c
perl -pi -e "s/(\.myhaddr =)[^\n]*/\$\1 `utils/macaddr `,/" src/setup.cperl -pi -e "s/(\.sid =)[^\n]*/\$\1 `utils/setupid `,/" src/setup.c
utils/inetaddr :make -C utils ; slide #45 macaddr, setupid, inetaddr Compile
Embedded Systems KUT1-39
Immediate / Deferred
Immediate / Deferred : make manual p.18» immediate := immediate
It happens to the first phase. Make will expand any variables or functions in that section of a construct as the makefile is parsed.
» immediate = deferred Expansion is not performed immediately. Expansion of deferred
construct is not performed until either the construct appears later in an immediate context, or until the second phase.
GNU make : two distinct phases» First phase
reads all the makefiles, included makefiles, … internalizes all the variables and their values, implicit and explicit
rules, .. constructs a dependency graph of all the targets and their
prerequisites. » Second phase
uses these internal structures to determine what targets will need to be rebuilt and to invoke the rules necessary to do so.
Embedded Systems KUT1-40
boot loader/monitor
Makefile : capturemake -C utils
make[1]: Entering directory `/pxa270/bootloader/bboot-1.0.1/utils'
gcc -Wall -O6 -s -o macaddr macaddr.c
gcc -Wall -O6 -s -o setupid setupid.c
gcc -Wall -O6 -s -o inetaddr inetaddr.c
make[1]: Leaving directory `/pxa270/bootloader/bboot-1.0.1/utils'
perl -pi -e "s/(\.myipaddr =)[^\n]*/\1 `utils/inetaddr 192.168.100.50`,/" src/setup.c
perl -pi -e "s/(\.destipaddr =)[^\n]*/\1 `utils/inetaddr 192.168.100.100`,/" src/setup.c
perl -pi -e "s/(\.myhaddr =)[^\n]*/\1 `utils/macaddr`,/" src/setup.c # random number
perl -pi -e "s/(\.sid =)[^\n]*/\1 `utils/setupid`,/" src/setup.c # random number
make -C src
make[1]: Entering directory `/pxa270/bootloader/bboot-1.0.1/src'
echo "compile start.S"
compile start.S
/opt/iwmmxt-1.0.0/bin/arm-linux-gcc -Wall -O2 -nostdinc -fomit-frame-pointer -fPIC -fno-strict-aliasing -mstructure-size-boundary=8 -mcpu=xscale -mtune=xscale -o start.o -c start.S -I/pxa270/bootloader/bboot-1.0.1/include -D__ASSEMBLY__ -include config.h
echo "compile memsetup.S"
compile memsetup.S
/opt/iwmmxt-1.0.0/bin/arm-linux-gcc -Wall -O2 -nostdinc -fomit-frame-pointer -fPIC -fno-strict-aliasing -mstructure-size-boundary=8 -mcpu=xscale -mtune=xscale -o memsetup.o -c memsetup.S -I/pxa270/bootloader/bboot-1.0.1/include -D__ASSEMBLY__ -include config.h
setup.cstatic struct setup_t __bsetup _setup = {
.sid = 0x13cc66eb,
.size = (uint32)&loader_size,
.myipaddr = 0x3264a8c0,
.destipaddr = 0x6464a8c0,
.myhaddr = {0x00,0x08,0xc9,0x62,0x5a,0xeb},
.autoboot = "load kernel; boot",};
Embedded Systems KUT1-41
boot loader/monitor
echo "compile setup.c"compile setup.c/opt/iwmmxt-1.0.0/bin/arm-linux-gcc -Wall -O2 -nostdinc -fomit-frame-pointer -fPIC -fno-strict-aliasing -mstructure-size-boundary=8 -mcpu=xscale -mtune=xscale -o setup.o -c setup.c -I/pxa270/bootloader/bboot-1.0.1/include -include config.h -include types.hecho "compile memcpy.S"compile memcpy.S/opt/iwmmxt-1.0.0/bin/arm-linux-gcc -Wall -O2 -nostdinc -fomit-frame-pointer -fPIC -fno-strict-aliasing -mstructure-size-boundary=8 -mcpu=xscale -mtune=xscale -o memcpy.o -c memcpy.S -I/pxa270/bootloader/bboot-1.0.1/include -D__ASSEMBLY__ -include config.h………….………….
echo "compile main.c"compile main.c/opt/iwmmxt-1.0.0/bin/arm-linux-gcc -Wall -O2 -nostdinc -fomit-frame-pointer -fPIC -fno-strict-aliasing -mstructure-size-boundary=8 -mcpu=xscale -mtune=xscale -o main.o -c main.c -I/pxa270/bootloader/bboot-1.0.1/include -include config.h -include types.hecho "compile time.c“/opt/iwmmxt-1.0.0/bin/arm-linux-gcc -Wall -O2 -nostdinc -fomit-frame-pointer -fPIC -fno-strict-aliasing -mstructure-size-boundary=8 -mcpu=xscale -mtune=xscale -o linux.o -c linux.c -I/pxa270/bootloader/bboot-1.0.1/include -include config.h -include types.h………….………….echo "compile pxafb.c"compile pxafb.c/opt/iwmmxt-1.0.0/bin/arm-linux-gcc -Wall -O2 -nostdinc -fomit-frame-pointer -fPIC -fno-strict-aliasing -mstructure-size-boundary=8 -mcpu=xscale -mtune=xscale -o pxafb.o -c pxafb.c -I/pxa270/bootloader/bboot-1.0.1/include -include config.h -include types.hsed -e "s/BOOTADDR/0xa3f00000/" boot.lds.in > boot.lds
Embedded Systems KUT1-42
boot loader/monitor
………….………….
echo "create boot"create boot/opt/iwmmxt-1.0.0/bin/arm-linux-gcc -static -nostdlib -T boot.lds -o boot.elf32 start.o memsetup.o setup.o memcpy.o fixgpio.o partition.o main.o time.o string.o command.o stdio.o vsprintf.o ctype.o cmddebug.o gpio.o ieb.o network.o bootp.o tftp.o cs8900.o flash.o serial.o xmodem.o linux.o pxafb.o /opt/iwmmxt-1.0.0/lib/gcc/arm-linux/3.4.3/libgcc.a/opt/iwmmxt-1.0.0/bin/arm-linux-objcopy -O binary -R .bss -R .note -R .comment -S boot.elf32 /pxa270/bootloader/bboot-1.0.1/bootmake[1]: Leaving directory `/pxa270/bootloader/bboot-1.0.1/src'
Embedded Systems KUT1-43
boot loader/monitor
linker script : boot.lds – bboot-1.0.1/srcOUTPUT_ARCH(arm)ENTRY(_start)SECTIONS {
. = 0xa3f00000; BOOTADDR__boot_start = .;.text ALIGN(4) : { *(.text) }
.setup ALIGN(4) : { setup_block = .;*(.setup)setup_block_end = .; }
.rodata ALIGN(4) : { *(.rodata) }
.data ALIGN(4) : { *(.data) }
.got ALIGN(4) : { *(.got) }
__boot_end = .;
.bss ALIGN(16) : { bss_start = .;*(.bss)*(COMMON)bss_end = .; }
.comment ALIGN(16) : { *(.comment) }
stack_point = __boot_start + 0x00100000;loader_size = __boot_end - __boot_start;setup_size = setup_block_end - setup_block;
}
Embedded Systems KUT1-44
boot loader/monitor
2. Makefile in utils directory : make –C utils
3. Makefile in src directory : make –C src
CC=gccCFLAGS=-Wall -O6 -s
all :$(CC) $(CFLAGS) -o macaddr macaddr.c$(CC) $(CFLAGS) -o setupid setupid.c$(CC) $(CFLAGS) -o inetaddr inetaddr.c
clean :rm -f macaddr setupid inetaddr
}
objfiles = start.o memsetup.o setup.o memcpy.o fixgpio.o partition.oobjfiles += main.o time.o string.o command.o stdio.o vsprintf.o ctype.o cmddebug.o gpio.o ieb.oobjfiles += network.o bootp.o tftp.o cs8900.oobjfiles += flash.o serial.o xmodem.o linux.o pxafb.o
libgcc = $(shell $(CC) --print-libgcc-file-name)
binfile = boot
all : $(objfiles) boot.ldsecho "create $(binfile)"$(CC) -static -nostdlib -T boot.lds -o $(binfile).elf32 $(objfiles) $(libgcc)$(OBJCOPY) -O binary -R .bss -R .note -R .comment -S $(binfile).elf32 $(TOPDIR)/$(binfile)
Embedded Systems KUT1-45
boot loader/monitor
make –C src : cont.%.o : %.S
echo "compile $<"$(CC) $(CFLAGS) -o $@ -c $< $(patsubst %,-I%, $(HPATH)) -D__ASSEMBLY__ -include config.h
%.o : %.cecho "compile $<"$(CC) $(CFLAGS) -o $@ -c $< $(patsubst %,-I%, $(HPATH)) -include config.h -include types.h
dep : .depend
.depend : $(wildcard *.S) $(wildcard *.c)rm -f .depend; touch .dependfor x in $(wildcard *.S); do $(CC) $(CFLAGS) -M -MT $${x/%.S/.o} $$x -I$(HPATH) >> .depend; donefor x in $(wildcard *.c); do $(CC) $(CFLAGS) -M -MT $${x/%.c/.o} $$x -I$(HPATH) >> .depend; done
ifeq (.depend,$(wildcard .depend))include .dependendif
clean :rm -f *.o boot.lds *.elf32 $(TOPDIR)/$(binfile)
proper : cleanrm -f .depend
boot.lds : boot.lds.in $(HPATH)/config.hsed -e "s/BOOTADDR/$(BOOTADDR)/" boot.lds.in > boot.lds
Embedded Systems KUT1-46
Boot Loader /Monitor
boot : Boot loader /monitor
main()
wait for 3 seconds
autoboot_mode()
run command
boot() load() tftp() flash() ......
Auto Boot Manual Boot
command mode
jump to kernel image address
command_mode()
Serial initTimer initEthernet init
Key pressed within 3 seconds
start.S
Embedded Systems KUT1-47
start.S
start.S#include <config.h>#include <hardware.h>
.section .text
.global _start_start :
bl define_gpio @ fixgpio.Sbl clock_enablebl setup_memory @ memsetup.S setup static and dynamic memory
@ copy bootloader to dynamic memory arealdr r0, =0x00ldr r1, =__boot_start @ boot.lds.in = 0xa3f00000 (SDRAM)ldr r2, =__boot_end
1: ldmia r0!, {r3-r10}stmia r1!, {r3-r10}cmp r1, r2blt 1b
@ clear bss areamov r3, #0x00 @ 8 bit immediate constantmov r4, #0x00mov r5, #0x00mov r6, #0x00ldr r0, =bss_startldr r1, =bss_end
1: stmia r0!, {r3-r6}cmp r0, r1blt 1b
ldrmacro
Embedded Systems KUT1-48
start.S
start.S - cont.@ set stack pointldr sp, =stack_point-4
@ jump to c codeldr pc, =main @ main.c
clock_enable :#if defined(CONFIG_PXA25x)
ldr r0, =0x0001FFFF#elif defined(CONFIG_PXA27x)
ldr r0, =0x01FFFFFF#endif
ldr r1, =CKENstr r0, [r1]mov pc, lr
include/pxareg.h
/* Core Clock */
#define CCCR __REG(0x41300000) /* Core Clock Configuration Register */#define CKEN __REG(0x41300004) /* Clock Enable Register */#define OSCC __REG(0x41300008) /* Oscillator Configuration Register */#define CCSR __REG(0x4130000C) /* Core Clock Status Register */
Embedded Systems KUT1-49
Memory Map and Registers
» Intel® PXA27x Processor Family Developer’s Manual
Static Bank Select 0(64Mbytes)Static Bank Select 1(64Mbytes)Static Bank Select 2(64Mbytes)Static Bank Select 3(64Mbytes)
0x0000 0000
PCMCIA Socket 0 Space(256Mbyte)
PCMCIA Socket 1 Space(256Mbyte)
Memory Mapped registers (Peripherals)(64MBytes)
Memory Mapped registers (LCD)(64Mbyte)
Memory Mapped registers (Memory Ctl)(64Mbyte)
0x0400 00000x0800 00000x0C00 00000x1000 0000
0x2000 0000
0x3000 0000
0x4000 0000
SDRAM BANK 0(64Mbytes)SDRAM BANK 1(64Mbytes)SDRAM BANK 2(64Mbytes)SDRAM BANK 3(64Mbytes)
Reserved(1024Mbytes)
Static Bank Select 4(64Mbytes)Static Bank Select 5(64Mbytes)
0x4400 0000
0x4800 0000
0x4C00 0000
0x1400 0000
Reserved(128 Mbytes)0x1800 0000
Reserved(1344Mbytes)Internal SRAM
(5C00 0000 - 5C03 FFFF)
0xA000 00000xA400 00000xA800 00000xAC00 00000xB000 0000
0xFFFF FFFFUnit AddressDMA Controller 0x4000_0000UART1ㅡFull Function UART 0x4010_0000UART2ㅡBluetooth UART 0x4020_0000Standard I2C Bus Interface Unit 0x4030_0000I2S Controller 0x4040_0000AC '97 Controller 0x4050_0000USB Client Controller 0x4060_0000UART 3ㅡStandard UART 0x4070_0000Fast Infrared Communications Port 0x4080_0000RTC 0x4090_0000OS Timers 0x40A0_0000PWM 0 and 2 0x40B0_0000PWM 1 and 3 0x40C0_0000Interrupt Controller 0x40D0_0000GPIO Controller 0x40E0_0000Power Manager 0x40F0_0000Reset Controller 0x40F0_0000Power Manager I2C 0x40F0_0180Synchronous Serial Port 1 0x4100_0000MultiMediaCard/SD/SDIO Controller 0x4110_0000reserved 0x4120_0000Clocks Manager 0x4130_0000Mobile Scalable Link (MSL) 0x4140_0000Keypad Interface 0x4150_0000Universal Subscriber ID (USIM)Interface 0x4160_0000
Synchronous Serial Port2 0x4170_0000Memory Stick Host Controller 0x4180_0000Synchronous Serial Port3 0x4190_0000
Peripheral Module Address Summary
Embedded Systems KUT1-50
GPIO
General-Purpose I/O (GPIO) controller» 121 highly-multiplexed general-purpose I/O (GPIO) pins
for use in generating and capturing application-specific input and output signals
» Each pin can be programmed as an output, an input, or as bidirectional for certain alternate functions Programmable for: Inputs or outputs, Interrupts or wake-up sources,
Rising or falling edge, GPIO or one of several alternate functions» Input : the GPIOs can be sampled or programmed to
generate interrupts from either rising or falling edges» Output : the GPIOs can be individually cleared or set » Alternate function : serve either as GPIO or as an
alternate function, but not as both at the same time, providing system flexibility
» All GPIO pins are configured as inputs during the assertion of all resets, and they remain inputs until configured otherwise
» GPIO35, GPIO36, GPIO37, and GPIO41 for target user
Embedded Systems KUT1-51
GPIO
GPIO Block Diagram
Pin DirectionRegister(GPDR)
Alternate FunctionRegister(GAFR)
Pin SetRegisters(GPSR)
Edge DetectStatus Register(GEDR)
Rising Edge DetectEnable Register(GRER)
Falling Edge DetectEnable Register(GFER)
EdgeDetect
Pin-LevelRegister(GPLR)
0
1
Alternate Function(Output)
Alternate Function(Input)
Pin ClearRegisters(GPCR)2
3
3
2
1
0
Power Manager
Sleep Wake-up logic
2
0x40E0_000C/10/14
GPDR1 : Output0 : Input
0x40E0_0054/58/5C0x40E0_0060/64/68
0x40E0_0060/64/68
0x40E0_0060/64/68
Base Address0x40E0_0000
0x40E0_0048/4C/50
0x40E0_0030/34/38
0x40E0_003C/40/44
0x40E0_0000/04/08
Embedded Systems KUT1-52
Clock Enable Register (CKEN)
* All Unit Clock Enable Bit;
0 – Clock disable1 – Clock enable
Name Description Name Description
CKEN[25] TPM Unit Clock Enable CKEN[11] USB Client Unit Clock Enable
CKEN[24] Quick Capture Interface Clock Enable
CKEN[23] SSP1 Unit Clock Enable CKEN[10] USB Host Unit Clock Enable
CKEN[22] Memory Controller CKEN[9] OS Timer Unit Clock Enable
CKEN[21] Memory Stick Host Controller CKEN[8] I2S Unit Clock Enable
CKEN[20] Internal Memory Clock Enable CKEN[7] BTUART Unit Clock Enable
CKEN[19] Keypad Interface Clock Enable CKEN[6] FFUART Unit Clock Enable
CKEN[18] USIM Unit Clock Enable CKEN[5] STUART Unit Clock Enable
CKEN[17] MSL interface Unit Clock Enable CKEN[4] SSP3 Unit Clock Enable
CKEN[16] LCK Controller Clock Enable CKEN[3] SSP2 Unit Clock Enable
CKEN[15] Power Manager I2C Unit Clock Enable CKEN[2] AC ’97 Controller Clock Enable
CKEN[14] I2C Unit Clock Enable CKEN[1:0] 0b00 = All PWMs disabled0b01 = All PWMs enabled0b10 = All PWMs enabled0b11 = All PWMs enabled
CKEN[13] Infrared Port Clock Enable
CKEN[12] MMC Controller Clock Enable
0x4130_0000 CCCR Core Clock Configuration register
0x4130_0004 CKEN Clock Enable register
0x4130_0008 OSCC Oscillator Configuration register
0x4130_000C CCSR Core Clock Status register
0x4130_0010-0x413F_FFFC
ㅡ reserved
0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
ReservedCKEN0
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
CKEN1
CKEN2
CKEN3
CKEN5
CKEN6
CKEN7
CKEN8
CKEN 11
CKEN 12
CKEN 13
CKEN 14
CKEN 16
CKEN4
CKEN9
CKEN15
CKEN10
CKEN 17
CKEN 18
CKEN 19
CKEN 20
CKEN 22
CKEN21
CKEN 24
CKEN23
CKEN 25
Embedded Systems KUT1-53
Clocks
32.768K
RTC
32.768K
PWR_MGR
3.6864
PWM
3.6864
SSP
3.6864
GPIO
3.6864
OST
CPU
CORE
MEM
Controller
LCD
Controller
USB
47.923
FICP
47.923
12C
31.949
MMC
19.169
UARTs
14.746
AC97
12.288
12S
5.672
32.768
KHz
OSC
3.6864
MHz
OSC
/1 /112
100-400
MHz
PLL*
147.46
MHz
PLL
95.846
MHz
PLL
DMA /
Bridge
/M/2/4
/N
RETAINS POWER IN SLEEPPXbus
L
1 0 10
OSCC, OON
CCLKCFGcp14 c6.1 : turbo
CCCR
Clocks Distribution Block Diagram : pxa255
Embedded Systems KUT1-54
ARM Processor Modes
Privileged / Non-privileged» Privileged : full read & write access to the cpsr» Non-privileged : only read access to the control field /
read & write access to the condition flags in the cpsr Seven operating modes = 6 Privileged + 1 Non-privileged
» User : unprivileged mode (most tasks run for programs and applications)
» FIQ : high priority (fast) interrupt is raised» IRQ : low priority (normal) interrupt is raised» Supervisor : entered on reset and OS kernel operates in
(Software Interrupt instruction is executed : SWI)» Abort : failed memory access (memory access violations)» Undef : used to handle undefined instructions» System : special version of user mode, full read & write
access to the cpsr (privileged mode using the same registers as user mode)
Embedded Systems KUT1-55
Register Set
Usermode
r0-r7,r15,andcpsr
r8
r9
r10
r11
r12
r13 (sp)
r14 (lr)
spsr
FIQ
r8
r9
r10
r11
r12
r13 (sp)
r14 (lr)
r15 (pc)
cpsr
r0
r1
r2
r3
r4
r5
r6
r7
UserSystem
r13 (sp)
r14 (lr)
spsr
IRQ
Usermode
r0-r12,r15,andcpsr
r13 (sp)
r14 (lr)
spsr
Undef
Usermode
r0-r12,r15,andcpsr
r13 (sp)
r14 (lr)
spsr
SVC
Usermode
r0-r12,r15,andcpsr
r13 (sp)
r14 (lr)
spsr
Abort
Usermode
r0-r12,r15,andcpsr
Thumb stateLow registers
Thumb stateHigh registers
Note: System mode uses the User mode register set
Embedded Systems KUT1-56
Abort Mode r0
r1
r2
r3
r4
r5
r6
r7
r8
r9
r10
r11
r12
r15 (pc)
cpsr
r13 (sp)
r14 (lr)
spsr
r13 (sp)
r14 (lr)
spsr
r13 (sp)
r14 (lr)
spsr
r13 (sp)
r14 (lr)
spsr
r8
r9
r10
r11
r12
r13 (sp)
r14 (lr)
spsr
Current Visible Registers
Banked out Registers
User FIQ IRQ SVC Undef
r13 (sp)
r14 (lr)
Register Set
Embedded Systems KUT1-57
Registers
37 Registers : 32-bits long» 1 dedicated program counter» 1 dedicated current program status register» 5 dedicated saved program status registers» 30 general purpose registers
Accessible registers» a particular set of r0-r12 registers» a particular r13 (the stack pointer, sp) and r14 (the link
register, lr)» the program counter, r15 (pc)» the current program status register (cpsr)» a particular spsr (saved program status register)
Embedded Systems KUT1-58
Condition code flags» N = Negative result from ALU » Z = Zero result from ALU» C = ALU operation Carried out» V = ALU operation oVerflowed
Sticky Overflow flag - Q flag» Architecture 5TE/J only» Saturation bit
J bit» Architecture 5TEJ only» J = 1: Processor in Jazelle state
Interrupt Disable bits.» I = 1: Disables the IRQ.» F = 1: Disables the FIQ.
T Bit» Architecture xT only» T = 0: Processor in ARM state» T = 1: Processor in Thumb state
Mode bits» Specify the processor mode
2731
N Z C V Q
28 67
I F T mode
1623 815 5 4 024
Flags Status Extension Control
U n d e f i n e dJ
cpsr
Embedded Systems KUT1-59
flags
Condition codes
Not equalUnsigned higher or sameUnsigned lowerMinus
Equal
OverflowNo overflowUnsigned higherUnsigned lower or same
Positive or Zero
Less thanGreater thanLess than or equalAlways
Greater or equal
EQNECS/HSCC/LO
PLVS
HILSGELTGTLEAL
MI
VC
Suffix Description
Z=0C=1C=0
Z=1Flags tested
N=1N=0V=1V=0C=1 & Z=0C=0 or Z=1N=VN!=VZ=0 & N=VZ=1 or N=!V
Embedded Systems KUT1-60
cpsr
Mode bitsMode Abbreviation Privileged Mode[4:0]
Abort abt Yes 10111
FIQ fiq Yes 10001
IRQ irq Yes 10010
Supervisor svc Yes 10011
System sys Yes 11111
Undefined und Yes 11011
User usr No 10000
Embedded Systems KUT1-61
FIQ FIQ
IRQ IRQ
(Reserved)
Data Abort Abort
Prefetch Abort Abort
Software Interrupt(SWI) Supervisor
Undefined Instruction Undefined
Reset Supervisor
0x0000001C
0x00000018
0x00000014
0x00000010
0x0000000C
0x00000008
0x00000004
0x00000000
When an exception occurs, the ARM:» Copies CPSR into SPSR» Sets appropriate CPSR bits
Change to ARM state Change to exception mode Disable interrupts (if appropriate)
» Stores the return address in LR» Sets PC to vector address
To return, exception handler needs to:» Restore CPSR from SPSR» Restore PC from LR
* High Vector AddressVector table can be at
0xFFFF0000 on ARM720Tand on ARM9/10 family devices
Exceptions and Modes
Vector TableException Handlers
Embedded Systems KUT1-62
Immediate constants
No ARM instruction can contain a 32 bit immediate constant» All ARM instructions are fixed as 32 bits long
The data processing instruction format has 12 bits available for operand2
To allow larger (32 bit) constants to be loaded, the assembler offers a pseudo-instruction (macro):» LDR rd, =const
0711 8immed_8
ShifterROR
rot
x2
Embedded Systems KUT1-63
Branch :» B{<cond>} label
pc = label
Branch with Link :» BL{<cond>}subroutine_label
pc = subroutine_label lr = address of the next instruction after the BL
2831 24 0
Cond 1 0 1 L Offset
Condition field
Link bit 0 = Branch1 = Branch with link
232527
Branch instructions
Embedded Systems KUT1-64
B <label>» PC relative. ±32 Mbyte range.
BL <subroutine>» Stores return address in LR
lr = address of the next instruction after the BL» Returning implemented by restoring the PC from LR
func1
:
:
BL func1
:
:
:
:
:
:
:
MOV pc, lr
Branches and Subroutines
Embedded Systems KUT1-65
Load/Store Multiple Instruction
Syntax:<LDM|STM> {<cond>} Rb{!}, <register list>
4 addressing modes:LDMIA / STMIA increment afterLDMIB / STMIB increment beforeLDMDA / STMDA decrement afterLDMDB / STMDB decrement before
IA
r1 IncreasingAddress
r4
r0
r1r4
r0
r1r4
r0 r1r4
r0
r10
IB DA DBLDMxx r10, {r0,r1,r4}STMxx r10, {r0,r1,r4}
Base Register (Rb)
Embedded Systems KUT1-66
LDMIA Instruction
LDMIA r0!, {r1-r3}
Pre-condition Post-condition
•Note : ! indicates that the register is updated after the instruction is executed.(without ! : r0 = 0x80010 )
Memory
Address Data
0x80020 0x000000005
0x8001c 0x000000004
0x80018 0x000000003 r3=0x00000000
0x80014 0x000000002 r2=0x00000000
r0=0x80010 0x80010 0x000000001 r1=0x00000000
0x8000c 0x000000000
Memory
Address Data
0x80020 0x000000005
r0=0x8001c 0x8001c 0x000000004
0x80018 0x000000003 r3=0x00000003
0x80014 0x000000002 r2=0x00000002
0x80010 0x000000001 r1=0x00000001
0x8000c 0x000000000
Embedded Systems KUT1-67
main.c
main.cint main(void){
int count;bool autoboot=true;
uart_init(); 2 timesuart_init();pxafb_disable();time_init();config_init();
printf("\033[H\033[J\n"); // clear screen.printf(" %s : bootloader for xhyper board\n", PACKAGE);printf(" Copyright (C) 2002-2004 Hybus Co,. ltd.\n");printf(" support : http://www.hybus.net\n");
iflash_init();eth_init();printf(" IEB board TEST\n");ieb_init(); //270_tku ieb initprintf(" autoboot in progress, press any key to stop.");
count = 2000;autoboot = true;do {
if (getc() != -1){ autoboot=false; break; }if (!(--count % 1000)) putc('.');mdelay(1);
} while (count);putc('\n');
Embedded Systems KUT1-68
main.c
main.c – cont.
command.c» autoboot_mode() → command parsing do_command() →
do_boot()» Command structure
struct command_t cmd_boot = {.name = "boot",.run = do_boot,.usage = boot_usage
};
if (autoboot){printf(" autoboot started.\n");autoboot_mode();
}
printf(" autoboot aborted\n");printf(" type \"help\" to get a list of commands\n");command_mode();while (1);return 0;
}
Embedded Systems KUT1-69
Command.c
Command lists
static struct command_t *cmdlist[] = {&cmd_load,&cmd_ping,&cmd_bootp,&cmd_tftp,&cmd_flash,&cmd_erase,&cmd_config,&cmd_boot,&cmd_memcpy,&cmd_memcmp,&cmd_memset,&cmd_hexdump,&cmd_write,&cmd_read,&cmd_reboot,0
};
do_command()
for (cp=cmdlist; *cp; cp++){if (! strcmp ( argv[0], (*cp)->name) ){res = (*cp)->run(argc, argv); callreturn res; bool}
}
boot or boot a0008000 at monitor prompt
Embedded Systems KUT1-70
do_boot()
do_boot()
* Kernel(0, 200) : machine type or architecture ID- Used at Kernel source/arch/arm/boot/compressed/head.S (Line # 177 Linux start : r0=0, r1=ID)- Defined at Kernel source/include/asm/mach-types.h (CEIVA → xhyper 65280)
static bool do_boot(int argc, char **argv){void (*kernel)(int zero, int arch);
if (argc == 1){struct map *mp;mp = find_map("kernel"); # next slide partition.cif (!mp){ printf(" can't found map for kernel.\n"); goto invalid; }kernel = (void *)mp->dramb; // kernel = A0008000
} else if (argc == 2){bool res;ulong tmp;
res = strtoul(argv[1], &tmp, 16); # kernel start address = &tmpif (!res) goto invalid;kernel = (void *)tmp; // kernel = argv[1]
} else goto invalid;if (!get_kernel_size(kernel)){ printf(" error: kernel is not exists.\n"); return false; }create_tags();printf("starting kernel ...\n");kernel(0, 200) # A0008000return true;
invalid :boot_usage();return false;
}
Embedded Systems KUT1-71
partition.c
static struct map __bsetup parts[] = { // used by find_map() function{
.name = "loader",
.sramb = LOADER_SRAM_BASE,
.srams = LOADER_MAX_SIZE,
.dramb = LOADER_DRAM_BASE,
.maxs = LOADER_MAX_SIZE,}, {
.name = "kernel",
.sramb = KERNEL_SRAM_BASE, SRAM = Flash memory
.srams = KERNEL_MAX_SIZE,
.dramb = KERNEL_DRAM_BASE, /bboot-1.0.1/include/board.h 0xA0008000
.maxs = KERNEL_MAX_SIZE,}, {
.name = "ramdisk",
.sramb = RAMDISK_SRAM_BASE,
.srams = RAMDISK_MAX_SIZE,
.dramb = RAMDISK_DRAM_BASE,
.maxs = RAMDISK_MAX_SIZE,}, {
.name = "root",
.sramb = ROOTFS_SRAM_BASE,
.srams = ROOTFS_MAX_SIZE,
.dramb = ROOTFS_DRAM_BASE,
.maxs = ROOTFS_MAX_SIZE,}
};
Embedded Systems KUT1-72
Board.h
Target flash map» /pxa270/bootloader/bboot-1.0.1/include/board.h
Target kernel start» /pxa270/kernel/linux-2.6.11-h270-tku_v1.1/arch/arm/
boot/compressed/head.S line # 177
/* flash map */#define LOADER_SRAM_BASE 0x00000000#define LOADER_DRAM_BASE 0xA1E00000#define LOADER_MAX_SIZE 0x00040000#define KERNEL_SRAM_BASE 0x00040000 Flash memory#define KERNEL_DRAM_BASE 0xA0008000 DRAM memory#define KERNEL_MAX_SIZE 0x001C0000#ifdef USE_RAMDISK# define RAMDISK_SRAM_BASE 0x001C0000# define RAMDISK_DRAM_BASE 0xA1000000# define RAMDISK_MAX_SIZE 0x00300000# define ROOTFS_SRAM_BASE 0x004C0000# define ROOTFS_DRAM_BASE 0xA0000000# define ROOTFS_MAX_SIZE 0x01B40000#else
Embedded Systems KUT1-73
Kernel Compile
zImage : kernel» cd /pxa270/kernel» tar xzvf linux-2.6.11-h270-tku_v1.1.tar.gz» cd linux-2.6.11-h270-tku_v1.1» make xhyper270tku_defconfig
/linux-2.6.11-h270-tku_v1.1/arch/arm/configs/xhyper270tku_defconfig /linux-2.6.11-h270-tku_v1.1/.config
» make menuconfig make config : text based interactive make menuconfig : text based menu driven
→ kernel/linux-2.6.11-h270-tku_v1.1/scripts/kconfig/Makefile make xconfig : Xwindows-GUI – cd /usr/src/linux-2.4
» Kernel configuration : Manual p.155 – p. 218» make zImage» cp arch/arm/boot/zImage /tftpboot » tftp zImage kernel : at boot monitor» flash kernel
Embedded Systems KUT1-74
Root File system
rootfs.img : Root File System» JFFS2 : Journaling Flash File System» Kernel configuration : Manual p.213 – p. 218» Flash Memory Definitions
kernel/linux-2.6.11-h270-tku_v1.1/drivers/mtd/maps/xhyper270tku.c» cd /pxa270/filesystem» cd rootfs , ls , & cd ..» rm –rf rootfs.img» ./mkjffs2 : script → mkfs.jffs2» cp rootfs.img /tftpboot» tftp rootfs.img root
Embedded Systems KUT1-75
Target Memory
Memory Mapped registers (Peripherals)(64MBytes)
Static Bank Select 0(64Mbytes)Static Bank Select 1(64Mbytes)Static Bank Select 2(64Mbytes)Static Bank Select 3(64Mbytes)
boot
zImage
0x00000000
PCMCIA Socket 0 Space(256Mbyte)
PCMCIA Socket 1 Space(256Mbyte)
Memory Mapped registers (LCD)(64Mbyte)
Memory Mapped registers (Memory Ctl)(64Mbyte)
0x040000000x080000000x0C0000000x10000000
0x20000000
0x30000000
0x40000000
SDRAM BANK 0(64Mbytes)SDRAM BANK 1(64Mbytes)SDRAM BANK 2(64Mbytes)SDRAM BANK 3(64Mbytes)
Reserved(1024Mbytes)
Static Bank Select 4(64Mbytes)Static Bank Select 5(64Mbytes)
0x44000000
0x48000000
0x4C000000
Flash32M Byte / 32 bit bus
CS0
Root file system
zImage
SDRAM64M Byte / 32 bit bus
RAS0 / CAS0
0xA0008000
0x00040000
0x14000000
Reserved(128 Mbytes)0x18000000
Reserved(1344Mbytes)0xA00000000xA40000000xA80000000xAC0000000xB0000000
0xFFFFFFFF
boot
reload command
flash command
File System Source
boot Sourceboot Image
rootfs.img Image
HOST
File System
Kernel Source
Compile
zImage
JTAG
tftp command
Root file system
0x00200000
0x00000000
0xA0000000
0xA1E00000
File System
Embedded Systems KUT1-76
RAM Disk
RAM Disk» Using the RAM as a disk
stored only temporarily save and retrieve files very quickly conserve power
» dd if=/dev/zero of=ramdisk_img bs=1k count=8192» file ramdisk_img» mke2fs ramdisk_img» mkdir ramdisk» mount –o loop ./ramdisk_img ./ramdisk» df» cd ramdisk» ls –al
“loop” device » a device driver that allows an image file to be mounted as
though it were a normal block device.