分类: 嵌入式
2009-11-15 14:51:10
Linux
【平台信息】
目标板(Nano2410)------------------------
CPU: S
SDRAM: HY57V561620(32MB)
FLASH: K
NET: CS8900
HOST---------------------------------------
Linux Realse Version: Fecora Cor 8 (FC8)
CrossCompiler: gcc-
【移植步骤】
1. 下载最新的busybox
2. 修改Makefile中的174行的 arch和编译工具链头。
ARCH ?= arm
CROSS_COMPILE ?= /opt/tool/gcc-
3. make menuconfig. 修改编译配置选项。
install optin-->
[*] Don't use /usr
Busybox Library Tuning --->
(2) MD5: Trade Bytes for Speed
[*] Faster /proc scanning code (+100 bytes)
[*] Support for /etc/networks
[*] Support for /etc/networks
[*] Additional editing keys
[*] vi-style line editing commands
[*] History saving
[*] Tab completion
[*] Username completion
[*] Fancy shell prompts
--- Ash Shell Options 下面的选项全部选择
Linux Module Utilities --->
[*] Support version 2.6.x Linux kernels
Build Options ---> (采用动态lib链接)
[ ] Build BusyBox as a static binary (no shared libs)
4.编译busybox
[kevin@localhost busybox-
在busybox/_install 目录下会生成我们需要的文件。
5. 修改_install/bin/busybox的属性。为4755
chmod 4755 ./_install/bin/busybox
必须要要修改属性,否则在busybox中很多命令会受限制,比如:
[kevin@kevin /]$ su
su: must be suid to work properly
6.建立root fs的文件系统所需的目录和文件。
Mkdir /nano2410
Mkdir /nano2410/root
在root文件夹中建立基本的目录
[kevin@localhost nano2410]$ tree root 5
root
|-- bin
|-- boot
|-- dev
|-- etc
|-- home
|-- lib
| `-- modules
|-- makedir
|-- mnt
| |-- data
| |-- etc
| |-- jffs2
| |-- temp
| `-- yaffs
|-- proc
|-- root
|-- sbin
|-- sys
|-- tmp
|-- usr
| |-- bin
| |-- lib
| `-- sbin
`-- var
|-- lib
|-- lock
|-- log
|-- run
`-- tmp
可以通过以下脚本文件来建立。
[kevin@localhost nano2410]$ vi makedir
#! /bin/sh
echo "making dir : bin dev etc lib proc sbin sys usr"
cd root
mkdir bin dev etc lib proc sbin sys usr #必备的8个目录
mkdir usr/bin usr/lib usr/sbin lib/modules
# Don't use mknod ,unless you run this Script as root !
# mknod -m 600 dev/console c 5 1
# mknod -m 666 dev/null c 1 3
echo "making dir : mnt tmp var"
mkdir mnt tmp var
chmod 1777 tmp
mkdir mnt/etc mnt/jffs2 mnt/yaffs mnt/data mnt/temp
mkdir var/lib var/lock var/log var/run var/tmp
chmod 1777 var/tmp
echo "making dir : home root boot"
mkdir home root boot
echo "done"
运行脚本文件makedir
[kevin@localhost nano2410]$ sh makedir
这样在root目录下就会生成以上列出的文件。
6. 以root身份建立节点文件/dev/console, /dev/null
mknod -m 600 dev/console c 5 1
mknod -m 666 dev/null c 1 3
7. 为shell加入全局变量文件/etc/profile,内容如下:
# /etc/profile: system-wide .profile file for the Bourne shells
echo
echo -n "Processing /etc/profile...... "
# Set search library path
export LD_LIBRARY_PATH=/lib:/usr/lib
# Set user path
PATH=/bin:/sbin:/usr/bin:/usr/sbin
export PATH
# Set PS1
USER="`id -un`"
LOGNAME=$USER
PS1='[\u@\h \W]\$ '
PATH=$PATH
echo “Done ... “
8. 增加初始化文件inittab和fstab
[kevin@localhost etc]$ vi fstab
proc /proc proc defaults i 0 0
none /tmp ramfs defaults 0 0
mdev /dev ramfs defaults 0 0
sysfs /sys sysfs defaults 0 0
[kevin@localhost etc]$ vi inittab
::sysinit:/etc/init.d/rcS
::respawn:-/bin/sh
tty2::askfirst:-/bin/sh
::ctrlaltdel:/bin/umount -a -r
::shutdown:/bin/umount -a -r
::shutdown:/sbin/swapoff -a
9. 增加初始化脚本文件。
[kevin@localhost etc]$ mkdir init.d
[kevin@localhost etc]$ vim init.d/rcS
#! /bin/sh
# 设置主机名,需要在etc建立文件host
. /etc/host
hostname ${HOSTNAME}
# mount all filesystem defined in “fstab”
echo "# mount all..........."
/bin/mount -a
#+kevin
#/bin/chmod 0666 /dev/null
echo "# Starting mdev........."
/bin/echo /sbin/mdev > /proc/sys/kernel/hotplug
mdev -s
echo "*********************************************************"
echo " kevin Linux-
echo "
echo "********************************************************"
echo
10.建立主机名存储文件/etc/host
[kevin@localhost etc]$ vim host
HOSTNAME=kevin
#如果不指定主机名,默认的为www。
11.建立文件/etc/mdev.conf,内容为空
[kevin@localhost etc]$ vi mdev.conf
12.复制主机/etc/下面的文件passwd, group, shadow文件到/etc
[kevin@localhost etc]$ cp /etc/group .
[kevin@localhost etc]$ cp /etc/passwd .
[kevin@localhost etc]$ cp /etc/shadow .
并修改用户passwd中用户使用的shell名称。FC8上默认的为bash,uboot中只支持ash。
root:x:0:0:root:/root:/bin/bash -->
root:x:0:0:root:/root:/bin/ash
kevin:x:500:500:kevin:/home/kevin:/bin/bash -->
kevin:x:500:500:kevin:/home/kevin:/bin/ash
ok,所需要的文件都已经建立ok了
[kevin@localhost etc]$ ls
fstab group host init.d inittab mdev.conf passwd profile shadow
13.复制刚刚编译的busybox到/root目录下
[kevin@localhost _install]$ sudo cp -Rfv * /nano2410/root
14.因为是编译的时候使用的是动态链接。所以先看看/busybox/_install/bin/busybox使用了哪些lib,然后从glibc复制相应的lib到/nano2410/root/lib中。
[kevin@localhost bin]$ /opt/tool/gcc-
Dynamic section at offset 0xb8014 contains 22 entries:
Tag Type Name/Value
0x00000001 (NEEDED) Shared library:[libcrypt.so.1]
0x00000001 (NEEDED) Shared library: [libm.so.6]
0x00000001 (NEEDED) Shared library: [libc.so.6]
0x
0x0000000d (FINI) 0xa
0x00000004 (HASH) 0x80e8
0x00000005 (STRTAB) 0xa384
0x00000006 (SYMTAB) 0x8b24
0x
0x0000000b (SYMENT) 16 (bytes)
0x00000015 (DEBUG) 0x0
0x00000003 (PLTGOT) 0xc00ec
0x00000002 (PLTRELSZ) 2952 (bytes)
0x00000014 (PLTREL) REL
0x00000017 (JMPREL) 0xb
0x00000011 (REL) 0xb454
0x00000012 (RELSZ) 112 (bytes)
0x00000013 (RELENT) 8 (bytes)
0x6ffffffe (VERNEED) 0xb384
0x6fffffff (VERNEEDNUM) 3
0x6ffffff0 (VERSYM) 0xb078
0x00000000 (NULL) 0x0
复制lib 文件:
[kevin@localhost lib]$ /opt/tool/gcc-
[kevin@localhost lib]$ /opt/tool/gcc-
[kevin@localhost lib]$ /opt/tool/gcc-
[kevin@localhost lib]$ /opt/tool/gcc-
[kevin@localhost lib]$ /opt/tool/gcc-
15.启用host PC上的nfs rootfs文件夹/nano2410/root
[root@localhost ~]# vim /etc/exports
/nano2410/root *(rw,sync,no_root_squash)
# 如果PC通过路由器连接targetboad 请使用下面的配置,否则targetboad不能访问
# Pc上的nfs. 192.168.0.xxx我的局域网使用的网段
# rw:可读写,no_root_squash:允许非root用户操作改文件夹
/nano2410/root 192.168.0.xxx(rw,sync,no_root_squash)
以root身份启动nfs 服务:
[root@localhost ~]# /etc/init.d/nfs start
16. 设定uboot的命令行参数。
bootargs=console=ttySAC0,115200 root=/dev/nfs init=/linuxrc nfsroot=192.168.0.10
4:/nano2410/root ip=192.168.0.69:192.168.0.104:192.168.0.1:255.255.255.0:
in.com:eth0:off
targetboard IP addr : 192.168.0.69
Host PC IP addr : 192.168.0.104
Gateway : 192.168.0.1
Nfs dir : 192.168.0.104:/nano2410/root
17.reset targetboard,看看启动信息~~
Starting kernel ...
Uncompressing Linux................................................................................................... done, booting the kernel.
Linux version
CPU: ARM920T [41129200] revision 0 (ARMv4T), cr=00007177
Machine: SMDK2410
Memory policy: ECC disabled, Data cache writeback
CPU S
S
S
CLOCK: Slow mode (1.500 MHz), fast, MPLL on, UPLL on
CPU0: D VIVT write-back cache
CPU0: I cache: 16384 bytes, associativity 64, 32 byte lines, 8 sets
CPU0: D cache: 16384 bytes, associativity 64, 32 byte lines, 8 sets
Built 1 zonelists in Zone order, mobility grouping on. Total pages: 8128
Kernel command line: console=ttySAC0,115200 root=/dev/nfs init=/linuxrc nfsroot=192.168.0.104:/nano2410/root ip=192.168.0.69:192.168.0.104:192.168.0.1:255.255.255.0:in.com:eth0:off
irq: clearing pending ext status 00000200
irq: clearing subpending status 00000002
PID hash table entries: 128 (order: 7, 512 bytes)
timer tcon=00500000, tcnt a509, tcfg 00000200,00000000, usec 00001e
Console: colour dummy device 80x30
console [ttySAC0] enabled
Dentry cache hash table entries: 4096 (order: 2, 16384 bytes)
Inode-cache hash table entries: 2048 (order: 1, 8192 bytes)
Memory: 32MB = 32MB total
Memory: 29196KB available (2836K code, 296K data, 116K init)
Mount-cache hash table entries: 512
CPU: Testing write buffer coherency: ok
net_namespace: 64 bytes
NET: Registered protocol family 16
S
S
S
DMA channel 0 at c2800000, irq 33
DMA channel 1 at c2800040, irq 34
DMA channel 2 at c2800080, irq 35
DMA channel 3 at c
usbcore: registered new interface driver usbfs
usbcore: registered new interface driver hub
usbcore: registered new device driver usb
NET: Registered protocol family 2
IP route cache hash table entries: 1024 (order: 0, 4096 bytes)
TCP established hash table entries: 1024 (order: 1, 8192 bytes)
TCP bind hash table entries: 1024 (order: 0, 4096 bytes)
TCP: Hash tables configured (established 1024 bind 1024)
TCP
NetWinder Floating Point Emulator V0.97 (double precision)
JFFS2 version 2.2. (NAND) 漏 2001-2006 Red Hat, Inc.
io scheduler noop registered
io scheduler anticipatory registered (default)
io scheduler deadline registered
io scheduler cfq registered
s
s
lp: driver loaded but no devices found
ppdev: user-space parallel port driver
Serial: 8250/16550 driver $Revision: 1.90 $ 4 ports, IRQ sharing enabled
s
s
s
RAMDISK driver initialized: 16 RAM disks of 4096K size 1024 blocksize
loop: module loaded
Cirrus Logic CS
eth0: CS
Uniform Multi-Platform E-IDE driver Revision: 7.00alpha2
ide: Assuming 50MHz system bus speed for PIO modes; override with idebus=xx
S
s
NAND device: Manufacturer ID: 0xec, Chip ID: 0x76 (Samsung NAND 64MiB 3,3V 8-bit)
Scanning device for bad blocks
Creating 4 MTD partitions on "NAND 64MiB 3,3V 8-bit":
0x00000000-0x00100000 : "U-Boot"
0x00100000-0x00400000 : "Linux Kernel"
0x00400000-0x
0x
usbmon: debugfs is not available
s
s
s
usb usb1: configuration #1 chosen from 1 choice
hub 1-0:1.0: USB hub found
hub 1-0:1.0: 2 ports detected
mice: PS/2 mouse device common for all mice
S
s
s
s
S
s
TCP cubic registered
NET: Registered protocol family 1
RPC: Registered udp transport module.
RPC: Registered tcp transport module.
drivers/rtc/hctosys.c: unable to open rtc device (rtc0)
IP-Config: Complete:
device=eth0, addr=192.168.0.69, mask=255.255.255.0, gw=192.168.0.1,
host=www, domain=, nis-domain=kevin.com,
bootserver=192.168.0.104, rootserver=192.168.0.104, rootpath=
Looking up
Looking up
VFS: Mounted root (nfs filesystem).
Freeing init memory: 116K
init started: BusyBox v
starting pid 770, tty '': '/etc/init.d/rcS'
# mount all...........
chmod: /dev/null: No such file or directory
# Starting mdev.........
*********************************************************
kevin Linux-
********************************************************
starting pid 776, tty '': '/bin/sh'
Processing /etc/profile...... Linux initialized! ^_^
[root@kevin /]# uname -a
Linux kevin
[root@kevin /]#
OK~~~ NFS 加载成功! J