需要準備的軟體包:系統包:uClinux-dist-20040408.tar.gz:http://www.uclinux.org/pub/uClinux/dist/uClinux-dist-20040408.tar.gz核心包:linux-2.6.9.tar.bz2:http://www.kernel.org/pub/linux/kernel/v2.6/linux-2.6.9.tar.bz2補丁包1:linux-2.6.9-uc0.patch.gz:http://www.uclinux.org/pub/uClinux/uClinux-2.6.x/linux-2.6.9-uc0.patch.gz補丁包2:linux-2.6.9-uc0-hsc0.patch.gz:http://opensrc.sec.samsung.com/download/linux-2.6.9-uc0-hsc0.patch.gz
1 解壓uClinux-dist-20040408.tar.gz[root@localhost opt]# tar -zxvf uClinux-dist-20040408.tar.gz解壓後在目前的目錄下產生uClinux-dist目錄。
2 採用2.6.9核心[root@localhost opt]#cp linux-2.6.9.tar.bz2 uClinux-dist/[root@localhost opt]#cp linux-2.6.9-uc0.patch.gz uClinux-dist/[root@localhost opt]#cp linux-2.6.9-uc0-hsc0.patch.gz uClinux-dist/ uClinux-dist-20040408包中的2.6.x核心是2.6.2的,我用2.6.9替換掉。Linux-2.6.9.tar.bz2是核心包,linux-2.6.9-uc0.patch.gz是對針對no mmu的核心補丁,linux-2.6.9-uc0-hsc0.patch.gz是針對CPU的核心補丁。 [root@localhost uClinux-dist]#tar –jxvf linux-2.6.9.tar.bz2解壓後產生linux-2.6.9目錄。[root@localhost uClinux-dist]#mv linux-2.6.9-uc0.patch.gz linux-2.6.9/[root@localhost uClinux-dist]#mv linux-2.6.9-uc0-hsc0.patch.gz linux-2.6.9/[root@localhost uClinux-dist]#cd linux-2.6.9[root@localhost linux-2.6.9]#gzip –dc linux-2.6.9-uc0.patch.gz | patch –p1[root@localhost linux-2.6.9]#gzip –dc linux-2.6.9-uc0-hsc0.patch.gz | patch –p1[root@localhost linux-2.6.9]#cd ..[root@localhost uClinux-dist]#rm –rf linux-2.6.x[root@localhost uClinux-dist]#mv linux2.6.9 linux-2.6.x
3建立uClinux-dist/vendors/Samsung/44B0[root@localhost uClinux-dist]#cd vendors/Samsung/[root@localhost Samsung]#mkdir 44B0[root@localhost Samsung]#cp 4510B/* 44B0/[root@localhost Samsung]#cd ../../../[root@localhost Samsung]#cp linux-2.6.x/arch/armnommu/config/s3c44b0x_defconfig vendors/Samsung/44B0/config.linux-2.6.x
4 修改配置資訊[root@localhost uClinux-dist]#cd vendors/Samsung/44B0⑴修改config.linux-2.6.x## System Type#DRAM_BASE=0x0C000000DRAM_SIZE=0x00800000FLASH_MEM_BASE=0x01000000FLASH_SIZE=0x00200000CONFIG_ARM_CLK=64000000 //64M時鐘 ## S3C44B0X Board Driver Options#CONFIG_SERIAL_S3C44B0X=yCONFIG_SERIAL_S3C44B0X_CONSOLE=yCONFIG_ETH_RTL8019AS=n先屏蔽網卡驅動 ⑵修改config.vendor-2.6.x[root@localhost 44B0]#cp config.vendor-2.4.x config.vendor-2.6.x修改部分CONFIG_USER_BUSYBOX_KILLALL=nCONFIG_USER_LOGIN_LOGIN=nCONFIG_USER_OLD_PASSWORDS=nCONFIG_USER_BUSYBOX_BUSYBOX=n⑶修改config.archCONSOLE_BAUD_RATE = 57600通訊傳輸速率改為與U-BOOT同樣⑷修改Makefile和 rcuClinux-dist//vendors/Samsung/44B0/Makefile 修改後如下:/---------------------------------------------------------------------------------------------------------------------------ROMFSIMG = $(IMAGEDIR)/romfs.imgROMIMAGE = $(IMAGEDIR)/image.romRAMIMAGE = $(IMAGEDIR)/image.ram ... echo "$(VERSIONSTR) -- " `date` > $(ROMFSDIR)/etc/version cp $(ROOTDIR)/user/ramimage/ramfs2048.img / $(ROOTDIR)/romfs/etc/ramfs2048.img image: [ -d $(IMAGEDIR) ] || mkdir -p $(IMAGEDIR) genromfs -v -V "ROMdisk" -f $(ROMFSIMG) -d $(ROMFSDIR) $(CROSS_COMPILE)ld -r -o $(ROOTDIR)/$(LINUXDIR)/romfs.o / -b binary $(ROMFSIMG) $(CROSS_COMPILE)objcopy -O binary -R .note -R .comment / -S $(ROOTDIR)/$(LINUXDIR)/linux $(RAMIMAGE) cp $(ROOTDIR)/$(LINUXDIR)/arch/armnommu/boot/zImage / $(ROMIMAGE) # $(CROSS_COMPILE)objcopy -O binary --remove-section=.romvec / --remove-section=.text --remove-section=.ramvec / --remove-section=.init / --remove-section=.bss --remove-section=.eram / $(ROOTDIR)/$(LINUXDIR)/linux $(IMAGEDIR)/linux.data# $(CROSS_COMPILE)objcopy -O binary --remove-section=.ramvec / --remove-section=.bss --remove-section=.data / --remove-section=.eram / --set-section-flags=.romvec=CONTENTS,ALLOC,LOAD,READONLY,CODE / $(ROOTDIR)/$(LINUXDIR)/linux $(IMAGEDIR)/linux.text# cat $(IMAGEDIR)/linux.text $(IMAGEDIR)/linux.data $(ROMFSIMG) > $(IMAGE)---------------------------------------------------------------------------------------------------------------------------/uClinux-dist//vendors/Samsung/44B0/rc修改如下/---------------------------------------------------------------------------------------------------------------------------hostname Samsung/bin/expand /etc/ramfs.img /dev/ram0/bin/expand /etc/ramfs2048.img /dev/ram1mount -t proc proc /procmount -t ext2 /dev/ram0 /varmount -t ext2 /dev/ram1 /varchmod 777 /ramdiskmkdir /var/configmkdir /var/tmpmkdir /var/logmkdir /var/runmkdir /var/lockmkdir /var/emptyifconfig lo 127.0.0.1route add -net 127.0.0.0 netmask 255.255.255.0 loifconfig eth0 192.168.1.70 netmask 255.255.255.0 upcat /etc/motd---------------------------------------------------------------------------------------------------------------------------/
5 增加romfs⑴修改linux-2.6.x/arch/armnommu/kernel/vmlinux.lds.S*(.got) /* Global offset table */ romfs_start = .; romfs.o romfs_end = .; _etext = .; /* End of text section */⑵修改linux-2.6.x/arch/armnommu/kernel/setup.c64 extern int _stext, _text, _etext, _edata, _end;65 extern int romfs_start,romfs_end;…void __init setup_arch(char **cmdline_p){…683 char *from = default_command_line; 685 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);…⑶修改uClinux-dist/Makefile在TFTPDIR = /tftpboot 後添加LINUXTARGET = bzImage
6 修改庫檔案⑴修改uClibc/libc/sysdeps/linux/common/create_module.c//#define __NR_create_module 127改為#define __NR_create_module 127⑵修改uClibc/libc/sysdeps/linux/common/syscalls.c//#define __NR_get_kernel_syms 130改為#define __NR_get_kernel_syms 130⑶修改uClibc/include/bits/sigcontextinfo.h注釋掉//#include<linux/version.h>/******************************************************************************以上庫檔案不修改會出現的錯誤create_module.c: In function `__create_module':create_module.c:37: `__NR_create_module' undeclared (first use in this function)create_module.c:37: (Each undeclared identifier is reported only oncecreate_module.c:37: for each function it appears in.)make[6]: *** [create_module.o] Error 1make[4]: Leaving directory `/opt/uClinux-dist/uClibc/libc/sysdeps/linux/common/' syscalls.c: In function `get_kernel_syms':syscalls.c:1446: `__NR_get_kernel_syms' undeclared (first use in this function)syscalls.c:1446: (Each undeclared identifier is reported only oncesyscalls.c:1446: for each function it appears in.)make[4]: Leaving directory `/opt/uClinux-dist/uClibc/libc/sysdeps/linux/common/' In file included from signals.c:24:/opt/uClinux-dist/lib/uClibc/include/bits/sigcontextinfo.h:21: linux/version.h: No such file or directorymake[4]: *** [signals.o] Error 1make[4]: Leaving directory `/opt/uClinux-dist/uClibc/libpthread/linuxthreads'******************************************************************************/
7 編譯核心⑴[root@localhost opt]#make distclean⑵[root@localhost opt]#make menuconfig①選擇CPUVendor:SamsungProduct:44B0②選擇核心Kernel Version:linux-2.4.xLibc Version:uClibcCustomize kernel setting:yCustomize vendor/user setting:y③儲存設定④退出退出後進行參數設定,參數的設定選擇會自動按照vendors/Samsung/44B0 裡的設定檔來選擇。再配置過程會出現如下需要手動選擇的:** System Type*ARM system type 1. Atmel AT91xxx (ARCH_ATMEL) 2. Samsung S3C3410X (ARCH_S3C3410) 3. ESPD 4510B / Samsung S3C4510B (ARCH_ESPD_4510B)> 4. Samsung S3C44B0 (ARCH_S3C44B0) 5. Samsung S5C7375 (ARCH_S5C7375) 6. Samsung S3C24A0 (ARCH_S3C24A0) (NEW)choice[1-6]: 4 boa (CONFIG_USER_BOA_SRC_BOA) [N/y/?] (NEW) n配置完畢後會彈出 kernel setting 和 vendor/user setting的設定視窗,直接按exit儲存即可。⑶ make dep ⑷ make lib_only ⑸ make user_only ⑹ make romfs ⑻ make image ⑼ make linux ⑽ make image ⑿ make編譯通過後會在uClinux-dist/images 裡產生三個檔案:image.ram image.rom romfs.imgimage.ram 即是可以移植的。 移植後出現:Error:unable to open an initial console未解決