假設工作目錄為/root step 1 將下面4個文件下載到/root目錄中 http://www.UCLinux.org/pub/uClinux/dist/uClinux-dist-20041215.tar.gz http://opensrc.sec.samsung.com/download/arm-uclinux-tools-base-gcc3.4.0-20040713.sh http://opensrc.sec.samsung.com/download/linux-2.6.9-hsc0.patch.gz http://www.kernel.org/pub/linux/kernel/v2.6/linux-2.6.9.tar.bz2 step 2 安裝arm-uclinux編譯器 執行 sh arm-uclinux-tools-base-gcc3.4.0-20040713.sh 修改 /root/.bash_profile,修改環境變量PATH PATH=$PATH:$HOME/bin:$HOME/arm-uclinux-tool/bin 可以測試一下arm-uclinux-gcc -v,應該可以其版本信息 step 3 釋放內核源代碼 依次執行如下命令 tar -zxvf uClinux-dist-20041215.tar.gz cd uClinux-dist tar -jxvf ../linux-2.6.9.tar.bz2 gzip -dc ../linux-2.6.9-hsc0.patch.gz patch -p0 rm -rf linux-2.6.x mv linux-2.6.9 linux-2.6.x cp linux-2.6.x/arch/armnommu/configs/espd_4510b_defconfig vendor/Samsung/4510B/config.linux-2.6.x (kernel配置) cp vendor/Samsung/4510B/config.vendor-2.4.x vendor/Samsung/4510B/config.vendor-2.6.x (vendor配置,保持與2.4一致即可) step 4 修改內核 修改vendor/Samsung/4510B/Makefile,添加如下內容 63 image: 64 [ -d $(IMAGEDIR) ] mkdir -p $(IMAGEDIR) 65 genromfs -v -V "ROMdisk" -f $(ROMFSIMG) -d $(ROMFSDIR) 66 arm-uclinux-ld -r -o $(ROOTDIR)/$(LINUXDIR)/romfs.o -b binary $(ROMFSIMG) 67 $(CROSS_COMPILE)objcopy -O binary --remove-section=.romvec 68 --remove-section=.text --remove-section=.ramvec 69 --remove-section=.init 70 --remove-section=.bss --remove-section=.eram 71 $(ROOTDIR)/$(LINUXDIR)/linux $(IMAGEDIR)/linux.data 修改vendor/Samsung/4510B/rc,將最後一行的dhcpcd屏蔽掉 11 cat /etc/motd 12 ifconfig lo 127.0.0.1 13 route add -net 127.0.0.0 netmask 255.255.255.0 lo 14 #dhcpcd & 修改vendor/config/armnommu/config.arch, 將arm-elf改為arm-uclinux 40 MACHINE = arm 41 ARCH = armnommu 42 CROSS_COMPILE = arm-uclinux- 43 CROSS = $(CROSS_COMPILE) 修改linux-2.6.x/arch/armnommu/arch/kernel/vmlinux-lds, 添加romfs.o 78 *(.got) /* Global offset table */ 79 80 romfs_start = .; 81 romfs.o 82 romfs_end = .; 修改linux-2.6.x/arch/armnommu/kernel/setup.c,添加變量romfs_start,romfs_end及設置default_command_line 64 extern int _stext, _text, _etext, _edata, _end; 65 extern int romfs_start,romfs_end; 682 char *from = default_command_line; 683 sprintf(default_command_line, "root=/dev/ram0 initrd=0x%08lx,%ldk keepinitrd", (unsigned long)&romfs_start,((unsigned long)&romfs_end - (unsigned long)&romfs_start)>>10); step 5 配置內核 執行make menconfig,以下全選上,然後保存退出,其余具體各項配置暫不更改 (linux-2.6.x) Kernel Version (uClibc) Libc Version Default all settings (lose changes) (NEW) Customize Kernel Settings (NEW) Customize Vendor/User Settings (NEW) Update Default Vendor Settings (NEW) 第一次配置退出可能還會要求選擇板類型,直接按數字選espd_4510b即可 step 6 編譯 執行 make 執行完後images目錄中會有image.ram文件,利用bootloader將其加載到0x8000地址處執行,接上串口就能看到如下信息了 Linux version 2.6.9-hsc0 ([email protected]) (gcc version 3.4 .3) #24 Thu Jun 30 00:04:47 EDT 2005 CPU: Samsung-S3C4510B [36807001] revision 1 (ARMv4T) Machine: ESPD 4510B(S3C4510B) Warning: bad configuration page, trying to continue Built 1 zonelists Kernel command line: root=/dev/ram0 initrd=0x0011d000,884k keepinitrd PID hash table entries: 128 (order: 7, 2048 bytes) Dentry cache hash table entries: 4096 (order: 2, 16384 bytes) Inode-cache hash table entries: 2048 (order: 1, 8192 bytes) Memory: 16MB = 16MB total Memory: 14080KB available (1936K code, 122K data, 56K init) Mount-cache hash table entries: 512 (order: 0, 4096 bytes) checking if image is initramfs...it isn't (ungzip failed); looks like an initrd NET: Registered protocol family 16 ttyS0 at I/O 0x3ffd000 (irq = 4) is a Samsung S3C4510B Internal UART ttyS1 at I/O 0x3ffe000 (irq = 6) is a Samsung S3C4510B Internal UART RAMDISK driver initialized: 16 RAM disks of 1024K size 1024 blocksize loop: loaded (max 8 devices) Samsung S3C4510B Ethernet Driver version 0.2 (2004-06-13) NET: Registered protocol family 2 IP: routing cache hash table of 512 buckets, 4Kbytes TCP: Hash tables configured (established 1024 bind 2048) NET: Registered protocol family 1 NET: Registered protocol family 17 RAMDISK: romfs filesystem found at block 0 RAMDISK: Loading 881KiB [1 disk] into ram disk... done. VFS: Mounted root (romfs filesystem) readonly. Freeing init memory: 56K Shell invoked to run file: /etc/rc Command: hostname Samsung Command: /bin/eXPand /etc/ramfs.img /dev/ram1 Command: mount -t proc proc /proc Command: mount -t ext2 /dev/ram1 /var Command: mkdir /var/config Command: mkdir /var/tmp Command: mkdir /var/log Command: mkdir /var/run Command: mkdir /var/lock Command: mkdir /var/empty Command: cat /etc/motd Welcome to ____ _ _ / __ _ _ _ _ ____ _ _ _ _ _ \ \ \/ / _ __ _ / ___\_______ _\____\_/\_/ _ For further information check: http://www.uclinux.org/ Command: ifconfig lo 127.0.0.1 Command: route add -net 127.0.0.0 netmask 255.255.255.0 lo Execution Finished, Exiting Sash command shell (version 1.1.1) />