Embedded System Design - Bubble Sort Algorithm, Embedded System Implementation
Implementation of Embedded OS
description
Transcript of Implementation of Embedded OS
Implementation of Embedded OS
Lab2 Linux Kernel Compilation
/ 182 Lab2
Goal Learn how to build Linux kernel image for
PXA270.
2014/4/1
/ 183 Lab2
Environment Host System
Windows XP Build System
VirtualBox + Ubuntu 8.04 Target System
Creator XScale PXA270 Software
Toolchain Linux for PXA270 linux-2.6.15.3-creator-pxa270.patch mkimage utility Bootloader image Root filesystem image (20M) You can download them from RSWiki IEOS Course Software
2014/4/1
/ 184 Lab2
Setting up Environment
2014/4/1
Install VirtualBox, Ubuntu 8.04, and development tools. Please refer to the slides of lab1 from the course
Computer System Laboratory (CSL). Check the evaluation board.
Please refer to the slides of lab2 from CSL.
/ 185 Lab2
Installing Toolchain
2014/4/1
Install the toolchain (cross compiler) for PXA270. Step1: download the toolchain.
% wget http://eraser.csie.ntu.edu.tw/courses/ieos/10202/lab2/arm-linux-toolchain-bin.4.0.2.tar.gz
Step2: extract the tar.gz file to home directory. % tar zxvf arm-linux-toolchain-bin.4.0.2.tar.gz -C $HOME
Step3: append installation directory (bin) to PATH. By adding “export PATH=$PATH:$HOME/arm-unknown-linux-gnu/bin” to $HOME/.bashrc
Don’t forget to logout and login again to make the change effective.
Test the newly installed cross-compiler. % arm-unknown-linux-gnu-gcc –v You will see the version number (4.0.2) in the output.
/ 186 Lab2
Compiling Linux Kernel (1/3)
Step1: download Linux source codes (mt-linux-2.6.15.3.tar.gz) for PXA270.
Step2: extract the source codes. Step3: apply the patch.
% cd pxa270/create-pxa270 % wget http://eraser.csie.ntu.edu.tw/courses/ieos/10202/lab2/linux-2.6.15.3-creator-pxa270.patch
% patch -p0 < linux-2.6.15.3-creator-pxa270.patch
2014/4/1
/ 187 Lab2
Compiling Linux Kernel (2/3)
Step4: configure the Linux kernel. Please make sure the toolchain path has been specified
in PATH and the C development library (libc6-dev) has been installed.
% cd ../linux % make mrproper % make creator_pxa270_defconfig The “make <platform>_defconfig” command will create .config by the default symbol values from arch/<architecture>/configs/<platform>_defconfig
To customize the configuration, please refer to page 9 of this slides.
Step5: compile Linux kernel. % make –j4
2014/4/1
/ 188 Lab2
Compiling Linux Kernel (3/3)
There are three output files in the source tree.a) ./vmlinux: uncompressed image in ELF formatb) ./arch/arm/boot/compressed/vmlinux: compressed image
in ELF format
c) ./arch/arm/boot/zImage: compressed image in raw format
2014/4/1
Decompression Function
Compressed Kernel
(c)
ELF Header
Decompression Function
Compressed Kernel
(b)
Uncompressed Kernel
(a)
ELF Header
/ 189 Lab2
Configuring Linux Kernel (1/2)
The Linux kernel build system (Kbuild) supports a variety of configuration methods, and the most commonly used method is: % make menuconfig
Please install libncurses5-dev package in Ubuntu.
2014/4/1
/ 1810 Lab2
Configuring Linux Kernel (2/2)
Many features and drivers are available as modules, and it is possible to choose whether to build them into the kernel. Please always build modules into the kernel, i.e., <*>, in our
Labs. In lab2, you need to add the NIC driver into the kernel as follows.
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.
2014/4/1
built-in
/ 1811 Lab2
Memory Layout of PXA270 (1/3)
The Creator XScale PXA270 board has 32MB flash and 64MB SDRAM. Flash memory ranges from 0x00000000 to
0x02000000. SDRAM ranges from 0xa0000000 to 0xa4000000.
The locations and sizes of kernel image and root filesystem are specified in Linux kernel (in arch/arm/mach-pxa/mach-creator-pxa270.c). The structure of creator_pxa270_partitions[] is at
line 248.
2014/4/1
/ 1812 Lab2
Memory Layout of PXA270 (2/3)
2014/4/1
0x00000000
0x00080000
0x00480000
0x01880000
0x02000000
U-Boot
Linux kernel
Root Filesystem
Flash
0xa0000000
0xa1080000
0xa3f80000
0xa4000000
U-Boot (TFTP)
RAM
U-Boot (domingo)
/ 1813 Lab2
Memory Layout of PXA270 (3/3)
Based on the memory layout, we can configure the partition of the flash in Linux kernel as follows.
2014/4/1
static struct mtd_partition creator_pxa270_partitions[] = { ... },{ name: "Kernel", offset: 0x00080000, size: 0x00400000, // 4M mask_flags: MTD_WRITEABLE },{ name: "Filesystem", offset: 0x00480000, size: 0x01400000, // 20M } ...
/ 1814 Lab2
Converting to U-Boot Bootable Image (1/2)
Since U-Boot has its own format for kernel images, we need to convert the Linux kernel image (vmlinux) to U-Boot bootable image (uImage).
Step1: get the raw binary file. % arm-unknown-linux-gnu-objcopy -O binary -R .note -R .comment -S arch/arm/boot/compressed/vmlinux linux.bin
Step2: compress the raw binary. % gzip -9 linux.bin
2014/4/1
/ 1815 Lab2
Converting to U-Boot Bootable Image (2/2)
Step3: add the header of U-Boot bootable image. % chmod +x mkimage % ./mkimage -A arm -O linux -T kernel -C gzip -a 0xa0008000 -e 0xa0008000 -n "IEOS Lab2 Kernel" -d linux.bin.gz uImage
mkimage can be downloaded from our course website (mkimage). You can see the mkimage usage by executing without arguments.
The resulting uImage is the U-Boot image we want.
2014/4/1
/ 1816 Lab2
Flashing
2014/4/1
Please refer to the slides of lab2 from CSL for the steps of copying bootloader, kernel, and filesystem.
Use the following files instead. Bootloader: u-boot.bin Linux kernel: the one you just compiled (uImage). Filesystem: rootfs_20M
/ 1817 Lab2
Testing Your Kernel Image (1/2)
After resetting PXA270, you will see your own Linux kernel is booted. U-Boot will display the image name “IEOS Lab2
Kernel” when loading the kernel image. After Linux is booted, use df -h to check the size
of filesystem. You will see the size of root filesystem
(/dev/mtdblock3).
2014/4/1
/ 1818 Lab2
Testing Your Kernel Image (2/2)
Check the NIC driver has been compiled into the kernel. Please use ifconfig eth0 to check your network
card.
2014/4/1