原创 u-boot-2010.03在tq6410上的移植详解(三)

2010-9-26 17:08 1861 9 9 分类: MCU/ 嵌入式

五、             DM9000在Uboot2010.03上的移植


1)首先进入include/configs/修改smdk6410.h文件,屏蔽CS8900的相关宏定义同时添加DM9000AE的相关宏


#cd include/configs///


#gedit smdk6410.h //


smdk6410.h修改内容如下:


#define CONFIG_NET_MULTI           1


//#define CONFIG_CS8900                  /* we have a CS8900 on-board */


//#define CONFIG_CS8900_BASE           0x18800300


//#define CONFIG_CS8900_BUS16           /* follow the Linux driver    */




#define CONFIG_DRIVER_DM9000          1/* we have a DM9000AE on-board      */


#define CONFIG_DM9000_BASE              0x18000300


#define DM9000_IO               CONFIG_DM9000_BASE


#define DM9000_DATA                (CONFIG_DM9000_BASE + 4)


#define CONFIG_DM9000_USE_16BIT



#define CONFIG_ETHADDR        10:23:45:67:89:ab


#define CONFIG_NETMASK              255.255.255.0


#define CONFIG_IPADDR            192.168.174.2 //开发板上的ip地址


#define CONFIG_SERVERIP        192.168.174.1//虚拟机上的ip地址


#define CONFIG_GATEWAYIP   192.168.174.6


#define CONFIG_DM9000_DEBUG//一定要加上否则会出现没有设置ipaddr的现象


2)修改net/eth.c,添加DM9000AE的初始化函数(红色部分为修改的地方):


int eth_initialize(bd_t *bis)


{


      unsigned char env_enetaddr[6];


      int eth_number = 0;



      eth_devices = NULL;


      eth_current = NULL;



      show_boot_progress (64);


#if defined(CONFIG_MII) || defined(CONFIG_CMD_MII)


      miiphy_init();


#endif


      /* Try board-specific initialization first. If it fails or isn't


       * present, try the cpu-specific initialization */


      if (board_eth_init(bis) < 0)


             cpu_eth_init(bis);



#if defined(CONFIG_DB64360) || defined(CONFIG_CPCI750)


      mv6436x_eth_initialize(bis);


#endif


#if defined(CONFIG_DB64460) || defined(CONFIG_P3Mx)


      mv6446x_eth_initialize(bis);


#endif


#if defined(CONFIG_DRIVER_DM9000)


      dm9000_initialize(bis);


#endif


      if (!eth_devices) {


             puts ("No ethernet found.\n");


             show_boot_progress (-64);


      } else {


             struct eth_device *dev = eth_devices;


             char *ethprime = getenv ("ethprime");



             show_boot_progress (65);


             do {


                    if (eth_number)


                           puts (", ");



                    printf("%s", dev->name);



                    if (ethprime && strcmp (dev->name, ethprime) == 0) {


                           eth_current = dev;


                           puts (" [PRIME]");


                    }



                    eth_getenv_enetaddr_by_index(eth_number, env_enetaddr);



                    if (memcmp(env_enetaddr, "\0\0\0\0\0\0", 6)) {


                           if (memcmp(dev->enetaddr, "\0\0\0\0\0\0", 6) &&


                               memcmp(dev->enetaddr, env_enetaddr, 6))


                           {


                                  printf ("\nWarning: %s MAC addresses don't match:\n",


                                         dev->name);


                                  printf ("Address in SROM is         %pM\n",


                                         dev->enetaddr);


                                  printf ("Address in environment is %pM\n",


                                         env_enetaddr);


                           }



                           memcpy(dev->enetaddr, env_enetaddr, 6);


                    }



                    eth_number++;


                    dev = dev->next;


             } while(dev != eth_devices);


重新编译uboot,并下载uboot到nand flash中,重新启动开发板,观察打印信息如下,可以发现uboot已经能识别DM9000芯片:



使用ping指令进行测试如下:




至此,uboot已经能支持dm9000的网卡,可以使用tftp协议下载程序并在ram中运行了。

文章评论0条评论)

登录后参与讨论
我要评论
0
9
关闭 站长推荐上一条 /2 下一条