170 likes | 378 Views
Computer System Laboratory. Lab5 - OS Kernel. Experimental Goal. Learn how to build Linux kernel image for PXA270. . Environment. Host System Windows XP Build System VirtualBox + Ubuntu 8.04 Target System Creator XScale PXA270 Software Linux for PXA270
E N D
Computer System Laboratory Lab5 - OS Kernel
Experimental Goal • Learn how to build Linux kernel image for PXA270. / 17
Environment • Host System • Windows XP • Build System • VirtualBox + Ubuntu 8.04 • Target System • Creator XScale PXA270 • Software • Linux for PXA270 • linux-2.6.15.3-creator-pxa270.patch • Root filesystem image (15M) • mkimage utility • You can download all software from RSWiki CSL Course Software / 17
Linux Kernel Version Numbering • 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 kerneland 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. reference: wikipedia – Linux kernel http://en.wikipedia.org/wiki/Linux_kernel / 17
Linux Kernel Compilation (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/csl/10201/lab5/software/linux-2.6.15.3-creator-pxa270.patch • % patch -p0 < linux-2.6.15.3-creator-pxa270.patch / 17
Linux Kernel Compilation (2/3) • Step4: configure the Linux kernel (check Lab3’s arm-unknown-linux-gnu-* toolchain path in PATH). • % cd ../linux • % make mrproper • % make creator_pxa270_defconfig • The “make <platform>_defconfig” command will create .config by the default symbol values from arch/<platform>/configs/<platform>_defconfig • Step5: compile Linux kernel. • % make –j4 / 17
Linux Kernel Compilation (3/3) • The resulting zImage in arch/arm/boot is the compressed kernel image we want. / 17
Linux Kernel Configuration (1/2) • 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. / 17
Linux Kernel Configuration (2/2) • 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. built-in module / 17
Memory Layout of PXA270 (1/3) • 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 bootm80000 • 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). / 17
Memory Layout of PXA270 (2/3) 0xa0000000 0x00000000 U-Boot 0x00080000 Linux kernel 0x00480000 0xa1080000 U-Boot (TFTP) Root Filesystem 0x01380000 0xa3f80000 U-Boot (domingo) 0x02000000 0xa4000000 Flash RAM / 17
Memory Layout of PXA270 (3/3) • Based on the memory layout, we can configure our Linux kernel. static structmtd_partition creator_pxa270_partitions[] = { ... },{ name: "Kernel", offset: 0x00080000, size: 0x00400000, // 4M mask_flags: MTD_WRITEABLE },{ name: "Filesystem", offset: 0x00480000, size: 0x00f00000, // 15M } ... / 17
Convert to U-Boot Bootable Image (1/2) • 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). • Step1: get raw binary file. • % arm-unknown-linux-gnu-objcopy-O binary -R .note -R .comment -S arch/arm/boot/compressed/vmlinuxlinux.bin • Step2: compress kernel image (optional). • % gzip -9 linux.bin / 17
Convert to U-Boot Bootable Image (2/2) • Step3: 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 and can be downloaded from our course website (mkimage). • You can see the mkimageusage by executing without arguments. • The resulting uImage is the U-Boot image we want. / 17
Test Your Linux Kernel (1/2) • Please refer to Lab2 to copy new Linux kernel and root filesystem to flash. • Step1: download new 15M rootfs (root filesystem). • Step2: copy your uImage to flash. • Step3: copy new rootfs to flash. (take about 7 minutes) • Step4: 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. / 17
Test Your Linux Kernel (2/2) • 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. / 17
Lab Requirement & Bonus • Show that you can use tftp on your Linux kernel which has a 15M filesystem. • Bonus:Answer the question of lab5 on RSWiki CSL course website.Write it in your report. • Please send your report to both TAs. • csiedatou@gmail.com, meenchen79@gmail.com • Please use this title format: [CSL] G# Lab# Ver# • E.g., [CSL] G13 Lab5 Ver1 / 17