u-boot移植4:支持 网络

来源:互联网 发布:查电话号码软件 编辑:程序博客网 时间:2024/04/30 01:49
uboot 中对网络默认支持的是 cs8900 ,我们板子上的芯片用的是 DM9000,驱动中有 DM9000 部分,因此,我们改动的较小:

1. 更改配置的宏:include/configs/lip2440.h


@@ -36,10 +36,13 @@
 /*
  * Hardware drivers
  */
-#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)
 /*
  * select serial console configuration
  */

@@ -93,8 +96,8 @@
 #define CONFIG_ZERO_BOOTDELAY_CHECK

 #define CONFIG_NETMASK         255.255.255.0
-#define CONFIG_IPADDR          10.0.0.110
-#define CONFIG_SERVERIP                10.0.0.1
+#define CONFIG_IPADDR          10.100.151.110
+#define CONFIG_SERVERIP                10.100.151.122

 #if defined(CONFIG_CMD_KGDB)
 #define CONFIG_KGDB_BAUDRATE   115200  /* speed to run kgdb serial port */

2. 更改初始化函数:board/samsung/lip2440/lip2440.c


@@ -122,6 +122,9 @@ int board_eth_init(bd_t *bis)
 #ifdef CONFIG_CS8900
        rc = cs8900_initialize(0, CONFIG_CS8900_BASE);
 #endif
+#ifdef CONFIG_DRIVER_DM9000 
+    rc = dm9000_initialize(bis);
+#endif
        return rc;
 }
 #endif

去掉“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;

       }


最后的运行结果是:
U-Boot 2016.03-00004-gf2f5c9e-dirty (May 06 2016 - 17:31:38 +0800)

CPUID: 32440001
FCLK:      400 MHz
HCLK:      100 MHz
PCLK:       50 MHz
DRAM:  64 MiB
WARNING: Caches not enabled
Flash: 2 MiB
NAND:  256 MiB
In:    serial
Out:   serial
Err:   serial
Net:   dm9000
Warning: dm9000 (eth0) using random MAC address - e6:07:43:45:ff:94

LIP2440 #
0 0
原创粉丝点击