u-boot-1.1.6移植之dm9000

2023-06-13  

网卡dm9000的执行过程(u-boot版本:u-boot-1.1.6):

在board.c里面有eth_initialize(gd->bd);

eth_initialize的实现在eth.c里面,但是eth_initialize函数里面没有dm9000的初始化eth_init

 

常见有nfs,tftp,ping命令会用到网络设备,可以从这里入手。

U_BOOT_CMD(

                ping,      2,            1,            do_ping,

                "pingt- send ICMP ECHO_REQUEST to network hostn",

                "pingAddressn"

);

 

而其处理函数do_ping如下:

int do_ping (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])

{

                if (argc < 2)

                                return -1;

 

                NetPingIP = string_to_ip(argv[1]);

                if (NetPingIP == 0) {

                                printf ("Usage:n%sn", cmdtp->usage);

                                return -1;

                }

 

                if (NetLoop(PING) < 0) {

                                printf("ping failed; host %s is not aliven", argv[1]);

                                return 1;

                }

 

                printf("host %s is aliven", argv[1]);

                return 0;

}

 

看上面红色标注的NetLoop,在net.c里面实现

eth_halt();            //Stop the interface.

#ifdef CONFIG_NET_MULTI

                eth_set_current();

#endif

                if (eth_init(bd) < 0) {                    //调用初始化函数,如果定义了cs8900,则使用cs8900的eth_init函数,这里使用dm9000

                                eth_halt();

                                return(-1);

                }

 

NetLoop函数的原型,参数是proto_t结构体指针

int NetLoop(proto_t protocol)

而proto_t有:

typedef enum { BOOTP, RARP, ARP, TFTP, DHCP, PING, DNS, NFS, CDP, NETCONS, SNTP } proto_t;

以上表明,当使用bootp,tftp,ping,nfs等命令的时候会调用NetLoop,进而对各种网卡进行对应于配置的初始化。

以上,是顶层对dm9000的调用过程,下面再看dm9000x.c执行过程

入口eth_init

                1、RESET device 复位 ,检测网络连接类型

                2、NIC Type: FASTETHER, HOMERUN, LONGRUN    NIC类型

                3、GPIO0 on pre-activate PHY  设置GPIO

                4、Set PHY   设置工作模式

                5、Program operating register设置寄存器       


文章来源于:电子工程世界    原文链接
本站所有转载文章系出于传递更多信息之目的,且明确注明来源,不希望被转载的媒体或个人可与我们联系,我们将立即进行删除处理。