Zynq-Linux移植学习笔记之十-u-boot网络配置

本文介绍了在Zynq开发板ZC706上进行Linux网络配置的过程,涉及Zynq、PHY和BCM5396网络交换芯片的配置。在u-boot中修改了Board.c、Eth.c和Zynq_gem.c三个关键文件,完成配置后,可以通过tftp加载设备树和镜像文件,实现快速启动。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

               

在zynq开发板zc706上,网络通路由下面三个设备组成:


其中zynq负责对phy进行配置,当zynq上的网络控制器以及phy完成正确配置时,能够看到RJ45上面的黄灯亮,此时表明链路已经通了。如果u-boot中已经设置了IP地址,通过网线就可以ping通电脑,此时会打印host alive这句话。

但是如果板子不是这样做的,比如是下面这种方式:


这里用到了BCM5396网络交换芯片,此时要保证网络链路通就需要对5396和两个PHY进行配置。幸运地是,PHY0由5396进行配置,当我们对5396进行正确配置后,PHY0也就配置完成了,PHY1的配置还是老样子。整个配置可以分为两步走,首先通过SPI总线配置5396,再配置PHY1,完成全部配置后,就能看到RJ45上面的黄灯亮起。

 

u-boot中需要修改的代码主要涉及三个地方

1、  arch/arm/lib/Board.c

其中board_init_r函数中需要在网络驱动配置前加入配置bcm5396的函数调用,这里我放在了串口驱动配置之后运行。

void board_init_r(gd_t *id, ulong dest_addr){ ulong malloc_start;#if !defined(CONFIG_SYS_NO_FLASH) ulong flash_size;#endif gd->flags |= GD_FLG_RELOC; /* tell others: relocation done */ bootstage_mark_name(BOOTSTAGE_ID_START_UBOOT_R, "board_init_r"); monitor_flash_len = _end_ofs; /* Enable caches */ enable_caches(); debug("monitor flash len: %08lX\n", monitor_flash_len); board_init(); /* Setup chipselects */ /*  * TODO: printing of the clock inforamtion of the board is now  * implemented as part of bdinfo command. Currently only support for  * davinci SOC's is added. Remove this check once all the board  * implement this.  */#ifdef CONFIG_CLOCKS set_cpu_clk_info(); /* Setup clock information */#endif serial_initialize(); myspi_init(); /*init bcm5396*/ printf("Now running in RAM - U-Boot at: %08lx\n", dest_addr);#ifdef CONFIG_LOGBUFFER


 

2、  net/Eth.c

在其中加入配置bcm5396的代码

 

void myspi_init(){ XSpiPs Spi; int i32Option,status; int i; unsigned char workBuf[10]; workBuf[0]=0xf0; workBuf[1]=0x1; g_SpiConfig = &XSpiPs_ConfigTable[0]; //Initialize the SPI device. Spi.IsBusy = 0; Spi.Config.BaseAddress = g_SpiConfig->BaseAddress; //Spi.StatusHandler = StubStatusHandler; Spi.SendBufferPtr = NULL; Spi.RecvBufferPtr = NULL; Spi.RequestedBytes = 0; Spi.RemainingBytes = 0; Spi.IsReady = 0x11111111; XSpiPs_WriteReg(Spi.Config.BaseAddress,0,0x00020000); //Initialize the SPI device. end  i32Option = 0x1 | 0x2 | 0x4 | 0x10; Spi_SetOptions(&Spi, i32Option); XSpiPs_SetSlaveSelect(&Spi,1 ); XSpiPs_SetClkPrescaler(&Spi, 6 ); workBuf[0]=0xf0; workBuf[1]=0x1; workBuf[
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值