nios2 通过AS接口对另一块FPGA在线升级
项目中需要通过一块FPGA控制板通过两个AS接口对另外两个FPGA进行在线升级。
FPGA控制板程序中运行的是基于nios2处理器的程序。
nios2的bsp启动过程中会对3个EPCS控制器配置:
EPCS_FLASH_CONTROLLER_0 控制器是控制板本身的EPCS控制器
EPCS_RSU_SCC1 、EPCS_RSU_SCC2 是通过AS接口连接到另外两个EPCS的控制器
fpga接口配置:
assign RSU_SCC1_PDCLK = RSU_SCC_EN ? RSU_SCC1_DCLK : 1'bz;
assign RSU_SCC1_PNSCE = RSU_SCC_EN ? RSU_SCC1_NSCE : 1'bz;
assign RSU_SCC1_PASDO = RSU_SCC_EN ? RSU_SCC1_ASDO : 1'bz;
assign RSU_SCC1_PCfgDn = RSU_SCC_EN ? RSU_SCC1_ConfigDone : 1'bz;
assign RSU_SCC1_PnConfg = RSU_SCC_EN ? RSU_SCC1_nConfig : 1'bz;
assign RSU_SCC2_PDCLK = RSU_SCC_EN ? RSU_SCC2_DCLK : 1'bz;
assign RSU_SCC2_PNSCE = RSU_SCC_EN ? RSU_SCC2_NSCE : 1'bz;
assign RSU_SCC2_PASDO = RSU_SCC_EN ? RSU_SCC2_ASDO : 1'bz;
assign RSU_SCC2_PCfgDn = RSU_SCC_EN ? RSU_SCC2_ConfigDone : 1'bz;
assign RSU_SCC2_PnConfg = RSU_SCC_EN ? RSU_SCC2_nConfig : 1'bz;
#include "epcs_reinit.h" #include <stdio.h> #include "system.h" #include "altera_avalon_pio_regs.h" extern void alt_sys_epcs_control_init( void ); /* 在bsp/alt_sys_init.c文件最后增加下面的代码 void alt_sys_epcs_control_init( void ) { ALTERA_AVALON_EPCS_FLASH_CONTROLLER_INIT ( EPCS_RSU_SCC1, EPCS_RSU_SCC1); ALTERA_AVALON_EPCS_FLASH_CONTROLLER_INIT ( EPCS_RSU_SCC2, EPCS_RSU_SCC2); } */ void epcs_reinit(void) { IOWR_ALTERA_AVALON_PIO_DATA(RSU_SCC1_EN_BASE,1); IOWR_ALTERA_AVALON_PIO_DATA(RSU_SCC1_NCS_BASE, 1); IOWR_ALTERA_AVALON_PIO_DATA(RSU_SCC1_NCONFIG_BASE, 0); IOWR_ALTERA_AVALON_PIO_DATA(RSU_SCC2_EN_BASE,1); IOWR_ALTERA_AVALON_PIO_DATA(RSU_SCC2_NCS_BASE, 1); IOWR_ALTERA_AVALON_PIO_DATA(RSU_SCC2_NCONFIG_BASE, 0); alt_sys_epcs_control_init(); } void epcs_release(void) { IOWR_ALTERA_AVALON_PIO_DATA(RSU_SCC1_NCS_BASE, 0); IOWR_ALTERA_AVALON_PIO_DATA(RSU_SCC1_NCONFIG_BASE, 0); IOWR_ALTERA_AVALON_PIO_DATA(RSU_SCC2_NCS_BASE, 0); IOWR_ALTERA_AVALON_PIO_DATA(RSU_SCC2_NCONFIG_BASE, 0); IOWR_ALTERA_AVALON_PIO_DATA(RSU_SCC1_EN_BASE,0); IOWR_ALTERA_AVALON_PIO_DATA(RSU_SCC2_EN_BASE,0); }
控制板程序初始化的3个EPCS,其中两个会初始失败,所以程序需要通过调用 alt_sys_epcs_control_init函数重新初化一次。