Chinaunix首页 | 论坛 | 博客
  • 博客访问: 63582
  • 博文数量: 12
  • 博客积分: 331
  • 博客等级: 一等列兵
  • 技术积分: 196
  • 用 户 组: 普通用户
  • 注册时间: 2012-02-16 10:40
文章分类
文章存档

2012年(12)

我的朋友

分类: LINUX

2012-04-19 07:48:37

 移植过程主要是按照友善之臂的移植手册上来的。

主要是向目标平台初始化代码(也就是mach-mini2440.c,这个文件在arch/arm/mach-s3c2440目录中)中添加一些代码。下面详细说明。

首先在mach-mini2440.c中添加头文件dm9000.h,在定义DM9000网卡设备的物理基地址。就是加上下面几行代码。


再填充该平台设备的资源设置,以便和 DM9000 网卡驱动接口配合起来,如下(pstary)

static struct resource mini2440_dm9k_resource[] = {
[0] = {
.start = MACH_MINI2440_DM9K_BASE,
.end = MACH_MINI2440_DM9K_BASE + 3,
.flags = IORESOURCE_MEM
},
[1] = {
.start = MACH_MINI2440_DM9K_BASE + 4,
.end = MACH_MINI2440_DM9K_BASE + 7,
.flags = IORESOURCE_MEM
},
[2] = {
.start = IRQ_EINT7,
.end = IRQ_EINT7,
.flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE,
}
};
/*
* * * The DM9000 has no eeprom, and it's MAC address is set by
* * * the bootloader before starting the kernel.
* * */
static struct dm9000_plat_data mini2440_dm9k_pdata = {
.flags = (DM9000_PLATF_16BITONLY | DM9000_PLATF_NO_EEPROM),
};
static struct platform_device mini2440_device_eth = {
.name = "dm9000",
.id = -1,
.num_resources = ARRAY_SIZE(mini2440_dm9k_resource),
.resource = mini2440_dm9k_resource,
.dev = {
.platform_data = &mini2440_dm9k_pdata,
},
};
//;同时在mini2440 设备集中添加上面做好的网卡平台设备,如下

修改完成以后,DM9000的平台接口就完成了。

因为 Linux-2.6.32.2 的DM9000 网卡驱动并不是专门为mini2440 准备的,所以还要在其源代码中做一些移植工作,调整DM9000 所用的位宽寄存器,配置DM9000 所用片选总线的时序,如下步骤。

打开 linux-2.6.32.2/ drivers/net/dm9000.c,头文件处添加2410 相关的配置定义


做完之后,在make menuconfg中加入对DM9000的支持,默认选上了。那么我们直接make zImage

下载到板子上,在终端中查看

可知,移植成功。

 

在编译之前,需要确认在内核中已经配置了网卡驱动

【1】在内核目录下执行:

[root@localhost linux-2.6.32.2]# make menuconfig

在打开的配置菜单Device Drivers --->Network device support ---> Ethernet (10 or 100Mbit) --->,可以看到如下图

Linux-2.6.32.2内核在mini2440上的移植(三)---DM9000网卡驱动移植 - singleboy - singleboy的博客

DM9000 已经被选中,这是因为Linux-2.6.32.2默认的内核配置已经加入了DM9000 的支持。


【2】编译

[root@localhost linux-2.6.32.2]# make clean
[root@localhost linux-2.6.32.2]# make uImage

编译完成后生成zImage 和 uImage

【3】进行网卡驱动测试

(1)采用友善官方已经移植好的根文件系统,可以从其提供的光盘映像/linux目录下直接复制过来。
[root@localhost ~]# cd linux-test
[root@localhost linux-test]# ls
busybox-1.13.3 mkyaffs2image.tgz
busybox-1.13.3-mini2440.tgz myrootfs
busybox-1.18.4 rootfs_qtopia_qt4
busybox-1.18.4.tar.bz2 rootfs_qtopia_qt4-20110304.tar.gz
linux-2.6.32.2 usr
linux-2.6.39 yaffs2
[root@localhost linux-test

(2)将其复制到宿主机/nfsboot目录下并命名为roorfs

[root@localhost linux-test]# cp -rf rootfs_qtopia_qt4 /nfsboot/rootfs
[root@localhost linux-test]#

并确保rootfs目录可读写

[root@localhost linux-test]# cd /nfsboot
[root@localhost nfsboot]# ls -l
总计 65280
drwxr-xr-x 18 root root 4096 06-01 19:06 rootfs
-rwxrw-rw- 1 root root 58487616 2009-07-18 root_qtopia-128M.img
-rw-r--r-- 1 root root 2110720 06-01 13:31 uImage
-rwxr-xr-x 1 root root 2022412 05-12 11:37 uImage_T35
-rwxr-xr-x 1 root root 2110656 06-01 13:31 zImage
-rwxrw-rw- 1 root root 2022348 2009-07-08 zImage_T35
[root@localhost nfsboot]#

(3)修改/etc/exports配置文件将rootfs默认的共享目录

[root@localhost ~]# vim /etc/exports

打开的配置文件将共享目录修改成如下所示:

/nfsboot/rootfs 10.1.0.*(rw,sync,no_root_squash)
/nfsboot/kernel 10.1.0.*(rw,sync,no_root_squash)
/nfsboot/nfs 10.1.0.*(rw,sync,no_root_squash)

# /nfsboot/rootfs 是共享目录,存放跟文件系统(使用绝对路径)
# /nfsboot/kernel 是共享目录,存放跟文件系统(使用绝对路径)
# /nfsboot/nfs 是共享目录,存放应用程序(使用绝对路径)
# 10.1.0.*表示客户端所在网段10.1.0.0/24
# 10.1.0.0/24表示10.1.0.1~10.1.0.254网段,子网掩码是255.255.255.0。
# 子网掩码是怎么来的呢?其实关键就在“24”上。我们知道IP地址是四个十进制数
# 组成的,相当于32位二进制。用CIDR表示形式,后一个数字将这32位进行了间隔
#(以24为例):前24位用"1"表示,后面8位用0表示,得到一个二进制数:
# 11111111 11111111 11111111 00000000
# 将其转化为十进制,就是:255.255.255.0了。
# rw:可读写
# sync:同步写入磁盘。
# no_root_squash:允许非root用户操作改文件夹

然后保存退出,重新启动nfs服务:

[root@localhost ~]# service nfs restart
关闭 NFS mountd: [确定]
关闭 NFS 守护进程: [确定]
关闭 NFS quotas: [确定]
关闭 NFS 服务: [确定]
启动 NFS 服务: [确定]
关掉 NFS 配额: [确定]
启动 NFS 守护进程: [确定]
启动 NFS mountd: [确定]
[root@localhost ~]#

(4)修改u-boot内核引导参数

在u-boot启动并进入命令行状态下

A,确保bootargs ="noinitrd console=ttySAC0,115200 init=/linuxrc mem=64M \
root=/dev/nfs rw nfsroot=10.1.0.128:/nfsboot \
ip=10.1.0.129:10.1.128:10.1.0.1:255.255.255.0::eth0:off"

B,确保bootcmd="nfs 0x30008000 10.1.0.128:/nfsboot/uImage;bootm"

先查看u-boot的环境变量

[u-boot@MINI2440]# printenv
bootargs=noinitrd console=ttySAC0,115200 init=/linuxrc root=/dev/mtdblock3 rw r
ootfstype=yaffs ip=10.1.0.129:10.1.0.128:10.1.0.1:255.255.255.0::eth0:off
bootcmd=nand read 0x30008000 0x80000 0x300000;bootm 0x30008000
bootdelay=3
baudrate=115200
ethaddr=08:00:3e:26:0a:5b
ipaddr=10.1.0.129
serverip=10.1.0.128
gatewayip=10.1.0.1
netmask=255.255.255.0
stdin=serial
stdout=serial
stderr=serial
ethact=dm9000

Environment size: 405/131068 bytes
[u-boot@MINI2440]#

这里的u-boot内核引导参数bootargs和bootcmd显然与我们要求的不一致,要重新设置此参数:

[u-boot@MINI2440]# setenv bootargs 'noinitrd console=ttySAC0,115200 init=/linux'
rc mem=64M root=/dev/nfs rw nfsroot=10.1.0.128:/nfsboot/rootfs ip=10.1.0.129:10'
.1.0.128:10.1.0.1:255.255.255.0::eht0:off'
[u-boot@MINI2440]# setenv bootcmd 'nfs 0x31000000 10.1.0.128:/uImage;bootm 0x31000000'

然后保存此变量到nand flash

[u-boot@MINI2440]# saveenv
Saving Environment to NAND...
Erasing Nand...
Erasing at 0x4000000000002 -- 0% complete.
Writing to Nand... done

(5)确认内核的命令行参数

如果编译内核生成的是zImage映像文件,那么CONFIG_CMDLINE需要

CONFIG_CMDLINE="root=/dev/nfs rw nfsroot=10.1.0.128:/nfsboot/rootfs ip=10.1.0.129 console=ttySAC0 mem=64M"

如果编译内核生成的是uImage映像文件,那么CONFIG_CMDLINE可以为空,因为uImage的文件头中的参数会被传进这个地方来。

(6)将编译生成zImage和uImage文件复制到宿主机/nfsboot/目录下

[root@localhost nfsboot]# ls
rootfs root_qtopia-128M.img uImage uImage_T35 zImage zImage_T35
[root@localhost nfsboot]#
(7)给开发板上电,启动u-boot

I2C: ready
DRAM: 64 MB
Flash: 2 MB
NAND: 128 MiB
Video: 240x320x16 20kHz 62Hz
In: serial
Out: serial
Err: serial
Net: dm9000
U-Boot 2009.08
modified by singleboy()
Love Linux forever!!!
Hit any key to stop autoboot: 0
dm9000 i/o: 0x20000300, id: 0x90000a46
DM9000: running in 16 bit mode
MAC: 08:00:3e:26:0a:5b
operating at 100M full duplex mode
Using dm9000 device
File transfer via NFS from server 10.1.0.128; our IP address is 10.1.0.129
Filename '/nfsboot/uImage'.
Load address: 0x31000000
Loading: #################################################################
#################################################################
#################################################################
#################################################################
#################################################################
#################################################################
#######################
done
Bytes transferred = 2110772 (203534 hex)
## Booting kernel from Legacy Image at 31000000 ...
Image Name: Linux-2.6.32.2
Created: 2011-06-01 11:10:24 UTC
Image Type: ARM Linux Kernel Image (uncompressed)
Data Size: 2110708 Bytes = 2 MB
Load Address: 30008000
Entry Point: 30008000
Verifying Checksum ... OK
Loading Kernel Image ... OK
OK

Starting kernel ...

Uncompressing Linux.............................................................
...................................................................... done, boo
ting the kernel.
Linux version 2.6.32.2 () (gcc version 4.4.3 (ctng-1.6
.1) ) #11 Wed Jun 1 19:10:07 CST 2011
CPU: ARM920T [41129200] revision 0 (ARMv4T), cr=00007177
CPU: VIVT data cache, VIVT instruction cache
Machine: my mini2440 devolopment board

... ...

S3C24XX NAND Driver, (c) 2004 Simtec Electronics
s3c24xx-nand s3c2440-nand: Tacls=3, 29ns Twrph0=7 69ns, Twrph1=3 29ns
s3c24xx-nand s3c2440-nand: NAND soft ECC
NAND device: Manufacturer ID: 0xec, Chip ID: 0xf1 (Samsung NAND 128MiB 3,3V 8-bi
t)
Scanning device for bad blocks
Creating 5 MTD partitions on "NAND 128MiB 3,3V 8-bit":
0x000000000000-0x000000040000 : "boot"
0x000000040000-0x000000060000 : "param"
0x000000060000-0x000000560000 : "kernel"
0x000000560000-0x000008000000 : "rootfs"
0x000000000000-0x000008000000 : "nand"
dm9000 Ethernet Driver, V1.31
eth0: dm9000e at c486e300,c4872304 IRQ 51 MAC: 08:90:90:90:90:90 (chip)

... ...

eth0: link up, 100Mbps, full-duplex, lpa 0x45E1
IP-Config: Complete:
device=eth0, addr=10.1.0.129, mask=255.255.255.0, gw=10.1.0.1,
host=10.1.0.129, domain=, nis-domain=(none),
bootserver=10.1.0.128, rootserver=10.1.0.128, rootpath=
Looking up port of RPC 100003/2 on 10.1.0.128
Looking up port of RPC 100005/1 on 10.1.0.128
VFS: Mounted root (nfs filesystem) on device 0:14.
Freeing init memory: 132K
----------munt all----------------
***********************************************
************booting to mini2440 *****************
Kernel version:linux-2.6.32.2
the fans:singelboy
Date:2011.5.30
***********************************************

Please press Enter to activate this console.

根据内核启动信息,可以看到dm9000网卡驱动移植成功。

阅读(2416) | 评论(0) | 转发(0) |
0

上一篇:初试mini2440 nandflash驱动移植

下一篇:没有了

给主人留下些什么吧!~~