U-Boot移植(16)ylp2410网卡dm9000aep

时间:2022-04-02 09:22:04

这几天真被dm9000aep折磨的受不了,在今晚12.5终于宣告对它的完美征服,回顾这几天的历程,真是一波三折。

1、首先我要说的是dm9000aep和dm9000是不一样的,虽是同一个公司的网卡,但是前者是后者的升级版,如果直接把u-boot下的网卡那部分程序拿来用,最终烧到优龙板里后在u-boot下是实现不了tftp的,因为之前我已经在pc机上搭建成功tftp平台了。

      注意下面的红体字

       一开始我真的以为dm9000aep和dm9000是一样的,所以其它部分移植成功后,就把u-boot直接烧到板里,结果出现如下错误:

OpenJTAG> ping 172.22.136.38
ERROR: resetting DM9000 -> not responding
dm9000 not found at 0x20000000 id: 0x2b2a2928
DM9000: Undefined IO-mode:0x3
MAC: 08:00:3e:26:0a:5b
could not establish link
## Warning: gatewayip needed but not set
transmission timeout
## Warning: gatewayip needed but not set
transmission timeout
ping failed; host 172.22.136.38 is not alive

从上面明显看出来是:根本没有找到网卡,所以一定是网卡的驱动不对,或者是基址不对。

2、后来我找到优龙光盘中所配套的开发板的电路原理图,找到网卡芯片的所在处,如下图所示:

U-Boot移植(16)ylp2410网卡dm9000aep

从上图可以看出片选CS#接的是nGCS5,16根数据线,CMD接addr2。

这下明白了,具体问题具体分析。嘛。

位宽16,访问地址:0x28000000~0x30000000,

于是(1)

vi  /u-boot-1.1.6/board/smdk2410/lowlevel_init.S进行修改,

#define BWSCON  0x48000000
/* BWSCON */
#define DW8                     (0x0)
#define DW16                    (0x1)
#define DW32                    (0x2)
#define WAIT                    (0x1<<2)
#define UBLB                    (0x1<<3)

#define B1_BWSCON               (DW16)
#define B2_BWSCON               (DW16)
#define B3_BWSCON               (DW16 + WAIT + UBLB)
//#define B3_BWSCON             (DW16 + UBLB)
#define B4_BWSCON               (DW16 + WAIT + UBLB)

//#define B5_BWSCON               (DW8)
#define B5_BWSCON               (DW16 + UBLB)
#define B6_BWSCON               (DW32)
#define B7_BWSCON               (DW32)
........................

#define B5_Tacs                 0x0     /*  0clk */
#define B5_Tcos                 0x3     /*  0clk */
#define B5_Tacc                 0x7     /* 14clk */
#define B5_Tcoh                 0x1     /*  0clk */
#define B5_Tah                  0x3     /*  0clk */
#define B5_Tacp                 0x6
#define B5_PMC                  0x0     /* normal */

.............................................

(2)vi  /u-boot-1.1.6/include/configs/100ask24x0.h

#if !defined(CONFIG_DRIVER_CS8900)
#define CONFIG_DRIVER_DM9000            1
#define CONFIG_DM9000_USE_16BIT         1
#define CONFIG_DM9000_BASE                      0x28000300 //nGCS5
#define DM9000_IO                       CONFIG_DM9000_BASE
#define DM9000_DATA                    (CONFIG_DM9000_BASE + 4)
#endif
顺便添加一个ping命令,这样在u-boot  下就可以使用该命令来测试网络。

#define CONFIG_COMMANDS \
                        ((CONFIG_CMD_DFL | \
                        CFG_CMD_CACHE    | \
                    /* Start: by www.100ask.net */ \
                        CFG_CMD_PING     | \
                        CFG_CMD_JFFS2    | \
                        CFG_CMD_NAND     | \
                    /* End: by www.100ask.net */ \
                        /*CFG_CMD_EEPROM |*/ \
                        /*CFG_CMD_I2C    |*/ \
                        /*CFG_CMD_USB    |*/ \
                        CFG_CMD_REGINFO  | \
                        CFG_CMD_DATE     | \
                        CFG_CMD_ELF))
(3)vi  /u-boot-1.1.6/drivers/dm9000x.c

eth_rx(void)
{
        u8 rxbyte, *rdptr = (u8 *) NetRxPackets[0];
        u16 RxStatus, RxLen = 0;
        struct board_info *db = &dm9000_info;

        /* Check packet ready or not, we must check
           the ISR status first for DM9000A */
        if (!(DM9000_ior(DM9000_ISR) & 0x01)) /* Rx-ISR bit must be set. */
                return 0;

        DM9000_iow(DM9000_ISR, 0x01); /* clear PR status latched in bit 0 */

        /* There is _at least_ 1 package in the fifo, read them all */
        for (;;) {
                DM9000_ior(DM9000_MRRH);
                DM9000_ior(DM9000_MRRL);
//dm9000ae spencial
                DM9000_ior(DM9000_MRCMDX);      /* Dummy read */

 ................................................

上面的增加为dm9000ae特有的

至此修改完毕,保存,到顶层中进行编译,连接生成u-boot.bin, 烧到板里,进行验证。。。