歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux編程 >> Linux編程 >> Linux-2.6.35內核移植—網卡驅動的移植

Linux-2.6.35內核移植—網卡驅動的移植

日期:2017/3/1 10:17:32   编辑:Linux編程

一、移植環境:

1、 Ubuntu 10.10發行版

2、 u-boot.bin

3、 目標機:FS_S5PC100平台

4、 交叉編譯器 arm-cortex_a8-linux-gnueabi-gcc

u-boot.bin下載:

免費下載地址在 http://linux.linuxidc.com/

用戶名與密碼都是www.linuxidc.com

具體下載目錄在 /2012年資料/7月/9日/Linux-2.6.35內核移植—網卡驅動的移植/

二、移植步驟

1、平台代碼修改

$ vim arch/arm/mach-s5pc100/mach-smdkc100.c
  • 添加需要的頭文件
#if defined(CONFIG_DM9000)
#include <linux/dm9000.h>
#include <linux/irq.h>
#endif
  • 平台設備的添加
/** DM9000 Support **/
#if defined(CONFIG_DM9000)
static struct resource dm9000_resources[] = {
    [0] = {
        .start  = 0x88000000,
        .end    = 0x88000000 + 0x3,
        .flags  = IORESOURCE_MEM,
    },
    [1] = {
        .start  = 0x88000000 + 0x4,
        .end    = 0x88000000 + 0x4 + 0x3,
        .flags  = IORESOURCE_MEM,
    },
    [2] = {
        .start  = IRQ_EINT(10),
        .end    = IRQ_EINT(10),
        .flags  = IORESOURCE_IRQ | IRQ_TYPE_LEVEL_HIGH,
    },
};

static struct dm9000_plat_data s5pc100_dm9000_platdata = {
    .flags  = DM9000_PLATF_16BITONLY,
    .dev_addr[0] = 0x00,
    .dev_addr[1] = 0x00,
    .dev_addr[2] = 0x3e,
    .dev_addr[3] = 0x26,
    .dev_addr[4] = 0x0a,
    .dev_addr[5] = 0x00,
};

static struct platform_device s5pc100_device_dm9000 = {
    .name   = "dm9000",
    .id     = -1,
    .num_resources  = ARRAY_SIZE(dm9000_resources),
    .resource   = dm9000_resources,
    .dev    = {
        .platform_data  = & s5pc100_dm9000_platdata,
    },
};
#endif
  • 平台設備列表的添加
#if defined(CONFIG_DM9000)
    &s5pc100_device_dm9000,
#endif

2、配置內核

$ make menuconfig
  • 網絡配置
[*] Networking support(NEW) --->
  Networking option --->
    <*> Packet socket
    <*> Unix domain socket
    [*] TCP/IP networking
    [*] IP: multicasting
    [*] IP: kernel level autoconfiguration
    [*] IP: BOOTP support 
  • 網上驅動配置
[*] Device Drivers --->
  [*] Network device support --->
    [*] Ethernet(10 or 100Mbit) --->
      <*> DM9000 support 
  • 網絡文件系統的配置
File systems --->
  [*] Network File Systems --->
    <*> NFS client support
    [*] NFS client support for NFS version 3
    [*] NFS client support for the NFSv3 ACL protocol extension
    [*] Root file system on NFS

三、編譯內核,並拷貝到tftpboot目錄下

$ make zImage
$ cp  arch/arm/boot/zImage  /tftpboot 

啟動開發板,修改內核啟動參數,通過NFS方式掛載根文件系統

Copyright © Linux教程網 All Rights Reserved