Presentation is loading. Please wait.

Presentation is loading. Please wait.

Implementation of Embedded OS

Similar presentations


Presentation on theme: "Implementation of Embedded OS"— Presentation transcript:

1 Implementation of Embedded OS
Lab1 Linux Kernel Compilation

2 Goal Learn how to build Linux kernel image for PXA270. / 18 2015/03/31

3 Environment Host System Build System Target System Software Windows XP
VirtualBox + Ubuntu 8.04 Target System Creator XScale PXA270 Software Toolchain Linux for PXA270 linux creator-pxa270.patch mkimage utility Bootloader image Root filesystem image (20M) You can download them from RSWiki IEOS Course Software / 18 2015/03/31

4 Setting up Environment
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. / 18 2015/03/31

5 Installing Toolchain Install the toolchain (cross compiler) for PXA270. Step1: download the toolchain. % wget 2/arm-linux-toolchain-bin tar.gz Step2: extract the tar.gz file to home directory. % tar zxvf arm-linux-toolchain-bin 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. / 18 2015/03/31

6 Compiling Linux Kernel (1/3)
Step1: download Linux source codes (mt-linux tar.gz) for PXA270. Step2: extract the source codes. Step3: apply the patch. % cd pxa270/create-pxa270 % wget /lab2/linux creator-pxa270.patch % patch -p0 < linux creator- pxa270.patch / 18 2015/03/31

7 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 / 18 2015/03/31

8 Compiling Linux Kernel (3/3)
There are three output files in the source tree. ./vmlinux: uncompressed image in ELF format ./arch/arm/boot/compressed/vmlinux: compressed image in ELF format ./arch/arm/boot/zImage: compressed image in raw format Decompression Function Compressed Kernel (c) ELF Header (b) Uncompressed Kernel (a) / 18 2015/03/31

9 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. / 18 2015/03/31

10 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. 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. built-in / 18 2015/03/31

11 Memory Layout of PXA270 (1/3)
The Creator XScale PXA270 board has 32MB flash and 64MB SDRAM. Flash memory ranges from 0x to 0x SDRAM ranges from 0xa to 0xa 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. / 18 2015/03/31

12 Memory Layout of PXA270 (2/3)
U-Boot 0x Linux kernel 0x 0xa U-Boot (TFTP) Root Filesystem 0x 0xa3f80000 U-Boot (domingo) 0x 0xa Flash RAM / 18 2015/03/31

13 Memory Layout of PXA270 (3/3)
Based on the memory layout, we can configure the partition of the flash in Linux kernel as follows. static struct mtd_partition creator_pxa270_partitions[] = { ... },{ name: "Kernel", offset: x , size: x , // 4M mask_flags: MTD_WRITEABLE name: "Filesystem", offset: x , size: x , // 20M } / 18 2015/03/31

14 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 / 18 2015/03/31

15 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 0xa e 0xa n "IEOS Lab1 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. / 18 2015/03/31

16 Flashing 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 / 18 2015/03/31

17 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 Lab1 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). / 18 2015/03/31

18 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. / 18 2015/03/31


Download ppt "Implementation of Embedded OS"

Similar presentations


Ads by Google