Title: LINUX BOOT PROCEDURE AND BOOTLOADER
1LINUX BOOT PROCEDURE AND BOOTLOADER
2OUTLINE
- Introduction
- Boot loader
- U-Boot
- Kernel
- INIT
- Lab
3Introduction
- An embedded linux system is typically consist of
some software below - Boot loader
- Kernel
- Init program
- Your application
4BOOT LOADER
- Boot loader is a program that
- Execute when board power on
- Detect hareware (if necessary)
- Initialize hardware
- Copy first program, might be
- A simple program
- Bootloader stage N
- OS kernel
- Transfer control to it and go
- Boot loader is varied from different CPU,
different board.
5BOOT LOADER Execute when board power on
- Any CPU will execute a program at specified
address when power on - Boot loader always be placed there
6BOOT LOADER Detect Hardware
- Search for attached device
- Filesystem on storage
- Mouse on USB
- etc
- Use detected device if need
- Read configure file in filesystem
7BOOT LOADER Initialize Hardware
- Some hardware require default value
- Stop interrupt
- Set CPU clock
- Configure RAM or MMU
- Reset other processor such as DSP
8BOOT LOADER Copy First Program
- A simple program
- Non-OS program
- Bootloader stage N
- Boot loader might have multiple stages, multiple
modes - OS kernel
- Linux
- WinCE
- etc
9BOOT LOADER Copy First ProgramStage N
- Typical 2 stages in embedded system
- Stage 1
- Write in assembly language to speed up
- Initialize hardware
- Copy Stage 2 to RAM
- Prepare stack for Stage 2
- Jump to Stage 2
- Stage 2
- Write in C for more feature
- Initialize hardware
- Load kernel
- Send parameter to kernel
- Start kernel
10BOOT LOADER Copy First ProgramMultiple modes
- In order to provide more feature, boot loader
might have multiple modes - Mode 1 Boot program or kernel
- Copy program only
- Mode 2 Update utility
- Read filesystem or kernel via
- RS232 xmodem protocol (Very Slow)
- Network FTP protocol
- Earse flash and overwrite it with new data
11BOOT LOADER Example
12BOOT LOADER Transfer Control to It and Go
- Copy next program to RAM
- Sometimes might execute on ROM
- Setup stack for it
- Set PC (or jump) to its start address
13U-Boot
- U-Boot Universal Bootloader
- http//u-boot.sourceforge.net/
- Portable and easy to port and to debug
- Support many architectures PPC, ARMs, MIPS, x86,
m68k, NIOS, Microblaze
14U-BootSupport list
15U-Boot Instructions
- help print online help
- help ltcommandgt show usage
- flinfo 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
16KERNEL
- After kernel is loaded and started, kernel will
detect and initialize hardware - After everything is done, find root filesystem
for VFS (Virtual File System) - Then, search for init, which is the first program
in OS - Init will be the parent of all other process
17INIT
- The first process in OS
- PID 1
- Enter ps aux to show all process
- Typical operation
- Fork shell and execute a script
- Mount all filesystem
- Start all deamon
- Wait for user login
- In embedded system, there are few task to do.
18LAB
19LAB
- LAB 1 Boot loader
- LAB 2 Boot procedure
20LAB 1Boot loader
- Install board
- Install arm tool-train
- Compile U-Boot
- Install JTAG driver
- Install U-Boot
21LAB 1Install board
1 Pin
22LAB 1 Install arm tool-train Compile U-Boot
- In Linux
- Download cross-3.2.tar.bz2 and
- u-boot-1.1.4.zip
- Install cross-3.2 to /usr/local/arm
- Extract U-Boot and compile it
- After completed, copy u-boot.bin to Windows
make innokom_config make CROSS_COMPILE/usr/local/
arm/bin/arm-linux-
23LAB 1 Install JTAG driver
- In Windows
- Copy GIVEIO.SYS under CgiveIO folder to
C\WINDOWS\system32\drivers - Click ???? in ???
- Select ?,??????
- Select ??????
- Select ????
- Select (COM / LPT)
- Click ?????, select giveio.inf
24LAB 1 Install U-Boot
- Place u-boot.bin in the folder where Jen255.exe
existed - Execute Jen255.exe and enter
- u-boot.bin
- Open ????? with baud rate 19200 bps, no flow
control - Reset board and see if success
25LAB 2
- Re-install origin I-Boot
- Modify boot procedure
- Install kernel and filesystem
26LAB 2 Re-install origin I-Boot
- In Windows
- Execute Jen255.exe again, but enter bootldr
insteaded
27LAB 2 Modify boot procedure
- Setup kernel and filesystem
- Use compiled kernel
- Modify existed filesystem
28LAB 2 Modify boot procedure(cont)
- In Linux, modify boot procedure
gzip -d ramdisk.gz mount filesystem sudo mount
-o loop ramdisk fs go to init procedure
folder cd fs/etc/init.d/ sudo mv rcS rcS.bak
edit boot procedure sudo vi rcS enter content
as below !/bin/sh while 1 do echo
AHHHHHHHHHHH done mark it as executable sudo
chmod x rcS cd ../../../ sudo umount fs pack
it again gzip -9 ramdisk ramdisk.gz
29LAB 2 Install kernel and filesystem
- In Windows
- Open ????? with baud rate 115200 bps, no flow
control
setup kernel download xmodem 0xa0020000 flashver
ify 0x040c0000 0xa0020000 0x100000 setup root
filesystem download xmodem 0xa0020000 flashverify
0x041c0000 0xa0020000 0x3D5000
30LAB 2