Presentation is loading. Please wait.

Presentation is loading. Please wait.

Lab 5 Department of Computer Science and Information Engineering National Taiwan University Lab5 – Bootloader + OS Kernel 2015/10/27/ 25 1.

Similar presentations


Presentation on theme: "Lab 5 Department of Computer Science and Information Engineering National Taiwan University Lab5 – Bootloader + OS Kernel 2015/10/27/ 25 1."— Presentation transcript:

1 Lab 5 Department of Computer Science and Information Engineering National Taiwan University Lab5 – Bootloader + OS Kernel 2015/10/27/ 25 1

2 Lab 5 Department of Computer Science and Information Engineering National Taiwan University  Learn how to build U-Boot bootloader for PXA270.  Learn how to build Linux kernel image for PXA270. 2015/10/27/ 25 2

3 Lab 5 Department of Computer Science and Information Engineering National Taiwan University  Host System  Windows XP  Build System  VirtualBox + Ubuntu 8.04  Target System  Creator XScale PXA270  Software  DENX U-Boot  Linux for PXA270  linux-2.6.15.3-creator-pxa270.patch  mkimage utility  Root filesystem image (15M)  You can find all software on CSL Course Software.CSL Course Software 2015/10/27/ 25 3

4 Lab 5 Department of Computer Science and Information Engineering National Taiwan University  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: 2015/10/27/ 25 4

5 Lab 5 Department of Computer Science and Information Engineering National Taiwan University  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). 2015/10/27/ 25 5

6 Lab 5 Department of Computer Science and Information Engineering National Taiwan University  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”. 2015/10/27/ 25 6 Reference: Das U-Boot, http://en.wikipedia.org/wiki/Das_U-Boothttp://en.wikipedia.org/wiki/Das_U-Boot

7 Lab 5 Department of Computer Science and Information Engineering National Taiwan University  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. 2015/10/27/ 25 7

8 Lab 5 Department of Computer Science and Information Engineering National Taiwan University  Step 4: compile U-Boot.  U-Boot must be configured for the target board before being compiled, i.e., make _config, where 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. 2015/10/27/ 25 8

9 Lab 5 Department of Computer Science and Information Engineering National Taiwan University 2015/10/27/ 25 9 0xA0000000 0xA4000000 RAM U-Boot Flash 0x00000000 0x00040000 0x00080000 diag 0x00480000 0x01380000 Linux kernel 1 Root Filesystem 0x00020000 U-Boot parameters 0x02000000 0x01C00000 Linux kernel 2U-Boot 0xA3F80000

10 Lab 5 Department of Computer Science and Information Engineering National Taiwan University  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. 2015/10/27/ 25 10

11 Lab 5 Department of Computer Science and Information Engineering National Taiwan University  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. 2015/10/27/ 25 11

12 Lab 5 Department of Computer Science and Information Engineering National Taiwan University  Step 3: copy the uImage provided in lab4 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. 2015/10/27/ 25 12

13 Lab 5 Department of Computer Science and Information Engineering National Taiwan University  After the 1.0 release and prior to version 2.6, the number was composed as “A.B.C”, where the number A denoted the kernel version, the number B denoted the major revision of the kernel and the number C indicated the minor revision of the kernel.  In 2004, after version 2.6.0 was released, the kernel developers no longer uses this system, instead now simply incrementing the third number, using a fourth number as necessary.  In 2011, the kernel version was bumped to 3.0 for the release following 2.6.39, to commemorate the 20th anniversary of Linux. 2015/10/27/ 25 13 Reference: wikipedia – Linux kernel http://en.wikipedia.org/wiki/Linux_kernelhttp://en.wikipedia.org/wiki/Linux_kernel

14 Lab 5 Department of Computer Science and Information Engineering National Taiwan University  Step 1: download Linux source codes (mt-linux-2.6.15.3.tar.gz) for PXA270.  Step 2: extract the source codes.  Step 3: apply the patch.  % cd pxa270/create-pxa270  % Link http://140.112.90.160:5000/fbsharing/nq8uCcwT to downloadhttp://140.112.90.160:5000/fbsharing/nq8uCcwT patch file  % patch -p0 < linux-2.6.15.3-creator-pxa270.patch 2015/10/27/ 25 14

15 Lab 5 Department of Computer Science and Information Engineering National Taiwan University  Step 4: configure the Linux kernel (check Lab4’s arm-unknown-linux-gnu- * toolchain path in PATH).  % cd../linux  % make mrproper  % make creator_pxa270_defconfig  The “ make _defconfig ” command will create.config by the default symbol values from arch/ /configs/ _defconfig.  Step 5: compile Linux kernel.  % make  The resulting zImage in arch/arm/boot is the compressed kernel image we want. 2015/10/27/ 25 15

16 Lab 5 Department of Computer Science and Information Engineering National Taiwan University  The Linux kernel build system (Kbuild) includes support for a variety of configuration methods, the most commonly used method is:  % make menuconfig  Please install libncurses5-dev package in Ubuntu.  Make sure your screen is large enough to display the configuration. 2015/10/27/ 25 16

17 Lab 5 Department of Computer Science and Information Engineering National Taiwan University  Many features and drivers are available as modules, and they are possible to choose whether to build features into the kernel.  Please always build into the kernel, i.e.,, in our Labs.  Once the kernel has been configured, you can quit the kernel configuration menu via Esc key or the Exit menu item.  Choose “Yes” to save the new configuration into a new.config file.  You can use “ ls -a ” to check the file. 2015/10/27/ 25 17 built-in module

18 Lab 5 Department of Computer Science and Information Engineering National Taiwan University  The Creator XScale PXA270 board has 32MB flash and 64MB SDRAM.  Flash memory address range: 0x00000000 to 0x02000000.  SDRAM address range: 0xA0000000 to 0xA4000000.  Recall that U-Boot has determined the location of kernel image. CONFIG_BOOTCOMMAND "run linux" CONFIG_LINUX bootm 80000  The locations and sizes of kernel image and root filesystem are also determined by Linux kernel (in arch/arm/mach-pxa/mach-creator- pxa270.c ). 2015/10/27/ 25 18

19 Lab 5 Department of Computer Science and Information Engineering National Taiwan University 2015/10/27/ 25 19 0xA0000000 0xA4000000 RAM U-Boot Flash 0x00000000 0x00040000 0x00080000 diag 0x00480000 0x01380000 Linux kernel 1 Root Filesystem 0x00020000 U-Boot parameters 0x02000000 0x01C00000 Linux kernel 2U-Boot 0xA3F80000

20 Lab 5 Department of Computer Science and Information Engineering National Taiwan University  Based on the memory layout, we can configure our Linux kernel. static struct mtd_partition creator_pxa270_partitions[] = {... },{ name: "Kernel", offset: 0x00080000, size: 0x00400000, // 4M mask_flags: MTD_WRITEABLE },{ name: "Filesystem", offset: 0x00480000, size: 0x00F00000, // 15M }... 2015/10/27/ 25 20

21 Lab 5 Department of Computer Science and Information Engineering National Taiwan University  We use U-Boot as the bootloader on PXA270, we need to convert the OS kernel image vmlinux (which zImage is compressed by) to U-Boot bootable image ( uImage ).  Step 1: get raw binary file.  % arm-unknown-linux-gnu-objcopy -O binary -R.note -R.comment -S arch/arm/boot/compressed/vmlinux linux.bin  Step 2: compress kernel image (optional).  % gzip -9 linux.bin 2015/10/27/ 25 21

22 Lab 5 Department of Computer Science and Information Engineering National Taiwan University  Step 3: download mkimage.  Step 4: add header.  % chmod +x mkimage  %./mkimage -A arm -O linux -T kernel -C gzip -a 0xa0008000 -e 0xa0008000 -n "CSL Lab5 Kernel" -d linux.bin.gz uImage  If you skip step2, please use -C none and -d linux.bin.  mkimage is in the tools folder of U-Boot source codes.  You can see the mkimage usage by executing without arguments.  The resulting uImage is the U-Boot image we want. 2015/10/27/ 25 22

23 Lab 5 Department of Computer Science and Information Engineering National Taiwan University  Please refer to Lab1 to copy new Linux kernel and root filesystem to flash.  Step 1: download new 15M rootfs (root filesystem).  Step 2: copy your uImage to flash.  Step 3: copy new rootfs to flash. (take about 7 minutes)  Step 4: reset PXA270, now you can see your own Linux kernel is booted (the message “CSL Lab5 Kernel”).  Please use “ df -h ” to check the size of filesystem. 2015/10/27/ 25 23

24 Lab 5 Department of Computer Science and Information Engineering National Taiwan University  However, the driver of the network card on PXA270 does not be configured in default Linux configuration.  Please try to configure the driver and build it into your kernel.  Please use “ ifconfig eth0 ” to check that your network card works. 2015/10/27/ 25 24

25 Lab 5 Department of Computer Science and Information Engineering National Taiwan University  Show your own command prompt in U-Boot.  Show that you can choose what to boot on, and it is as simple as possible.  Show that you can use “ tftp ” on your Linux kernel which has a 15M filesystem.  Please hand in your lab report to the FTP.  Server: 140.112.90.174  Username: csl2015  Password: csl2015HomeWork  Directory: lab5,6  Please use this format for filename: “G# Ver#”, where G# is your group id and Ver# is revision version number.  E.g., G1 Ver2 2015/10/27/ 25 25


Download ppt "Lab 5 Department of Computer Science and Information Engineering National Taiwan University Lab5 – Bootloader + OS Kernel 2015/10/27/ 25 1."

Similar presentations


Ads by Google