CycloneV Linux Application: Write to PIO over HPSLWMaster Hangs Kernel

Hello, I currently have a hardware design with the HPS lightweight master connected to a 10-bit output PIO which in turn is connected to 10 LEDs on my board. I am trying to write the PIO output register.


p. 304 suggests I need to write to register offset 0x0 from the base of the peripheral.

The PIO itself is at address 0x0 one the AXI bus in the Platform Designer qsys design

Here is my software

#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>
#include <sys/mman.h>
#include <unistd.h>

int main(int argc, char *argv[]) {

    off_t offset = 0xFF200000;
    size_t len = 4096;

    // Truncate offset to a multiple of the page size, or mmap will fail.
    size_t pagesize = sysconf(_SC_PAGE_SIZE);
    off_t page_base = (offset / pagesize) * pagesize;
    off_t page_offset = offset - page_base;

    int fd = open("/dev/mem", O_SYNC);
    unsigned char *mem = mmap(NULL, page_offset + len, PROT_READ | PROT_WRITE, MAP_PRIVATE, fd, page_base);
    if (mem == MAP_FAILED) {
        perror("Can't map memory");
        return -1;
    }

    printf("Mapping successful\n");
    size_t i;
    for (i = 0; i < 1; ++i)
        printf("%02x ", (int)mem[page_offset + i]);

    return 0;
}

I am just trying to read the initial value established in the Quartus design (displayed successfully on the LEDs upon FPGA load).

When I do not enable the bridge, the kernel gives an output that it cannot complete the write and everything continues on (Linux kills the application and keeps running).

When I have the bridge enabled, the execution of the program hangs, and eventually the kernel panics and initiates a total reboot of the system.

This leads me to believe it is a hardware issue. In this case I have two questions:

  1. How can you build SignalTap into a design loaded from u-boot so that you can see what is going on in the SoC FPGA firmware that is causing this read to hang?
  2. What could be causing this issue?

I didn’t have my clock constrained to my oscillator. Once the hardware is in place, it is easy to use /dev/mem to read and write to the fabric

2 Likes