Chinaunix首页 | 论坛 | 博客
  • 博客访问: 134784
  • 博文数量: 28
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 165
  • 用 户 组: 普通用户
  • 注册时间: 2013-07-14 10:02
文章分类

全部博文(28)

文章存档

2014年(12)

2013年(16)

我的朋友

分类: 嵌入式

2014-07-09 17:03:46

本移植主要参考友善之臂移植手册完成,做个笔记以备不时之需
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行附近添加头文件

  1. 54 #include <plat/nand.h>
  2.  55
  3.  56 #include <linux/dm9000.h>
  4.  57
  5.  58 static struct map_desc mini2440_iodesc[] __initdata = {
在209行附近添加以下代码(231行-245行为添加代码):

  1. 207 .ignore_unset_ecc = 1,
  2. 208 };
  3. 209
  4. 210 /* DM9000AEP 10/100 ethernet controller */
  5. 211 #define MACH_MINI2440_DM9K_BASE (S3C2410_CS4 + 0x300)
  6. 212
  7. 213 static struct resource mini2440_dm9k_resource[] = {
  8. 214 [0] = {
  9. 215 .start = MACH_MINI2440_DM9K_BASE,
  10. 216 .end = MACH_MINI2440_DM9K_BASE + 3,
  11. 217 .flags = IORESOURCE_MEM
  12. 218 },
  13. 219 [1] = {
  14. 220 .start = MACH_MINI2440_DM9K_BASE + 4,
  15. 221 .end = MACH_MINI2440_DM9K_BASE + 7,
  16. 222 .flags = IORESOURCE_MEM
  17. 223 },
  18. 224 [2] = {
  19. 225 .start = IRQ_EINT7,
  20. 226 .end = IRQ_EINT7,
  21. 227 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE,
  22. 228 }
  23. 229 };
  24. 230 /*
  25. 231 * * * * The DM9000 has no eeprom, and it's MAC address is set by
  26. 232 * * * * the bootloader before starting the kernel.
  27. 233 * * * */
  28. 234 static struct dm9000_plat_data mini2440_dm9k_pdata = {
  29. 235 .flags = (DM9000_PLATF_16BITONLY | DM9000_PLATF_NO_EEPROM),
  30. 236 };
  31. 237 static struct platform_device mini2440_device_eth = {
  32. 238 .name = "dm9000",
  33. 239 .id = -1,
  34. 240 .num_resources = ARRAY_SIZE(mini2440_dm9k_resource),
  35. 241 .resource = mini2440_dm9k_resource,
  36. 242 .dev = {
  37. 243 .platform_data = &mini2440_dm9k_pdata,
  38. 244 },
  39. 245 };
  40. 246
  41. 247 static struct platform_device *mini2440_devices[] __initdata = {
在253行附近添加网卡设备:

  1. 247 static struct platform_device *mini2440_devices[] __initdata = {
  2. 248 &s3c_device_usb,
  3. 249 &s3c_device_lcd,
  4. 250 &s3c_device_wdt,
  5. 251 &s3c_device_i2c0,
  6. 252 &s3c_device_iis,
  7. 253 &mini2440_device_eth,
  8. 254 &s3c_device_nand,
  9. 255 };
调整DM9000所用的位宽寄存器
#vim drivers/net/dm9000.c
在1555行附近添加如下代码:

  1. 1553 dm9000_init(void)
  2. 1554 {
  3. 1555 #if defined(CONFIG_ARCH_S3C2410)
  4. 1556 unsigned int oldval_bwscon = *(volatile unsigned int *)S3C2410_BWSCON;
  5. 1557 unsigned int oldval_bankcon4 = *(volatile unsigned int *)S3C2410_BANKCON4;
  6. 1558 *((volatile unsigned int *)S3C2410_BWSCON) =
  7. 1559 (oldval_bwscon & ~(3<<16)) | S3C2410_BWSCON_DW4_16 |
  8. 1560 S3C2410_BWSCON_WS4 | S3C2410_BWSCON_ST4;
  9. 1561 *((volatile unsigned int *)S3C2410_BANKCON4) = 0x1f7c;
  10. 1562 #endif
  11. 1563 printk(KERN_INFO "%s Ethernet Driver, V%s\n", CARDNAME, DRV_VERSION);
  12. 1564
  13. 1565 return platform_driver_register(&dm9000_driver);
  14. 1566 }
在1458行附近添加以下一行代码:

  1. 1454 mac_src = "chip";
  2. 1455 for (i = 0; i < 6; i++)
  3. 1456 ndev->dev_addr[i] = ior(db, i+DM9000_PAR);
  4. 1457 }
  5. 1458 memcpy(ndev->dev_addr, "\x08\x90\x90\x90\x90\x90", 6);
  6. 1459 if (!is_valid_ether_addr(ndev->dev_addr))
  7. 1460 dev_warn(db->dev, "%s: Invalid ethernet MAC address. Please "
  8. 1461 "set using ifconfig\n", ndev->name);
在41行附近添加如下代码:

  1. 39 #include <asm/io.h>
  2.   40
  3.   41 #if defined(CONFIG_ARCH_S3C2410)
  4.   42 #include <mach/regs-mem.h>
  5.   43 #endif
  6.   44
  7.   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主机:

  1. Please press Enter to activate this console.
  2. [root@FriendlyARM /]# eth0: link up, 100Mbps, full-duplex, lpa 0x41E1
  3. ifconfig
  4. eth0 Link encap:Ethernet HWaddr 08:90:90:90:90:90
  5.           inet addr:192.168.1.230 Bcast:192.168.1.255 Mask:255.255.255.0
  6.           UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
  7.           RX packets:1 errors:0 dropped:0 overruns:0 frame:0
  8.           TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
  9.           collisions:0 txqueuelen:1000
  10.           RX bytes:352 (352.0 B) TX bytes:0 (0.0 B)
  11.           Interrupt:51 Base address:0xe300

  12. lo Link encap:Local Loopback
  13.           inet addr:127.0.0.1 Mask:255.0.0.0
  14.           UP LOOPBACK RUNNING MTU:16436 Metric:1
  15.           RX packets:0 errors:0 dropped:0 overruns:0 frame:0
  16.           TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
  17.           collisions:0 txqueuelen:0
  18.           RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)

  19. [root@FriendlyARM /]# ifconfig eth0 10.50.80.1 netmask 255.255.254.0
  20. [root@FriendlyARM /]# ifconfig
  21. eth0 Link encap:Ethernet HWaddr 08:90:90:90:90:90
  22.           inet addr:10.50.80.1 Bcast:10.50.81.255 Mask:255.255.254.0
  23.           UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
  24.           RX packets:4 errors:0 dropped:0 overruns:0 frame:0
  25.           TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
  26.           collisions:0 txqueuelen:1000
  27.           RX bytes:1408 (1.3 KiB) TX bytes:0 (0.0 B)
  28.           Interrupt:51 Base address:0xe300

  29. lo Link encap:Local Loopback
  30.           inet addr:127.0.0.1 Mask:255.0.0.0
  31.           UP LOOPBACK RUNNING MTU:16436 Metric:1
  32.           RX packets:0 errors:0 dropped:0 overruns:0 frame:0
  33.           TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
  34.           collisions:0 txqueuelen:0
  35.           RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)

  36. [root@FriendlyARM /]# ping 10.50.80.207
  37. PING 10.50.80.207 (10.50.80.207): 56 data bytes
  38. 64 bytes from 10.50.80.207: seq=0 ttl=64 time=3.492 ms
  39. 64 bytes from 10.50.80.207: seq=1 ttl=64 time=1.311 ms
  40. 64 bytes from 10.50.80.207: seq=2 ttl=64 time=1.285 ms
  41. 64 bytes from 10.50.80.207: seq=3 ttl=64 time=1.314 ms
  42. 64 bytes from 10.50.80.207: seq=4 ttl=64 time=1.321 ms
  43. 64 bytes from 10.50.80.207: seq=5 ttl=64 time=1.199 ms
  44. 64 bytes from 10.50.80.207: seq=6 ttl=64 time=1.316 ms
  45. 64 bytes from 10.50.80.207: seq=7 ttl=64 time=1.324 ms
  46. 64 bytes from 10.50.80.207: seq=8 ttl=64 time=8.723 ms
  47. 64 bytes from 10.50.80.207: seq=9 ttl=64 time=1.308 ms
  48. ^C
  49. --- 10.50.80.207 ping statistics ---
  50. 10 packets transmitted, 10 packets received, 0% packet loss
  51. round-trip min/avg/max = 1.199/2.259/8.723 ms
  52. [root@FriendlyARM /]#
在主机上平开发板:

  1. [root@localhost /]# ping 10.50.80.1
  2. PING 10.50.80.1 (10.50.80.1) 56(84) bytes of data.
  3. 64 bytes from 10.50.80.1: icmp_seq=1 ttl=64 time=17.8 ms
  4. 64 bytes from 10.50.80.1: icmp_seq=2 ttl=64 time=0.857 ms
  5. 64 bytes from 10.50.80.1: icmp_seq=3 ttl=64 time=0.836 ms
  6. 64 bytes from 10.50.80.1: icmp_seq=4 ttl=64 time=0.872 ms
  7. ^C
  8. --- 10.50.80.1 ping statistics ---
  9. 4 packets transmitted, 4 received, 0% packet loss, time 3466ms
  10. rtt min/avg/max/mdev = 0.836/5.112/17.886/7.375 ms
  11. [root@localhost /]#
至此网卡移植成功!








阅读(1863) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~