当前位置:网站首页>[i.mx6ul] u-boot migration (VI) network driver modification lan8720a
[i.mx6ul] u-boot migration (VI) network driver modification lan8720a
2022-06-25 02:28:00 【Full stack programmer webmaster】
Hello everyone , I meet you again , I'm your friend, Quan Jun .
I.MX6UL/ULL There is an Ethernet inside MAC peripherals , That is to say ENET, Need an external PHY Chip to realize network communication function , The inside MAC+ external PHY Chip scheme .
I.MX6UL/ULL There are two network interfaces ENET1 and ENET2,I.MX6U-ALPHA The development board provides these two network interfaces , among ENET1 and ENET2 All use LAN8720A As PHY chip .
NXP Official I.MX6ULL EVK Development board use KSZ8081 The star PHY chip ,LAN8720A comparison KSZ8081 Small size 、 Less peripheral devices 、 Advantages such as low price . Use it directly KSZ8081 Yes, of course , But we may not use it in actual products KSZ8081, Sometimes, in order to reduce costs, they choose other PHY chip . There is a problem at this time : Changed PHY What about the network driver after the chip ? So ,I.MX6U-ALPHA The development board will ENET1 and ENET2 Of PHY Instead of LAN8720A, In this way, we can explain the replacement PHY How to adjust the network driver after the chip , Make the network work properly .
I.MX6U-ALPHA Development board ENET1 Pin and NXP Official I.MX6ULL EVK The development board is basically the same , Only the reset pin is different . As can be seen from the figure ,I.MX6U-ALPHA Development board ENET1 Reset pin ENET1_RST Got it I.M6ULL Of SNVS_TAMPER7 On this pin .
LAN8720A There are registers inside ,I.MX6ULL Will read LAN8720 Internal register to determine the current physical link status 、 Connection speed (10M still 100M) And duplex status ( Half duplex or full duplex ). I.MX6ULL adopt MDIO Interface to read PHY The internal register of the chip ,MDIO The interface has two pins ,ENET_MDC and ENET_MDIO, ENET_MDC Provide clock ,ENET_MDIO Data transfer . One MIDO Interfaces can manage 32 individual PHY chip , The same MDIO These under the interface PHY Use different device addresses to distinguish ,MIDO The interface can access the corresponding device through different device addresses PHY chip .I.MX6U-ALPHA Development board ENET1 Connected to LAN8720A The device address is 0X0, So we have to modify ENET1 If the network is driven, the focus is on three points :
①、ENET1 Reset pin initialization . ENET1_RST –>SNVS_TAMPER7 ②、LAN8720A The device ID.0x0 ③、LAN8720 drive
modify ENET2 If the network is driven, the focus is on three points :
①、ENET1 Reset pin initialization . ENET1_RST –>SNVS_TAMPER8 ②、LAN8720A The device ID.0x1 ③、LAN8720 drive
Let's start to modify the file .
- The input terminal :gedit include/configs/mx6ull_mybsp_emmc.h
The following figure shows the modified :
- Delete uboot in 74LV595 Driver code for , because NXP official I.MX6ULL EVK Development board use 74LV595 To expand IO, The reset pins of the two networks are controlled by 74LV595 Controlled .I.MX6U-ALPHA The development board does not use 74LV595, So we delete the code .
The input terminal :gedit board/freescale/mx6ull_mybsp_emmc/mx6ull_mybsp_emmc.c
Before the change :
#define IOX_SDI IMX_GPIO_NR(5, 10)
#define IOX_STCP IMX_GPIO_NR(5, 7)
#define IOX_SHCP IMX_GPIO_NR(5, 11)
#define IOX_OE IMX_GPIO_NR(5, 8)After modification :
#define ENET1_RESET IMX_GPIO_NR(5, 7)
#define ENET2_RESET IMX_GPIO_NR(5, 8)- ENET1 The reset pin of is connected to SNVS_TAMPER7 On , Corresponding GPIO5_IO07,ENET2 The reset pin of is connected to Receive SNVS_TAMPER8 On , Corresponding GPIO5_IO08. Continue to mx6ull_mybsp_emmc.c Find the following code in , Delete all the structures :
static iomux_v3_cfg_t const iox_pads[] = {
/* IOX_SDI */
MX6_PAD_BOOT_MODE0__GPIO5_IO10 | MUX_PAD_CTRL(NO_PAD_CTRL),
/* IOX_SHCP */
MX6_PAD_BOOT_MODE1__GPIO5_IO11 | MUX_PAD_CTRL(NO_PAD_CTRL),
/* IOX_STCP */
MX6_PAD_SNVS_TAMPER7__GPIO5_IO07 | MUX_PAD_CTRL(NO_PAD_CTRL),
/* IOX_nOE */
MX6_PAD_SNVS_TAMPER8__GPIO5_IO08 | MUX_PAD_CTRL(NO_PAD_CTRL),
}; - Continue to mx6ull_mybsp_emmc.c Function found in iox74lv_init and iox74lv_set, Delete both functions !
- stay mx6ull_mybsp_emmc.c Find board_init function , This function is the board initialization function , Will be board_init_r call .
board_init Would call imx_iomux_v3_setup_multiple_pads and iox74lv_init These two functions are used to initialize 74lv595 Of GPIO, Delete these two lines . thus ,mx6ull_mybsp_emmc.c About China 74LV595 Chip driver All the moving codes have been deleted .
add to I.MX6U-ALPHA Development board network reset pin driver
stay mx6ull_mybsp_emmc.c Keyword found in : ①static iomux_v3_cfg_t const fec1_pads[] ②static iomux_v3_cfg_t const fec2_pads[]
The following contents need to be added :
MX6_PAD_SNVS_TAMPER7__GPIO5_IO07 | MUX_PAD_CTRL(NO_PAD_CTRL),/* initialization ETH1 RESET Pin */MX6_PAD_SNVS_TAMPER8__GPIO5_IO08 | MUX_PAD_CTRL(NO_PAD_CTRL),/* initialization ETH2 RESET Pin */Continue in file mx6ull_mybsp_emmc.c Function found in setup_iomux_fec. Put these two IO Set to output and reset the hardware LAN8720A, This hardware reset is very important ! Otherwise, it may lead to uboot Can't recognize LAN8720A. Add the following :
static void setup_iomux_fec(int fec_id)
{
if (fec_id == 0)
{
imx_iomux_v3_setup_multiple_pads(fec1_pads,
ARRAY_SIZE(fec1_pads));
gpio_direction_output(ENET1_RESET, 1);
gpio_set_value(ENET1_RESET, 0);
mdelay(100);
gpio_set_value(ENET1_RESET, 1);
}
else
{
imx_iomux_v3_setup_multiple_pads(fec2_pads,
ARRAY_SIZE(fec2_pads));
gpio_direction_output(ENET2_RESET, 1);
gpio_set_value(ENET2_RESET, 0);
mdelay(100);
gpio_set_value(ENET2_RESET, 1);
}
}modify drivers/net/phy/phy.c Functions in the file genphy_update_link
uboot Medium LAN8720A There is a problem with the driver , Open file drivers/net/phy/phy.c, Find the function genphy_update_link, This is a universal PHY Driving functions , This function is used to update PHY Connection status and speed .
The input terminal :gedit drivers/net/phy/phy.c Search for keywords :genphy_update_link Revised as follows :
/* LAN8720 must software*/
#ifdef CONFIG_PHY_SMSC
static int lan8720_flag = 0;
int bmcr_reg = 0;
if (lan8720_flag == 0) {
bmcr_reg = phy_read(phydev, MDIO_DEVAD_NONE, MII_BMCR); /* Read register BMCR The default value is */
phy_write(phydev, MDIO_DEVAD_NONE, MII_BMCR, BMCR_RESET); /* Software reset , Automatic reset */
while(phy_read(phydev, MDIO_DEVAD_NONE, MII_BMCR) & BMCR_RESET) {
udelay(100);
}
phy_write(phydev, MDIO_DEVAD_NONE, MII_BMCR, bmcr_reg); /* BMCR Write the original value */
lan8720_flag = 1;
}
#endifrecompile uboot
./mx6ull_mybsp_emmc.sh or make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- mx6ull_mybsp_emmc_defconfig make V=1 ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- -j16
Download burning verification :
chmod 777 imxdownload
// To give imxdownload Executable rights
./imxdownload u-boot.bin /dev/sdg
// burning u-boot.bin To SD In the card After the burning is completed, the SD Card insertion I.MX6U-ALPHA Development board TF In the card slot , Finally, set the development board from SD Card activation . open SecureCRT, Set the serial port used by the development board and open it , Reset the development board .
stay uboot Set several environment variables before using the network in , The order is as follows :
setenv ipaddr 192.168.1.55
// Development board IP Address
setenv ethaddr 00:04:9f:04:d2:35
// Development board network card MAC Address
setenv gatewayip 192.168.1.1
// Default gateway of development board
setenv netmask 255.255.255.0
// Development board subnet mask
setenv serverip 192.168.1.250
// Server address , That is to say Ubuntu Address
saveenv
// Save environment variables SecureCRT Of uboot Use in ping command .
ping 192.168.1.250 Yes “host 192.168.1.250 is alive” This sentence , explain ping Host succeeded .
Publisher : Full stack programmer stack length , Reprint please indicate the source :https://javaforall.cn/151761.html Link to the original text :https://javaforall.cn
边栏推荐
- 商城项目 pc----商品详情页
- 把 Oracle 数据库从 Windows 系统迁移到 Linux Oracle Rac 集群环境(4)—— 修改 oracle11g rac 集群的 scanIP
- Summary of stack frame in arm assembly
- Planification du réseau | [quatre couches de réseau] points de connaissance et exemples
- 【Proteus仿真】Arduino UNO+数码管显示4x4键盘矩阵按键
- Squid 代理服务器之 ACL 访问控制
- 内网学习笔记(5)
- Test / development programmers, 30, do you feel confused? And where to go
- Please run IDA with elevated permissons for local debugging.
- How can Huatai Securities open an account to achieve one in ten thousand? Are securities accounts safe and reliable
猜你喜欢

【FPGA】串口以命令控制温度采集

计网 | 【四 网络层】知识点及例题

【STL源码剖析】配置器(待补充)

内网学习笔记(5)

Talking about the advantages of flying book in development work | community essay solicitation

EasyCVR国标协议接入的通道,在线通道部分播放异常是什么原因?

转行软件测试2年了,给还在犹豫的女生一点建议

It is said that Yijia will soon update the product line of TWS earplugs, smart watches and bracelets

会自动化—10K,能做自动化—20K,你搞懂自动化测试没有?

What is the reason for the disconnection of video playback due to the EHOME protocol access of easycvr platform?
随机推荐
What is the reason for the disconnection of video playback due to the EHOME protocol access of easycvr platform?
Intranet learning notes (5)
ida中交叉引用的解析
How to quickly familiarize yourself with the code when you join a new company?
记一次beego通过go get命令后找不到bee.exe的坑
对进程内存的实践和思考
centos7.3修改mysql默认密码_详解Centos7 修改mysql指定用户的密码
Talking about the advantages of flying book in development work | community essay solicitation
Cusdis - lightweight, privacy first open source comment system | chain of the city
Dirvish Chinese document of vim
当人们用互联网式的思维和视角来看待产业互联网的时候,其实已陷入到了死胡同
F - Spices(线性基)
internship:svn的使用
Can automate - 10k, can automate - 20K, do you understand automated testing?
Distributed transaction solutions and code implementation
内网学习笔记(7)
It's 2022, and you still don't know what performance testing is?
Migrate Oracle database from windows system to Linux Oracle RAC cluster environment (1) -- migrate data to node 1
分布式事务解决方案和代码落地
EasyCVR国标协议接入的通道,在线通道部分播放异常是什么原因?