分类: 嵌入式
2010-01-10 17:28:09
Linux
【平台信息】
目标板(Nano2410)------------------------
CPU: S
SDRAM: HY57V561620(32MB)
FLASH: K
NET: CS8900
HOST---------------------------------------
Linux Realse Version: Fecora Cor 8 (FC8)
CrossCompiler: gcc-
【移植步骤】
1. 解压linux-
2. 编辑Makefile,修改目标cpu体系结构和交叉编译工具的路径。
[kevin@localhost linux-
第193行改为:
ARCH ?= arm
CROSS_COMPILE ?= /opt/tool/gcc-
CROSS_COMPILE根据自己所使用的交叉编译器路径设置。
3. 复制编译配置文件到linux-
[kevin@localhostlinux-
4.修改NandFlash分区信息。
[kevin@localhostlinux-
第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 = "S
.offset = 0,
.size = SZ_
},
[2] = {
.name = "S
.offset = SZ_
.size = SZ_
},
[3] = {
.name = "S
.offset = SZ_
.size = SZ_
},
[4] = {
.name = "S
.offset = SZ_
.size = SZ_
},
[5] = {
.name = "S
.offset = SZ_
.size = SZ_
},
[6] = {
.name = "S
.offset = SZ_
.size = SZ_
},
[7] = {
.name = "S
.offset = SZ_
.size = SZ_
}
#else
[0] = {
.name = "U-Boot",
.size = SZ_
.offset = 0,
},
[1] = {
.name = "Linux Kernel",
.offset = SZ_
.size = SZ_
},
[2] = {
.name = "Root",
.offset = SZ_
.size = SZ_
},
[3] = {
.name = "User",
.offset = SZ_
.size = SZ_
},
#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-
在配置菜单中,选择system type-->s
其他的arch-machines全部取消。
[kevin@localhost linux-
编译完成后在arch/arm/boot下会有一个zImage
[kevin@localhost linux-
[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
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 ...
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:【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 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: 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
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
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
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: Device `eth0' not found.【网卡驱动NG】
Looking up
rpcbind: server 192.168.0.104 not responding, timed out
Root-NFS: Unable to get nfsd port number from server, using default
Looking up
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:
Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(2,0)
----------------------------------------------------------------------
从以上信息中可以看到,网卡驱动加载失败。目标板使用的是CS8900,内核中没有该网卡ic的驱动,下一步的工作:移植CS8900驱动。
待续………………