It doesn’t seem to work. I can read the qsys_id, I can blink leds.
But I can’t write to a fifo and read from it, despite trying the same code.
I received a “Transparent bridge in fifo_0 of type altera_avalon_fifo is not yet supported” when creating the device tree using:
https://rocketboards.org/foswiki/view/Documentation/A10GSRDGeneratingTheLinuxDeviceTree
void * GLOBAL_LW_BRIDGE_ADDRESS;
int main(void) {
uint32_t * custom_led_map = 0;
volatile uint32_t * fifo_0_in = 0;
volatile uint32_t * fifo_0_out = 0;
volatile uint32_t * fifo_0_lvl = 0;
// The start address and length of the Lightweight bridge
#define HPS_TO_FPGA_LW_BASE 0xFF200000
#define HPS_TO_FPGA_LW_SPAN 0x1FFFFF
#define HPS_TO_FPGA_ON_CHIP_BASE 0xC0000000
extern void * GLOBAL_LW_BRIDGE_ADDRESS;
int devmem_fd = 0;
// Open up the /dev/mem device (aka, RAM)
devmem_fd = open("/dev/mem", O_RDWR | O_SYNC);
if(devmem_fd < 0) {
perror("devmem open");
exit(EXIT_FAILURE);
}
// mmap() the entire address space of the Lightweight bridge so we can access our custom module
GLOBAL_LW_BRIDGE_ADDRESS = (uint32_t*)mmap(NULL, HPS_TO_FPGA_LW_SPAN, PROT_READ|PROT_WRITE, MAP_SHARED, devmem_fd, HPS_TO_FPGA_LW_BASE);
if(GLOBAL_LW_BRIDGE_ADDRESS == MAP_FAILED) {
perror("devmem mmap");
close(devmem_fd);
exit(EXIT_FAILURE);
}
custom_led_map = (uint32_t*)(GLOBAL_LW_BRIDGE_ADDRESS + LED_PIO_BASE);
fifo_0_in = ( uint32_t*)(GLOBAL_LW_BRIDGE_ADDRESS + FIFO_0_IN_BASE);
fifo_0_out = ( uint32_t*)(GLOBAL_LW_BRIDGE_ADDRESS + FIFO_0_OUT_BASE);
fifo_0_lvl = ( uint32_t*)(GLOBAL_LW_BRIDGE_ADDRESS + FIFO_0_IN_CSR_BASE);
// Turn all LEDs on
*custom_led_map = 0xFF;
*fifo_0_in = 0xFFFF;
*fifo_0_in = 0xFFF1;
*fifo_0_out = 0xEEEE;
// Wait half a second
usleep(500000);
printf("custom leds: %x \n", *custom_led_map);
printf("read lvl: %x \n", *fifo_0_lvl);
printf("read out: %x \n", *fifo_0_out);