本移植主要参考友善之臂移植手册完成,做个笔记以备不时之需
Linux-2.6.32 在Mini2440上的移植(四)
使用环境:fedora9
交叉编译工具链:arm-linux-gcc-4.4.3
内核源码来源:
内核存放目录:/opt/mymini2440/linux-2.6.32
说明:红色部分为代码修改部分
#vim arch/arm/mach-s3c2440/mach-mini2440
在56行附近添加头文件
-
54 #include <plat/nand.h>
-
55
-
56 #include <linux/dm9000.h>
-
57
-
58 static struct map_desc mini2440_iodesc[] __initdata = {
在209行附近添加以下代码(231行-245行为添加代码):
-
207 .ignore_unset_ecc = 1,
-
208 };
-
209
-
210 /* DM9000AEP 10/100 ethernet controller */
-
211 #define MACH_MINI2440_DM9K_BASE (S3C2410_CS4 + 0x300)
-
212
-
213 static struct resource mini2440_dm9k_resource[] = {
-
214 [0] = {
-
215 .start = MACH_MINI2440_DM9K_BASE,
-
216 .end = MACH_MINI2440_DM9K_BASE + 3,
-
217 .flags = IORESOURCE_MEM
-
218 },
-
219 [1] = {
-
220 .start = MACH_MINI2440_DM9K_BASE + 4,
-
221 .end = MACH_MINI2440_DM9K_BASE + 7,
-
222 .flags = IORESOURCE_MEM
-
223 },
-
224 [2] = {
-
225 .start = IRQ_EINT7,
-
226 .end = IRQ_EINT7,
-
227 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE,
-
228 }
-
229 };
-
230 /*
-
231 * * * * The DM9000 has no eeprom, and it's MAC address is set by
-
232 * * * * the bootloader before starting the kernel.
-
233 * * * */
-
234 static struct dm9000_plat_data mini2440_dm9k_pdata = {
-
235 .flags = (DM9000_PLATF_16BITONLY | DM9000_PLATF_NO_EEPROM),
-
236 };
-
237 static struct platform_device mini2440_device_eth = {
-
238 .name = "dm9000",
-
239 .id = -1,
-
240 .num_resources = ARRAY_SIZE(mini2440_dm9k_resource),
-
241 .resource = mini2440_dm9k_resource,
-
242 .dev = {
-
243 .platform_data = &mini2440_dm9k_pdata,
-
244 },
-
245 };
-
246
-
247 static struct platform_device *mini2440_devices[] __initdata = {
在253行附近添加网卡设备:
-
247 static struct platform_device *mini2440_devices[] __initdata = {
-
248 &s3c_device_usb,
-
249 &s3c_device_lcd,
-
250 &s3c_device_wdt,
-
251 &s3c_device_i2c0,
-
252 &s3c_device_iis,
-
253 &mini2440_device_eth,
-
254 &s3c_device_nand,
-
255 };
调整DM9000所用的位宽寄存器
#vim drivers/net/dm9000.c
在1555行附近添加如下代码:
-
1553 dm9000_init(void)
-
1554 {
-
1555 #if defined(CONFIG_ARCH_S3C2410)
-
1556 unsigned int oldval_bwscon = *(volatile unsigned int *)S3C2410_BWSCON;
-
1557 unsigned int oldval_bankcon4 = *(volatile unsigned int *)S3C2410_BANKCON4;
-
1558 *((volatile unsigned int *)S3C2410_BWSCON) =
-
1559 (oldval_bwscon & ~(3<<16)) | S3C2410_BWSCON_DW4_16 |
-
1560 S3C2410_BWSCON_WS4 | S3C2410_BWSCON_ST4;
-
1561 *((volatile unsigned int *)S3C2410_BANKCON4) = 0x1f7c;
-
1562 #endif
-
1563 printk(KERN_INFO "%s Ethernet Driver, V%s\n", CARDNAME, DRV_VERSION);
-
1564
-
1565 return platform_driver_register(&dm9000_driver);
-
1566 }
在1458行附近添加以下一行代码:
-
1454 mac_src = "chip";
-
1455 for (i = 0; i < 6; i++)
-
1456 ndev->dev_addr[i] = ior(db, i+DM9000_PAR);
-
1457 }
-
1458 memcpy(ndev->dev_addr, "\x08\x90\x90\x90\x90\x90", 6);
-
1459 if (!is_valid_ether_addr(ndev->dev_addr))
-
1460 dev_warn(db->dev, "%s: Invalid ethernet MAC address. Please "
-
1461 "set using ifconfig\n", ndev->name);
在41行附近添加如下代码:
-
39 #include <asm/io.h>
-
40
-
41 #if defined(CONFIG_ARCH_S3C2410)
-
42 #include <mach/regs-mem.h>
-
43 #endif
-
44
-
45 #include "dm9000.h"
确认内核支持网卡:
#make menuconfig
Device Drivers ---> [*] Network device support ---> [*] Ethernet (10 or 100Mbit) ---> <*> DM9000 support
编译内核测试
#make zImage
在vivi菜单中输入【k】将内核下载到nandflash,输入【y】下载友善之臂文件系统,输入【b】启动:
查看、修改开发板ip,ping主机:
-
Please press Enter to activate this console.
-
[root@FriendlyARM /]# eth0: link up, 100Mbps, full-duplex, lpa 0x41E1
-
ifconfig
-
eth0 Link encap:Ethernet HWaddr 08:90:90:90:90:90
-
inet addr:192.168.1.230 Bcast:192.168.1.255 Mask:255.255.255.0
-
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
-
RX packets:1 errors:0 dropped:0 overruns:0 frame:0
-
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
-
collisions:0 txqueuelen:1000
-
RX bytes:352 (352.0 B) TX bytes:0 (0.0 B)
-
Interrupt:51 Base address:0xe300
-
-
lo Link encap:Local Loopback
-
inet addr:127.0.0.1 Mask:255.0.0.0
-
UP LOOPBACK RUNNING MTU:16436 Metric:1
-
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
-
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
-
collisions:0 txqueuelen:0
-
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
-
-
[root@FriendlyARM /]# ifconfig eth0 10.50.80.1 netmask 255.255.254.0
-
[root@FriendlyARM /]# ifconfig
-
eth0 Link encap:Ethernet HWaddr 08:90:90:90:90:90
-
inet addr:10.50.80.1 Bcast:10.50.81.255 Mask:255.255.254.0
-
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
-
RX packets:4 errors:0 dropped:0 overruns:0 frame:0
-
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
-
collisions:0 txqueuelen:1000
-
RX bytes:1408 (1.3 KiB) TX bytes:0 (0.0 B)
-
Interrupt:51 Base address:0xe300
-
-
lo Link encap:Local Loopback
-
inet addr:127.0.0.1 Mask:255.0.0.0
-
UP LOOPBACK RUNNING MTU:16436 Metric:1
-
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
-
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
-
collisions:0 txqueuelen:0
-
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
-
-
[root@FriendlyARM /]# ping 10.50.80.207
-
PING 10.50.80.207 (10.50.80.207): 56 data bytes
-
64 bytes from 10.50.80.207: seq=0 ttl=64 time=3.492 ms
-
64 bytes from 10.50.80.207: seq=1 ttl=64 time=1.311 ms
-
64 bytes from 10.50.80.207: seq=2 ttl=64 time=1.285 ms
-
64 bytes from 10.50.80.207: seq=3 ttl=64 time=1.314 ms
-
64 bytes from 10.50.80.207: seq=4 ttl=64 time=1.321 ms
-
64 bytes from 10.50.80.207: seq=5 ttl=64 time=1.199 ms
-
64 bytes from 10.50.80.207: seq=6 ttl=64 time=1.316 ms
-
64 bytes from 10.50.80.207: seq=7 ttl=64 time=1.324 ms
-
64 bytes from 10.50.80.207: seq=8 ttl=64 time=8.723 ms
-
64 bytes from 10.50.80.207: seq=9 ttl=64 time=1.308 ms
-
^C
-
--- 10.50.80.207 ping statistics ---
-
10 packets transmitted, 10 packets received, 0% packet loss
-
round-trip min/avg/max = 1.199/2.259/8.723 ms
-
[root@FriendlyARM /]#
在主机上平开发板:
-
[root@localhost /]# ping 10.50.80.1
-
PING 10.50.80.1 (10.50.80.1) 56(84) bytes of data.
-
64 bytes from 10.50.80.1: icmp_seq=1 ttl=64 time=17.8 ms
-
64 bytes from 10.50.80.1: icmp_seq=2 ttl=64 time=0.857 ms
-
64 bytes from 10.50.80.1: icmp_seq=3 ttl=64 time=0.836 ms
-
64 bytes from 10.50.80.1: icmp_seq=4 ttl=64 time=0.872 ms
-
^C
-
--- 10.50.80.1 ping statistics ---
-
4 packets transmitted, 4 received, 0% packet loss, time 3466ms
-
rtt min/avg/max/mdev = 0.836/5.112/17.886/7.375 ms
-
[root@localhost /]#
至此网卡移植成功!
阅读(1907) | 评论(0) | 转发(0) |