Transcript bootloader
LAB 8
Bootloader
CS 4101 Introduction to Embedded Systems
Chung-Ta King
Introduction
• In this lab, we will learn
– What is bootloader
– How bootloader works
Lab 8: Compile and install bootloader
Bonus Lab: Modify bootloader
We have learned …
• How to setup PCM-7230 environment
• How to install
– bootloader
– linux kernel
– root file system
• How to execute a program on PCM-7230
Why bootloader ?
• Computer processor can only execute
program code found in read-only memory
(ROM), random access memory (RAM).
• However, modern operating systems and
application program code and data are stored
on nonvolatile data storage devices, such
as hard drive, flash memory, DVD disc, etc.
The OS and root file system have to be loaded
into executable place.
Why Bootloader? Cont’d
• Moreover, before entering
kernel, the computer must
be prepared, and there are
some requirements must
be obeyed.[1]
Kernel Booting requirements (for arm):
CPU register settings
r0 = 0.
r1 = machine type number.
r2 = physical address of tagged list in system RAM.
CPU mode
All forms of interrupts must be disabled (IRQs and
FIQs.)
The CPU must be in SVC mode. (A special exception
exists for Angel.)
Caches, MMUs
The MMU must be off.
Instruction cache may be on or off.
Data cache must be off and must not contain any
stale data.
Devices
DMA to/from devices should be quiesced.
The boot loader is expected to call the kernel image by
jumping directly to the first instruction of the kernel image.
have to prepare computer for kernel to boot
Start-up (finding bootloader)
ROM
Power
on signal!
RAM
Call
Reset pin
Bootloader
BIOS
MBR (master boot record)
• POST(Power-On Self
Test)
• Initialize devices (check
IRQ/IO conflict)
• Find bootloader (address)
Windows file
system
Kernel entry
Linux file
system
Other file
system
Boot sector (bootloader)
Bootloader
• In this lab, we use the boot-loader named iboot.
• Normally, there are 2 stages in the booting
sequence.
RAM
Bootloader
Stage 1
Load
Load
kernel
Stage 2
Root
file
system
Bootloader
• 1st stage
– Usually written by assembly language.
– It does some simple hardware initialization, prepares the
program context for high level language, and jump to
stage2.
• 2nd stage
– written by C language.
– It does some more complex hardware initialization,
detects whether a Linux kernel exists, move kernel to ram,
and does some special setting for booting Linux kernel and
passes the control to kernel.
Memory
• There are three types of memory on the
PCM7230:
• 1MB ROM for boot-loader: It
uses AM29LV800BB-90EC
Chipset.
• 32MB(16MB*2) Flash for kernel
and ramdisk: It uses Intel
E28F128-J3A150*2 chipset.
• 64MB(32MB*2) SDRAM: It uses
SAMSUNG K4S561632E-TC75*2
Chipset.
0x040c0000
0x041c0000
kernel
Root fs
Writing Bootloader
Jen255.exe
i-boot
LAB ASSIGNMENTS
Basic Lab: Compile and install bootloader
• Lab Objective
– You will learn how to compile and install the IBoot bootloader in this lab.
• Requirement
– A build machine with Linux installed
– i-boot-lite.tgz
Basic Lab Steps (1/2)
1. Login provided Linux machine.
2. To build I-Boot bootloader, you need to set the PATH
variable. For example, the toolchain executable files are
installed in the directory /toolchain/bin, set the
following environment variables:
– % export
PATH=$PATH:/home/pads/lab/toolchain/bin
Absolute path of the executable file
3. Change into the unpacked directory and type “make”.
– % cd lab/i-boot-lite
– % make clean
– % make
Basic Lab Steps (2/2)
4. Fix the SED variable problem
– To fix this problem, you need to set SED variable to be `which sed`.
– % export SED=`which sed` (bash)
– % make
5. Write the new compiled boot-loader to PCM-7230.
– The new complied boot-loader image will be created in i-boot-lite/iboot-cerf-board-pxa250_1.7-lite.img
– Rename the file to bootldr and copy it to the same folder with the
utility Jen255.exe.
– Now you can install the new compiled loader onto PCM-7230 as Lab
7.
*Once you want to check the burned boot-loader, be sure you
dis-connect the JTAG when using hyper-terminal.
Bonus Lab : Modify Boot-loader
• Lab Objective
– In this lab, you will learn how to modify the bootloader codes to show some messages while
booting.
Bonus Lab Steps (1/2)
1. Change into the unpacked directory i-boot-lite.
– % cd i-boot-lite
2. Modify the source file src/main/c_main.c.
–
–
–
–
–
You can use gedit src/main/c_main.c.
Use itc_printf() function to show some messages.
The code example is in the next page.
You have to add the group info in the startup message.
Ex: Group: TA
3. Compile and install the modified boot-loader as Lab 7
Bonus Lab Steps (2/2)