需要准备的软件包 :
系统包:
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=0x0C000000
DRAM_SIZE=0x00800000
FLASH_MEM_BASE=0x01000000
FLASH_SIZE=0x00200000
CONFIG_ARM_CLK=64000000
//64M
时钟
#
# S3C44B0X Board Driver Options
#
CONFIG_SERIAL_S3C44B0X=y
CONFIG_SERIAL_S3C44B0X_CONSOLE=y
CONFIG_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=n
CONFIG_USER_LOGIN_LOGIN=n
CONFIG_USER_OLD_PASSWORDS=n
CONFIG_USER_BUSYBOX_BUSYBOX=n
⑶
修改 config.arch
CONSOLE_BAUD_RATE = 57600
通信波特率改为与 U-BOOT
同样
⑷
修改 Makefile
和 rc
uClinux-dist//vendors/Samsung/44B0/Makefile
修改后如下:
/---------------------------------------------------------------------------------------------------------------------------
ROMFSIMG = $(IMAGEDIR)/romfs.img
ROMIMAGE = $(IMAGEDIR)/image.rom
RAMIMAGE = $(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/ram1
mount -t proc proc /proc
mount -t ext2 /dev/ram0 /var
mount -t ext2 /dev/ram1 /var
chmod 777 /ramdisk
mkdir /var/config
mkdir /var/tmp
mkdir /var/log
mkdir /var/run
mkdir /var/lock
mkdir /var/empty
ifconfig lo 127.0.0.1
route add -net 127.0.0.0 netmask 255.255.255.0 lo
ifconfig eth0 192.168.1.70 netmask 255.255.255.0 up
cat /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.c
64 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 once
create_module.c:37: for each function it appears in.)
make[6]: *** [create_module.o] Error 1
make[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 once
syscalls.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 directory
make[4]: *** [signals.o] Error 1
make[4]: Leaving directory `/opt/uClinux-dist/uClibc/libpthread/linuxthreads'
******************************************************************************/
7 编译内核
⑴
[root@localhost opt]#
make distclean
⑵
[root@localhost opt]#make menuconfig
①
选择
CPU
Vendor:Samsung
Product:44B0
②
选择内核
Kernel Version:linux-2.4.x
Libc Version:uClibc
Customize kernel setting:y
Customize 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.img
image.ram
即是可以移植的。
移植后出现 :
Error:unable to open an initial console
未解决