2.6.38到Tiny6410的移植手册(2)

今天做的是dm9000网卡移植,和nfs文件系统的搭建

1、vi include/linux/dm9000.h
28行增加
unsigned char    param_addr[6];

2、vi arch/arm/mach-s3c64xx/mach-mini6410.c

为方便起见,将他的网卡结构体注释掉
#if 0
static struct resource mini6410_dm9k_resource[] = {
        [0] = {
                .start  = S3C64XX_PA_XM0CSN1,
                .end    = S3C64XX_PA_XM0CSN1 + 1,
                .flags  = IORESOURCE_MEM
        },
        [1] = {
                .start  = S3C64XX_PA_XM0CSN1 + 4,
                .end    = S3C64XX_PA_XM0CSN1 + 5,
                .flags  = IORESOURCE_MEM
        },
        [2] = {
                .start  = S3C_EINT(7),
                .end    = S3C_EINT(7),
             .flags  = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL
        }
};

static struct dm9000_plat_data mini6410_dm9k_pdata = {
        .flags          = (DM9000_PLATF_16BITONLY | DM9000_PLATF_NO_EEPROM),
};

static struct platform_device mini6410_device_eth = {
        .name           = "dm9000",
        .id             = -1,
        .num_resources  = ARRAY_SIZE(mini6410_dm9k_resource),
        .resource       = mini6410_dm9k_resource,
        .dev            = {
                .platform_data  = &mini6410_dm9k_pdata,
        },
};

#endif

增加

#define S3C64XX_PA_DM9000       (0x18000000)
#define S3C64XX_SZ_DM9000       SZ_1M
#define S3C64XX_VA_DM9000       S3C_ADDR(0x03b00300)

static struct resource dm9000_resources[] = {
        [0] = {
                .start          = S3C64XX_PA_DM9000,
                .end            = S3C64XX_PA_DM9000 + 3,
                .flags          = IORESOURCE_MEM,
        },
        [1] = {
                .start          = S3C64XX_PA_DM9000 + 4,
                .end            = S3C64XX_PA_DM9000 + S3C64XX_SZ_DM9000 - 1,
                .flags          = IORESOURCE_MEM,
        },
        [2] = {
                .start          = IRQ_EINT(7),
                .end            = IRQ_EINT(7),
                .flags          = IORESOURCE_IRQ | IRQF_TRIGGER_HIGH,
        },
};

static struct dm9000_plat_data dm9000_setup = {
        .flags                  = DM9000_PLATF_16BITONLY,
        .dev_addr               = { 0x08, 0x90, 0x00, 0xa0, 0x90, 0x90 },
};

static struct platform_device s3c_device_dm9000 = {
        .name                   = "dm9000",
        .id                             = 0,
        .num_resources  = ARRAY_SIZE(dm9000_resources),
        .resource               = dm9000_resources,
        .dev                    = {
                .platform_data = &dm9000_setup,
        }
};

如果不嫌麻烦,也可以直接在原代码上改,S3C64XX_PA_XM0CSN1的值也为0x18000000的。

增加mac地址设置函数
static int __init dm9000_set_mac(char *str) {
        unsigned char addr[6];
        unsigned int val;
        int idx = 0;
        char *p = str, *end;
        while (*p && idx < 6) {
                val = simple_strtoul(p, &end, 16);
                if (end <= p) {
                        /* convert failed */
                        break;
                } else {
                        addr[idx++] = val;
                        p = end;
                        if (*p == ':'|| *p == '-') {
                                p++;
                        } else {
                                break;
                        }
                }
        }
         if (idx == 6) {
                printk("Setup ethernet address to %pM\n", addr);
                memcpy(dm9000_setup.param_addr, addr, 6);
        }

return 1;
}

__setup("ethmac=", dm9000_set_mac);

增加IO映射
增加映射结构体
static struct map_desc mini6410_iodesc[] = {
#ifdef CONFIG_DM9000
        {
                .virtual        = (u32)S3C64XX_VA_DM9000,
                .pfn            = __phys_to_pfn(S3C64XX_PA_DM9000),
                .length         = S3C64XX_SZ_DM9000,
                .type           = MT_DEVICE,
        },
#endif
};
然后在static void __init mini6410_map_io(void)函数中
将s3c64xx_init_io(NULL, 0);改成
  s3c64xx_init_io(mini6410_iodesc, ARRAY_SIZE(mini6410_iodesc));

最后在static struct platform_device *mini6410_devices[] __initdata 的初始化设备中
将     &mini6410_device_eth,
改成   &s3c_device_dm9000,

3、vi drivers/net/dm9000.c
大概1586行
将mac_src = "platform data";
memcpy(ndev->dev_addr, pdata->dev_addr, 6);

改成

mac_src = "param data";
  memcpy(ndev->dev_addr, pdata->param_addr, 6);

大概1598行
增加
   if (!is_valid_ether_addr(ndev->dev_addr) && pdata != NULL) {
                mac_src = "platform data";
                memcpy(ndev->dev_addr, pdata->dev_addr, 6);
        }


4、make menuconfig
        [*] Networking support  --->
                Networking options  ---> 
               <*> Packet socket                                               
                 <*> Unix domain sockets 
                [*] TCP/IP networking
                  [*]   IP: kernel level autoconfiguration                      
                      [*]     IP: DHCP support                                       
                          [*]     IP: BOOTP support                                       
                      [*]     IP: RARP support
    Device Drivers  --->
        [*] Network device support  --->
            [*]   Ethernet (10 or 100Mbit)  --->
                 <*>   DM9000 support 
            [ ]   Ethernet (1000 Mbit)  --->   去掉
其他的默认

编译出来,在引导信息中就能看到dm9000网卡信息了。

dm9000 Ethernet Driver, V1.31
eth0: dm9000a at d0930000,d0e00004 IRQ 108 MAC: 08:90:90:90:。。。。

5、增加NFS挂载功能
make menuconfig
    File systems  --->
        Network File Systems  --->
            <*>   NFS client support 
             [*]   Root file system on NFS   这个一点要选
            <*>   NFS server support

之后编译出来的内核就能挂载nfs文件系统了
我的是setenv bootargs console=ttySAC0 root=/dev/nfs nfsroot=58.154.51.164:/root/my_root ip=58.154.51.199:58.154.51.164:58.154.51.199:255.255.255.0 :kiss:eth0:off


mmc1: mmc_rescan_try_freq: trying to init card at 100000 Hz
eth0: link down
eth0: link up, 100Mbps, full-duplex, lpa 0xC1E1
IP-Config: Complete:
     device=eth0, addr=58.154.51.199, mask=255.255.255.0, gw=58.154.51.199,
     host=58.154.51.199, domain=, nis-domain=(none),
     bootserver=58.154.51.164, rootserver=58.154.51.164, rootpath=
VFS: Mounted root (nfs filesystem) on device 0:11.
Freeing init memory: 120K


Please press Enter to activate this console. [root@kissBaofish /]#
[root@kissBaofish /]#
[root@kissBaofish /]#
[root@kissBaofish /]#

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/wydjyx.html