嵌入式软件工程师&&太极拳
全部博文(548)
分类: 嵌入式
2012-04-25 16:31:08
在S3C4510B上运行uClinux-2.6的过程(romfs直接链入image.ram)
假设工作目录为/root
step 1 将下面4个文件下载到/root目录中
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 (root@localhost.localdomain) (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:
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)
/>