u-boot-2016.03在mini2440移植 之DM9000

u-boot默认的网络芯片是CS8900,但开发板上的网络芯片是DM9000,所以为了使用网络功能,就必须进行移植。好在u-boot有DM9000的驱动程序,我们只需要把关于CS8900的部分换成DM9000的部分即可。

首先在include/configs/smdk2410.h 中注释如下语句

#define CONFIG_CS8900          we have a CS8900 on-board
#define CONFIG_CS8900_BASE      0x19000300
#define CONFIG_CS8900_BUS16      the Linux driver does accesses as shorts

再增加如下语句 :

#define CONFIG_DRIVER_DM9000
#define CONFIG_DM9000_NO_SROM                           //not use the dm9000 eeprom
#define CONFIG_NET_RANDOM_ETHADDR                       //set the ethaddr
#define CONFIG_LIB_RAND                                 //random_ethadd need rand function
#define CONFIG_DM9000_BASE      0x20000300
#define DM9000_IO               CONFIG_DM9000_BASE     
#define DM9000_DATA             (CONFIG_DM9000_BASE + 4 ) //data address*/

然后定义缺省的环境变量,先添加MAC地址,再修改开发板以及宿主机的IP地址:

#define CONFIG_NETMASK          255.255.255.0
#define CONFIG_IPADDR           192.168.1.8         //arm board ip
#define CONFIG_SERVERIP         192.168.1.120       // pc ip  

打开board/samsung/smdk2410/smdk2410.c 文件中的board_eth_init函数 在133行增加如下内容:

#ifdef CONFIG_DRIVER_DM9000 
        rc= dm9000_initialize(bis);
#endif

完成上述步骤,开发板就能正常的使用网络功能了。

运行结果如图所示:

当看到最后一行“host192.168.1.120 is alive”时,说明网络功能已能正常使用。如果为了去掉“could not establish link”字样,并加快运行速度,可以注释掉drivers/net/dm9000x.c文件中的dm9000_init函数内的下面语句:

       i= 0;

       while(!(dm9000_phy_read(1) & 0x20)) {   /*autonegation complete bit */

              udelay(1000);

              i++;

              if(i == 10000) {

                     printf("couldnot establish link\n");

                     return0;

              }

       }

 

       /*see what we've got */

       lnk= dm9000_phy_read(17) >> 12;

       printf("operatingat ");

       switch(lnk) {

       case1:

              printf("10M half duplex ");

              break;

       case2:

              printf("10M full duplex ");

              break;

       case4:

              printf("100M half duplex ");

              break;

       case8:

              printf("100M full duplex ");

              break;

       default:

              printf("unknown:%d ", lnk);

              break;

       }

 

posted @ 2016-04-03 00:30  jetli  阅读(1864)  评论(0编辑  收藏  举报