uboot study notes | 06 - transplant uboot 2012.04 to JZ2440 (support DM9000C card)

1. JZ2440 development board NIC

On-board development JZ2440 DM9000C card, as shown in FIG principle:

2. Add uboot already drive files to the project

2.1. Adding macro definitions

uboot comes with the drive folder already contains files DM9000:

  • drivers/net/dm9000x.c
  • drivers/net/dm9000x.h

Next View makefile files in this directory (net directory), the DM9000 join the project of these two files:

you can see from makefille, you only need to configure CONFIG_DRIVER_DM9000 this macro definition, dm9000 relevant documents will be added to the project.

According to experience, you need to configure certainly more than a simple macro definition, global search this macro is defined with reference to other documents veneer, such as:

really, except CONFIG_DRIVER_DM9000 macro definition, there are three address configuration macro definitions related.

This configuration is modeled, in their own board configuration file is added include/configs/smdk2440.h, and the original CS8900 network card driver configuration to remove:

2.2. Modify the macro definition

Three address-related macro definition is a reference to the other board configuration copied, certainly can not see S3C2440 chip manuals and schematics to determine the three addresses.

First, the base address CONFIG_DM9000_BASE, can be seen in the schematic DM9000 is connected to the memory controller on the BANK4 by the control nGCS4, further BANK4 find the base address corresponding to the chip manual S3C2440 0x20000000:

DM9000_IO default configuration is the base address CONFIG_DM9000_BASE, without modification.

DM9000 address lines and data lines are isolated, but the data line command or data may be transmitted, it is necessary to distinguish the signal line CMD, schematic view, for convenience the LADDR2 signal on the CMD line to the pin, as a control signal, use.

所以当发出的地址中 bit2 为0时,表示数据线上传输的命令,当发出地址中 bit 2 为1时,表示传输的是数据,DM9000_DATA宏定义就表示发数据时地址应该有什么变化,将bit 2置为1即可:

#define DM9000_DATA					(CONFIG_DM9000_BASE + 4)

综合以上修改,最后修改结果如图:

这个时候编译没有问题,但是运行的结果还是会出现net 网卡找不到的日志,接着进行修改。

3. 设置内存控制器

根据原理图,网卡DM9000是接到内存控制器的BANK4的,所以需要设置内存控制器中BANK4的位宽参数和时序参数。

3.1. 内存控制器BANK4的设置

通过内存控制器的 BWSCON 寄存器来设置数据总线位宽:

其中BANK位宽设置如下:

通过内存控制器的 BANKCON4 来设置 BANK4 的时序参数:


根据DM9000的时序性能,此寄存器的值可以设置为0x00000740

3.2. 在uboot中修改内存控制器的设置

在之前分析SDRAM移植的时候已经详细分析了内存控制器的设置位置,这里不再赘述。

内存控制器设置在board/samsung/smdk2440/lowlevel_init.S文件中的 lowlevel_init 函数中,接下来开始修改。

B4_BWSCON寄存器的设置是DW16,和DM9000一致,不用修改:

时序参数宏定义中只需要修改一处即可:

设置完成。

编译之后,结果还是不符合预期,提示找不到网卡,根据启动过程进行错误分析。

4. 修改初始化函数

在uboot启动的第二阶段board_init_r函数中,网卡初始化调用的是eth_initialize函数:

eth_initialize 函数在net/eth.c文件中,其中又调用了 board_eth_init 函数:

board_eth_init 函数在board/samsung/smdk2440/smdk2410.c文件中,实现如下:

可以看到,当定义CONFIG_CS8900时,会调用其初始化函数,但是此处我们定义的是DM9000,所以无任何操作。

修改此函数实现:

编译,下载到开发板中,在串口终端中查看结果:

5. 优化

在这里发现一个不影响功能的小问题,顺手优化一下,在smdk2440文件夹下,smdk2410.c文件名没有修改

修改文件名为smdk2440.c:

然后修改此目录下的makefile,将smdk2440.c文件加入工程:

重新编译:

make distclean
make smdk2440_config
make

编译通过,证明没有问题,将编译后的可执行文件下载到开发板中,查看输出信息:

6. 网卡功能测试

发布了229 篇原创文章 · 获赞 598 · 访问量 26万+

Guess you like

Origin blog.csdn.net/Mculover666/article/details/104549535