13
Lab 4 Department of Computer Science and Information Engineering National Taiwan University Computer System Laboratory Lab4 - Bootloader 2014/10/14 / 13 1

Lab 4 Department of Computer Science and Information Engineering National Taiwan University Lab4 - Bootloader 2014/10/14/ 13 1

Embed Size (px)

Citation preview

Page 1: Lab 4 Department of Computer Science and Information Engineering National Taiwan University Lab4 - Bootloader 2014/10/14/ 13 1

Lab 4 Department of Computer Science and Information EngineeringNational Taiwan University / 131

Computer System Laboratory

Lab4 - Bootloader

2014/10/14

Page 2: Lab 4 Department of Computer Science and Information Engineering National Taiwan University Lab4 - Bootloader 2014/10/14/ 13 1

Lab 4 Department of Computer Science and Information EngineeringNational Taiwan University / 132

Experimental Goal

Learn how to build U-Boot bootloader for PXA270.

2014/10/14

Page 3: Lab 4 Department of Computer Science and Information Engineering National Taiwan University Lab4 - Bootloader 2014/10/14/ 13 1

Lab 4 Department of Computer Science and Information EngineeringNational Taiwan University / 133

Environment

Host System Windows XP

Build System VirtualBox + Ubuntu 8.04

Target System Creator XScale PXA270

Software DENX U-Boot

You can find all software on RSWiki CSL Course Software.

2014/10/14

Page 4: Lab 4 Department of Computer Science and Information Engineering National Taiwan University Lab4 - Bootloader 2014/10/14/ 13 1

Lab 4 Department of Computer Science and Information EngineeringNational Taiwan University / 134

Bootloader Concept

A typical flow when booting a computer. Load BIOS and do hardware self-test. Execute bootloader in master boot record (MBR) which is the first sector of disk. Load kernel and root filesystem. Initialize hardware. …

When a computer is powered on, CPU will execute the first instruction from a specified address: ROM, EEPROM, Flash memory, etc. In ARM system, the address usually is 0x00000000.

In other words, bootloader is usually located at 0x00000000.

Typical space allocation:

2014/10/14

Page 5: Lab 4 Department of Computer Science and Information Engineering National Taiwan University Lab4 - Bootloader 2014/10/14/ 13 1

Lab 4 Department of Computer Science and Information EngineeringNational Taiwan University / 135

Bootloader Examples

Bootloader highly depends on architecture.

Some popular bootloaders: LILO, GRUB, GRUB2

You can see /boot/grub/menu.lst for the settings in Ubuntu 8.04.

Windows Boot Manager You can see the settings in C:\boot.init in Windows XP.

U-Boot We will use U-Boot for PXA270 (ARM architecture).

2014/10/14

Page 6: Lab 4 Department of Computer Science and Information Engineering National Taiwan University Lab4 - Bootloader 2014/10/14/ 13 1

Lab 4 Department of Computer Science and Information EngineeringNational Taiwan University / 136

Introduction to U-Boot

Das U-Boot (Universal Bootloader) is an open source, primary bootloader used in embedded systems.

It is available for a number of different computer architectures, including PPC, ARM, MIPS, x86, etc.

The current name Das U-Boot adds a German definite article as a pun to the German word for “submarine”.

2014/10/14

Reference: Das U-Boot, http://en.wikipedia.org/wiki/Das_U-Boot

Page 7: Lab 4 Department of Computer Science and Information Engineering National Taiwan University Lab4 - Bootloader 2014/10/14/ 13 1

Lab 4 Department of Computer Science and Information EngineeringNational Taiwan University / 137

U-Boot Compilation (1/2)

Step 1: download the patched source codes of U-Boot (mt-u-boot-1.1.2.tar.gz) in Ubuntu 8.04.

Step 2: extract source codes.

Step 3: please check the path of toolchain arm-elf-* is in PATH. The toolchain arm-elf-* will be used in the compilation.

Tips: The include/configs/ directory under U-Boot source directory contains

configuration files for supported boards. It defines the CPU type, the peripherals and their configuration, the memory

mapping, the U-Boot features that should be compiled in, etc. For instance of PXA270, U-boot will be copied to 0xA3F80000 when it is loaded by

CPU and it uses 0x00020000 to 0x0003FFFF as the boot parameters.

2014/10/14

Page 8: Lab 4 Department of Computer Science and Information Engineering National Taiwan University Lab4 - Bootloader 2014/10/14/ 13 1

Lab 4 Department of Computer Science and Information EngineeringNational Taiwan University / 138

U-Boot Compilation (2/2)

Step 4: compile U-Boot. U-Boot must be configured for the target board before being compiled, i.e., make

<target board>_config, where <target board> is the name of the configuration file in include/configs/, without the “.h”. E.g., Create_XScale_PXA270 is for our target board.

% cd u-boot-1.1.2 % make mrproper

This command often uses to clean all the object files and configurations. You can see Makefile and check what it has done.

% make Create_XScale_PXA270_config % make

The resulting u-boot.bin is the bootloader we want so that we can copy it to PXA270.

2014/10/14

Page 9: Lab 4 Department of Computer Science and Information Engineering National Taiwan University Lab4 - Bootloader 2014/10/14/ 13 1

Lab 4 Department of Computer Science and Information EngineeringNational Taiwan University / 139

Memory Layout of PXA270

2014/10/14

0xA0000000

0xA4000000RAM

U-Boot

Flash

0x00000000

0x00040000

0x00080000diag

0x00480000

0x01380000

Linux kernel 1

Root Filesystem

0x00020000U-Boot parameters

0x02000000

0x01C00000Linux kernel 2 U-Boot

0xA3F80000

Page 10: Lab 4 Department of Computer Science and Information Engineering National Taiwan University Lab4 - Bootloader 2014/10/14/ 13 1

Lab 4 Department of Computer Science and Information EngineeringNational Taiwan University / 1310

Configure U-Boot

If you want to change default configuration for PXA270, you can modify the specified files and recompile U-Boot. % cd u-boot-1.1.2 % nano include/configs/Create_XScale_PXA270.h

CONFIG_SERVERIP: host system IP. CONFIG_IPADDR: target system IP. CONFIG_BOOTARGS: boot arguments. CONFIG_BOOTCOMMAND: boot command. CONFIG_BOOTDELAY: U-Boot delay (do not set to 0!). CONFIG_LINUX: Linux kernel start command. etc.

Tips: The U-Boot environment variable “bootargs” is used to hold the parameter

options passed to the Linux kernel, as the kernel’s command line parameters.

2014/10/14

Page 11: Lab 4 Department of Computer Science and Information Engineering National Taiwan University Lab4 - Bootloader 2014/10/14/ 13 1

Lab 4 Department of Computer Science and Information EngineeringNational Taiwan University / 1311

Build Your Own U-Boot (1/2)

Step 1: please modify the boot command in U-Boot. CONFIG_BOOTCOMMAND = “run linux” CONFIG_LINUX = “bootm 80000”

Step 2: please try to change the command prompt and display with your group id.

2014/10/14

Page 12: Lab 4 Department of Computer Science and Information Engineering National Taiwan University Lab4 - Bootloader 2014/10/14/ 13 1

Lab 4 Department of Computer Science and Information EngineeringNational Taiwan University / 1312

Build Your Own U-Boot (2/2)

Step 3: copy the uImage provided in lab3 to flash address 0x01C00000. The erased end address is 0x1FFFFFF (32 sectors).

Step 4: compile your U-Boot and copy to flash address 0x00000000. Make sure you also erase the boot parameters sector (0x00020000 to 0x0003FFFF), or your modified settings could not work.

Step 5: reset PXA270 and then you will see new configuration. Try to do some settings so that you can choose which to boot on, the two Linux

kernels ,or the program diag.

2014/10/14

Page 13: Lab 4 Department of Computer Science and Information Engineering National Taiwan University Lab4 - Bootloader 2014/10/14/ 13 1

Lab 4 Department of Computer Science and Information EngineeringNational Taiwan University / 1313

Lab Requirement

Show your own command prompt in U-Boot.

Show that you can choose what to boot on, and it is as simple as possible.

Please hand in your lab report to the FTP. Server: 140.112.90.174 Username: csl2014 Password: csl2014HomeWork Directory: lab4 Please use this format for filename: “G# Ver#”, where G# is your group id and

Ver# is revision version number. E.g., G1 Ver2

2014/10/14