Chinaunix首页 | 论坛 | 博客
  • 博客访问: 161204
  • 博文数量: 95
  • 博客积分: 1998
  • 博客等级: 大尉
  • 技术积分: 531
  • 用 户 组: 普通用户
  • 注册时间: 2009-05-07 10:55
文章分类
文章存档

2015年(5)

2012年(4)

2011年(2)

2009年(84)

我的朋友

分类: LINUX

2009-05-20 11:21:12




【平台信息】
目标板(Nano2410)------------------------
CPU: S3C2410X
SDRAM: HY57V561620(32MB)
FLASH: K9F1208(64MB)
NET: CS8900
HOST---------------------------------------
Linux Realse Version: Fecora Cor 8 (FC8)
CrossCompiler: gcc-4.1.1/glibc-2.3.2

Linux2.6.24.4 移植到S3C2410(nano2410)之:内核移植篇
1. 解压linux-2.6.24.4。
2. 编辑Makefile,修改目标cpu 体系结构和交叉编译工具的路径。
[kevin@localhost linux-2.6.24.4]$ vim Makefile
第193 行改为:
ARCH ?= arm
CROSS_COMPILE ?= /opt/tool/gcc-4.1.1-glibc-2.3.2/arm-9tdmi-
CROSS_COMPILE 根据自己所使用的交叉编译器路径设置。
3.复制编译配置文件到linux-2.6.24.4 下面。移植过程以sdmk2410 开发板为模板。
[kevin@localhostlinux-2.6.24.4]$cp arch/arm/configs/s3c2410_defconfig .config
4.修改NandFlash 分区信息。
[kevin@localhostlinux-2.6.24.4]$vim arch/arm/plat-s3c24xx/common-smdk.c
第108 行smdk_default_nand_part[]修改如下:
static struct mtd_partition smdk_default_nand_part[] = {
#if 0
[0] = {
.name = "Boot Agent",
.size = SZ_16K,
.offset = 0,
},
[1] = {
.name = "S3C2410 flash partition 1",
.offset = 0,
.size = SZ_2M,
},
[2] = {
.name = "S3C2410 flash partition 2",
.offset = SZ_4M,
.size = SZ_4M,
},
[3] = {
.name = "S3C2410 flash partition 3",
.offset = SZ_8M,
.size = SZ_2M,
},
[4] = {
.name = "S3C2410 flash partition 4",
.offset = SZ_1M * 10,
.size = SZ_4M,
},
[5] = {
.name = "S3C2410 flash partition 5",
.offset = SZ_1M * 14,
.size = SZ_1M * 10,
},
[6] = {
.name = "S3C2410 flash partition 6",
.offset = SZ_1M * 24,
.size = SZ_1M * 24,
},
[7] = {
.name = "S3C2410 flash partition 7",
.offset = SZ_1M * 48,
.size = SZ_16M,
}
#else
[0] = {
.name = "U-Boot",
.size = SZ_1M,
.offset = 0,
},
[1] = {
.name = "Linux Kernel",
.offset = SZ_1M,
.size = SZ_3M,
},
[2] = {
.name = "Root",
.offset = SZ_4M,
.size = SZ_4M * 10,
},
[3] = {
.name = "User",
.offset = SZ_4M * 11,
.size = SZ_4M * 5,
},
#endif
};
5.为了我们的内核支持devfs 以及在启动时并在/sbin/init 运行之前能自动挂载/dev 为devfs 文件系统。编辑fs/Kconfig:
在902 行menu "Pseudo filesystems"下面添加如下代码:
#+kevin -->
config DEVFS_FS
bool "/dev file system support (OBSOLETE)"
default y
config DEVFS_MOUNT
bool "Automatically mount at boot"
default y
depends on DEVFS_FS
#+kevin <--
6.OK,现在先编译一下内核。下载到目标板看看内核能否启动。
[kevin@localhost linux-2.6.24.4]$ make menuconfig
在配置菜单中,选择system type-->s3c2410 machines 中的smdk2410
其他的arch-machines 全部取消。
[kevin@localhost linux-2.6.24.4]$ make zImage
编译完成后在arch/arm/boot 下会有一个zImage
[kevin@localhost linux-2.6.24.4]$ cd arch/arm/boot
[kevin@localhost boot]$ ls
bootp compressed Image install.sh Makefile zImage
因为使用的bootloader 是UBoot,下面需要把zImga 转换成Uboot 可以使用的uImage.
将Uboot 编译后生成的tools/mkImage 文件copy 到/bin 下面。然后允许下面的命令
mkimage -A arm -O linux -T kernel -C none -a 30008000 -e 30008040 - n "linux kernel" -d zImage
uImage
我将该命令写在一个脚本文件mk.sh 中了。执行该命令后在boot 目录会多出一个uImage 文件
[kevin@localhost boot]$ sh mk.sh
Image Name: linux kernel
Created: Sat Mar 29 16:50:21 2008
Image Type: ARM Linux Kernel Image (uncompressed)
Data Size: 1545360 Bytes = 1509.14 kB = 1.47 MB
Load Address: 0x30008000
Entry Point: 0x30008040
通过uboot 把uImage 加载到SDRAM 的0x30008000 处,并执行bootm。会看到以下启动信息。
Kevin2410 > run lk
TFTP from server 192.168.0.102; our IP address is 192.168.0.69
Filename 'uImage'.
Load address: 0x30008000
Loading: #################################################################
#########################################
done
Bytes transferred = 1545424 (1794d0 hex)
## Booting image at 30008000 ...
Image Name: linux kernel
Created: 2008-03-29 8:50:21 UTC
Image Type: ARM Linux Kernel Image (uncompressed)
Data Size: 1545360 Bytes = 1.5 MB
Load Address: 30008000
Entry Point: 30008040
Verifying Checksum ... OK
XIP Kernel Image ... OK
Starting kernel ...
Uncompressing Linux.................................................................................................... done,
booting the kernel.
Linux version 2.6.24.4 (kevin@localhost.localdomain) (gcc version 4.1.1) #1 Sat Mar 29
16:42:31 CST 2008
CPU: ARM920T [41129200] revision 0 (ARMv4T), cr=00007177
Machine: SMDK2410
Memory policy: ECC disabled, Data cache writeback
CPU S3C2410A (id 0x32410002)
S3C2410: core 202.800 MHz, memory 101.400 MHz, peripheral 50.700 MHz
S3C24XX Clocks, (c) 2004 Simtec Electronics
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:
【Uboot
中设置的command line 参数】
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 00001e4c
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: 29188KB available (2840K 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
S3C2410 Power Management, (c) 2004 Simtec Electronics
S3C2410: Initialising architecture
S3C24XX DMA Driver, (c) 2003-2004,2006 Simtec Electronics
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 c28000c0, irq 36
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 reno registered
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
s3c2410-lcd s3c2410-lcd: no platform data for lcd, cannot attach
s3c2410-lcd: probe of s3c2410-lcd failed with error -22
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
s3c2410-uart.0: s3c2410_serial0 at MMIO 0x50000000 (irq = 70) is a S3C2410
s3c2410-uart.1: s3c2410_serial1 at MMIO 0x50004000 (irq = 73) is a S3C2410
s3c2410-uart.2: s3c2410_serial2 at MMIO 0x50008000 (irq = 76) is a S3C2410
RAMDISK driver initialized: 16 RAM disks of 4096K size 1024 blocksize
loop: module loaded
dm9000 Ethernet Driver
Uniform Multi-Platform E-IDE driver Revision: 7.00alpha2
ide: Assuming 50MHz system bus speed for PIO modes; override with idebus=xx
S3C24XX NAND Driver, (c) 2004 Simtec Electronics
s3c2410-nand s3c2410-nand: Tacls=3, 29ns Twrph0=7 69ns, Twrph1=3 29ns
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-0x02c00000 : "Root"
0x02c00000-0x04000000 : "User"【分区信息】

usbmon: debugfs is not available
s3c2410-ohci s3c2410-ohci: S3C24XX OHCI
s3c2410-ohci s3c2410-ohci: new USB bus registered, assigned bus number 1
s3c2410-ohci s3c2410-ohci: irq 42, io mem 0x49000000
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
S3C24XX RTC, (c) 2004,2006 Simtec Electronics
s3c2410-i2c s3c2410-i2c: slave address 0x10
s3c2410-i2c s3c2410-i2c: bus frequency set to 99 KHz
s3c2410-i2c s3c2410-i2c: i2c-0: S3C I2C adapter
S3C2410 Watchdog Timer, (c) 2004 Simtec Electronics
s3c2410-wdt s3c2410-wdt: watchdog inactive, reset disabled, irq enabled
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: Device `eth0' not found.【网卡驱动NG】
Looking up port of RPC 100003/2 on 192.168.0.104
rpcbind: server 192.168.0.104 not responding, timed out
Root-NFS: Unable to get nfsd port number from server, using default
Looking up port of RPC 100005/1 on 192.168.0.104
rpcbind: server 192.168.0.104 not responding, timed out
Root-NFS: Unable to get mountd port number from server, using default
mount: server 192.168.0.104 not responding, timed out
Root-NFS: Server returned error -5 while mounting /nano2410/root
VFS: Unable to mount root fs via NFS, trying floppy.
VFS: Cannot open root device "nfs" or unknown-block(2,0)
Please append a correct "root=" boot option; here are the available partitions:
1f00 1024 mtdblock0 (driver?)
1f01 3072 mtdblock1 (driver?)
1f02 40960 mtdblock2 (driver?)
1f03 20480 mtdblock3 (driver?)
Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(2,0)
----------------------------------------------------------------------
从以上信息中可以看到,网卡驱动加载失败。目标板使用的是CS8900,内核中没有该网卡ic 的驱动,
下一步的工作:移植CS8900 驱动。
Linux2.6.24.4 移植到S3C2410(nano2410)之:CS8900 移植
1.将准备好的cs8900.c, cs8900.h 复制到drivers/net/arm 文件夹下。
(注意,网上大部分cs8900 驱动都是针对2.6.14 内核的,2.6.24 有很大的变动,可以下载本文开头的附件
cs8900-linux2.6.24-kevin.tar.bz2。
2.新建文件smdk2410.h
[kevin@localhost arch-s3c2410]$ pwd
/kevin/linux-2.6.24.4/include/asm-arm/arch-s3c2410
[kevin@localhost arch-s3c2410]$ vim smdk2410.h
添加如下代码:
#define pSMDK2410_ETH_IO __phys_to_pfn(0x19000000)
#define vSMDK2410_ETH_IO 0xE0000000
#define SMDK2410_EHT_IRQ IRQ_EINT9
这些宏在cs8900.c 中要用到。
3.修改mach-smdk2410.c.
[kevin@localhost mach-s3c2410]$ pwd
/kevin/linux-2.6.24.4/arch/arm/mach-s3c2410
[kevin@localhost mach-s3c2410]$ vim mach-smdk2410.c
include 建立的刚才建立的头文件smdk2410.h
#include "asm/arch/smdk2410.h
在map_desc smdk2410_iodesc[]
中添加cs8900 的对于的io 空间映射
static struct map_desc smdk2410_iodesc[] __initdata = {
/* nothing here yet */
{ vSMDK2410_ETH_IO , pSMDK2410_ETH_IO, SZ_1M, MT_DEVICE },
};
4.在/drivers/net/arm/Kconfig 中增加menu config 中CS8900 编译选项
[kevin@localhost arm]$ pwd
/kevin/linux-2.6.24.4/drivers/net/arm
[kevin@localhost arm]$ vim Kconfig
# +kevin 080327
config ARM_CS8900
tristate "CS8900 support"
depends on NET_ETHERNET && ARM && ARCH_SMDK2410
help
Support for CS8900A chipset based Ethernet cards. If you have a network
(Ethernet) card of this type, say Y and read the Ethernet-HOWTO,available from as well
as .To compile this driver as a module, choose M here and read .The module will be called
cs8900.o.
这样,在编译配置菜单”Menu config”中的Ethernet 网络设备中就可以找到”CS8900 support”的选项了。
5.在/drivers/net/arm/Makefile 中添加
obj-$(CONFIG_ARM_CS8900) += cs8900.o
6. 执行menu config。
Device drivers->network device support->Ethernet 中选择(*)CS8900 support.
7. 编译内核 make zImage
8. 将生成的uImage 重新download 到开办板SDRAM 中再来看看启动信息。
Uncompressing Linux................................................................................................... done, booting the
kernel.
Linux version 2.6.24.4 (kevin@localhost.localdomain) (gcc version 4.1.1) #2 Sat Mar 29 17:32:04 CST
2008
CPU: ARM920T [41129200] revision 0 (ARMv4T), cr=00007177
Machine: SMDK2410
Memory policy: ECC disabled, Data cache writeback
CPU S3C2410A (id 0x32410002)
S3C2410: core 202.800 MHz, memory 101.400 MHz, peripheral 50.700 MHz
S3C24XX Clocks, (c) 2004 Simtec Electronics
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:
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 00001e4c
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
S3C2410 Power Management, (c) 2004 Simtec Electronics
S3C2410: Initialising architecture
S3C24XX DMA Driver, (c) 2003-2004,2006 Simtec Electronics
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 c28000c0, irq 36
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 reno registered
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
s3c2410-lcd s3c2410-lcd: no platform data for lcd, cannot attach
s3c2410-lcd: probe of s3c2410-lcd failed with error -22
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
s3c2410-uart.0: s3c2410_serial0 at MMIO 0x50000000 (irq = 70) is a S3C2410
s3c2410-uart.1: s3c2410_serial1 at MMIO 0x50004000 (irq = 73) is a S3C2410
s3c2410-uart.2: s3c2410_serial2 at MMIO 0x50008000 (irq = 76) is a S3C2410
RAMDISK driver initialized: 16 RAM disks of 4096K size 1024 blocksize
loop: module loaded
Cirrus Logic CS8900A driver for Linux (Modified for SMDK2410)
eth0: CS8900A rev E at 0xe0000300 irq=53, addr: 00: 0:3E:26:0A: 0

Uniform Multi-Platform E-IDE driver Revision: 7.00alpha2
ide: Assuming 50MHz system bus speed for PIO modes; override with idebus=xx
S3C24XX NAND Driver, (c) 2004 Simtec Electronics
s3c2410-nand s3c2410-nand: Tacls=3, 29ns Twrph0=7 69ns, Twrph1=3 29ns
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-0x02c00000 : "Root"
0x02c00000-0x04000000 : "User"
usbmon: debugfs is not available
s3c2410-ohci s3c2410-ohci: S3C24XX OHCI
s3c2410-ohci s3c2410-ohci: new USB bus registered, assigned bus number 1
s3c2410-ohci s3c2410-ohci: irq 42, io mem 0x49000000
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
S3C24XX RTC, (c) 2004,2006 Simtec Electronics
s3c2410-i2c s3c2410-i2c: slave address 0x10
s3c2410-i2c s3c2410-i2c: bus frequency set to 99 KHz
s3c2410-i2c s3c2410-i2c: i2c-0: S3C I2C adapter
S3C2410 Watchdog Timer, (c) 2004 Simtec Electronics
s3c2410-wdt s3c2410-wdt: watchdog inactive, reset disabled, irq enabled
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 port of RPC 100003/2 on 192.168.0.104
Root-NFS: Unable to get nfsd port number from server, using default
Looking up port of RPC 100005/1 on 192.168.0.104
Root-NFS: Unable to get mountd port number from server, using default
Ok, 在linux host 系统日志中/var/log/messages 中我们可以看到来自target board 的网络连接请求信息:
Mar 29 17:35:38 localhost mountd[12381]: authenticated mount request from
192.168.0.69:736 for /nano2410/root (/nano2410/root)

网卡驱动移植成功!
下一步工作:制作rootfs!
Linux2.6.24.4 移植到S3C2410(nano2410)之:建立nfs 根文件系统(busybox1.9.2)
1. 下载最新的busybox1.9.2,并解压缩。
2. 修改Makefile 中的174 行的 arch 和编译工具链头。
ARCH ?= arm
CROSS_COMPILE ?=
/opt/tool/gcc-4.1.1-glibc-2.3.2/arm-9tdmi-linux-gnu/bin/arm-9tdmi-linux-gnu-
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-1.9.2]$ make install
在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-2.6.24.4 nfs boot "
echo " 2008-03-29 "
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-4.1.1-glibc-2.3.2/arm-9tdmi-linux-gnu/bin/arm-9tdmi-linux-gnu-readelf -d busybox
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]
0x0000000c (INIT) 0xc04c
0x0000000d (FINI) 0xa26f0
0x00000004 (HASH) 0x80e8
0x00000005 (STRTAB) 0xa384
0x00000006 (SYMTAB) 0x8b24
0x0000000a (STRSZ) 3316 (bytes)
0x0000000b (SYMENT) 16 (bytes)
0x00000015 (DEBUG) 0x0
0x00000003 (PLTGOT) 0xc00ec
0x00000002 (PLTRELSZ) 2952 (bytes)
0x00000014 (PLTREL) REL
0x00000017 (JMPREL) 0xb4c4
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-4.1.1-glibc-2.3.2/arm-9tdmi-linux-gnu/ arm-9tdmi-linux-gnu/lib/ld* .
[kevin@localhost lib]$ /opt/tool/gcc-4.1.1-glibc-2.3.2/arm-9tdmi-linux-gnu/
arm-9tdmi-linux-gnu/lib/libc-2.3.2.so .
[kevin@localhost lib]$ /opt/tool/gcc-4.1.1-glibc-2.3.2/arm-9tdmi-linux-gnu/
arm-9tdmi-linux-gnu/lib/libc.so.6 .
[kevin@localhost lib]$ /opt/tool/gcc-4.1.1-glibc-2.3.2/arm-9tdmi-linux-gnu/ arm-9tdmi-linux-gnu/lib/libm * .
[kevin@localhost lib]$ /opt/tool/gcc-4.1.1-glibc-2.3.2/arm-9tdmi-linux-gnu/
arm-9tdmi-linux-gnu/lib/libcrypt* .
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 2.6.24.4 (kevin@localhost.localdomain) (gcc version 4.1.1) #2 Sat Mar 29 17:32:04 CST
2008
CPU: ARM920T [41129200] revision 0 (ARMv4T), cr=00007177
Machine: SMDK2410
Memory policy: ECC disabled, Data cache writeback
CPU S3C2410A (id 0x32410002)
S3C2410: core 202.800 MHz, memory 101.400 MHz, peripheral 50.700 MHz
S3C24XX Clocks, (c) 2004 Simtec Electronics
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:
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 00001e4c
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
S3C2410 Power Management, (c) 2004 Simtec Electronics
S3C2410: Initialising architecture
S3C24XX DMA Driver, (c) 2003-2004,2006 Simtec Electronics
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 c28000c0, irq 36
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 reno registered
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
s3c2410-lcd s3c2410-lcd: no platform data for lcd, cannot attach
s3c2410-lcd: probe of s3c2410-lcd failed with error -22
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
s3c2410-uart.0: s3c2410_serial0 at MMIO 0x50000000 (irq = 70) is a S3C2410
s3c2410-uart.1: s3c2410_serial1 at MMIO 0x50004000 (irq = 73) is a S3C2410
s3c2410-uart.2: s3c2410_serial2 at MMIO 0x50008000 (irq = 76) is a S3C2410
RAMDISK driver initialized: 16 RAM disks of 4096K size 1024 blocksize
loop: module loaded
Cirrus Logic CS8900A driver for Linux (Modified for SMDK2410)
eth0: CS8900A rev E at 0xe0000300 irq=53, addr: 00: 0:3E:26:0A: 0
Uniform Multi-Platform E-IDE driver Revision: 7.00alpha2
ide: Assuming 50MHz system bus speed for PIO modes; override with idebus=xx
S3C24XX NAND Driver, (c) 2004 Simtec Electronics
s3c2410-nand s3c2410-nand: Tacls=3, 29ns Twrph0=7 69ns, Twrph1=3 29ns
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-0x02c00000 : "Root"
0x02c00000-0x04000000 : "User"
usbmon: debugfs is not available
s3c2410-ohci s3c2410-ohci: S3C24XX OHCI
s3c2410-ohci s3c2410-ohci: new USB bus registered, assigned bus number 1
s3c2410-ohci s3c2410-ohci: irq 42, io mem 0x49000000
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
S3C24XX RTC, (c) 2004,2006 Simtec Electronics
s3c2410-i2c s3c2410-i2c: slave address 0x10
s3c2410-i2c s3c2410-i2c: bus frequency set to 99 KHz
s3c2410-i2c s3c2410-i2c: i2c-0: S3C I2C adapter
S3C2410 Watchdog Timer, (c) 2004 Simtec Electronics
s3c2410-wdt s3c2410-wdt: watchdog inactive, reset disabled, irq enabled
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 port of RPC 100003/2 on 192.168.0.104
Looking up port of RPC 100005/1 on 192.168.0.104
VFS: Mounted root (nfs filesystem).
Freeing init memory: 116K
init started: BusyBox v1.9.2 (2008-04-01 21:32:34 CST)
starting pid 770, tty '': '/etc/init.d/rcS'
# mount all...........
chmod: /dev/null: No such file or directory
# Starting mdev.........
*********************************************************
kevin Linux-2.6.24.4 nfs boot
2008-03-29
********************************************************
starting pid 776, tty '': '/bin/sh'
Processing /etc/profile...... Linux initialized! ^_^
[root@kevin /]# uname -a
Linux kevin 2.6.24.4 #2 Sat Mar 29 17:32:04 CST 2008 armv4tl unknown
[root@kevin /]#
OK~~~ NFS 加载成功! ☺
阅读(707) | 评论(0) | 转发(4) |
给主人留下些什么吧!~~