170 likes | 321 Views
Building Embedded Linux System. 2005/09/21 Reporter: sih-han wang. StrongARM. 32-bit StrongARM RISC processor 執行速度 : max 206 MHz. Bootloader Kernel Root Filesystem. Target. Cross-platform Development Environment. Host. 連結式規劃.
E N D
Building Embedded Linux System 2005/09/21 Reporter: sih-han wang
StrongARM • 32-bit StrongARM RISC processor • 執行速度:max 206 MHz
Bootloader • Kernel • Root Filesystem Target Cross-platform Development Environment Host 連結式規劃
There are four main steps to creating a target Linux system • Determine system components • Configure and build the kernel • Build root filesystem • Set up boot software and configuration
Make Kernel • 使用Linux kernel • 需要Linux kernel source + some patches if needed • cross-compiler
Kernel Configuration • make config • 這種模式需要逐行輸入所需要設定的項目,無法往前修改設定,所以目前很少使用這種方式來設定 Kernel 的項目了 • make xconfig • 這種模式則是使用 X-Window 為主要環境的設定模式!除非你有 X-Window 在執行,否則沒有辦法使用這種模式; • make menuconfig----Makefile • 這種模式有點像是文字界面的選單模式,較為簡便,而且可以在純文字界面下面執行編輯動作!
Kernel Compiling • make cleanmake menuconfig ( gzip –dc /home/ patch-2.4.18-rmk7.gz | patch –p1 –d arm-linux gzip –dc /home/ diff-2.4.18-rmk7-pxa3.gz | patch –p1 –d arm-linux) • make assabet_config • make oldconfig • make dep • make zImage Additional Options:ARCH=arm CROSS_COMPILE=arm-linux-
Make Root Filesystem Filesystem: Busybox Device node Configuration
BusyBox • Combine tiny versions of many common UNIX into a single small executable. • Provide a fairly complete environment for any small or embedded system. • BusyBox has been written with size-optimization and limited resources in mind. It is also extremely modular so you can easily include or exclude commands (or features) at compile time. This makes it easy to customize your embedded systems • Ex: ls dd cp cat tar chmod mknod find ps
Make Busybox • make menuconfig • ln –s /home/arm-linux/include/linux/version.h version.h (/usr/local/arm/2.95.3/arm-linux/include/linux) • make • make PREFIX=../busybox_arm install
Device Files 檔名 類型 主編號 次編號 權限 • mknod console c 5 1 600 • mknod tty0 c 5 0 600 • mknod mem c 1 1 600 • mknod null c 1 3 666 • mknod random c 1 8 644
initrd • initrd provides the capability to load a RAM disk by the boot loader. • This RAM disk can then be mounted as the root file system and programs can be run from it. • Afterwards, a new root file system can be mounted from a different device. The previous root (from initrd) is then moved to a directory and can be subsequently unmounted. • initrd is mainly designed to allow system startup to occur in two phases, where the kernel comes up with a minimum set of compiled-in drivers, and where additional modules are loaded from initrd.
Make INITRD image • dd if=/dev/zero of=/home/initrd.img bs=1k count=8192 • su root • mke2fs -F -v -m0 /home/initrd.img • mkdir tmp • mount -o loop initrd.img tmp/ • cp ~/root-fs/* /home/tmp/ -dpRrf • umount tmp/ • gzip -9 < initrd.img > initrd.bin 8MBfile is null mount ~/root-fs Write DATA 8MBfile with data unmount
Write Shell Script • /etc/inittab • ::sysinit:/etc/rc.S • ::askfirst:/bin/sh • /etc/rc.S • #!/bin/sh • mount -t proc proc /proc
Cross-Compiler X86 Architecture code 在/etc/bashrc中加入 PATH=$PATH:/usr/local/arm/2.95.3/bin Cross-Compiler ----------------------------- ARM(Advanced RISC Machine) execution Next