0

I am trying to read FPGA memory on a Xilinx Zynq board (zc702) as part of porting an RTEMS driver to Linux. I am using the devmem2 and mmap_test programs that I cross-compile for the board using the Yocto cross-compiler. The board has 1 GB of normal memory. This means that any read between 0x0 and 0x40000000 returns valid memory. The problem is, however, when reading from 0x7AA00000, the kernel crashes immediately without even printing a kernel panic message to the terminal (serial port with minicom and ssh). I even wrote small sample kernel modules to read from that address and use kprint, but it results in the same crash. Since the driver works with RTEMS, the physical memory address has been verified to be correct.

What steps have to be taken to be able to read from the FPGA memory/registers without Linux crashing?

5
  • I suppose you have some kind of debugger, so did you look at how that memory region is mapped in the MMU? – Philippos Jan 10 '18 at 8:35
  • By debugger, do you mean GDB or Jtag debugging? And which tools can be used for debugging the MMU? – Moritz Jan 10 '18 at 8:42
  • I don't think you can do this with gdb, but I'm not sure. With a JTAG debugger you can typically see the memory mapping somehow. At least I remember doing so with Lauterbach Trace32. – Philippos Jan 10 '18 at 8:51
  • Directly debugging the MMU is kind of hairy due to all the assembler specific code. Perfect would be a high-level representation of the mappings. This is a related question without any answers, so it seams tricky. – Moritz Jan 10 '18 at 9:00
  • I don't know your Zynq, but I suppose the ARM core also interacts with the MMU via the cp15 coprocessor, while the actual memory mapping is held in normal RAM. If you find out the map currently used, it's no rocket science to interpret the mapping format. But it's a lot easier if ou can directly see it in your JTAG debugger. But at this point this stops being a unix&linux question. – Philippos Jan 10 '18 at 9:11
0

I finally found out why it was always crashing. It was a combination of two factors (as is the case for the tricky problems).

  1. When accessing memory through /dev/mem it has to be aligned to the page
  2. When accessing FPGA memory, the bitstream has to be loaded first

Initially I had been loading the FPGA bitstream (with cat stream.bit > /dev/xdevcfg) and then trying to access the registers with either directly dereferencing the physical address (no mapping). Later, I looked at reading through /dev/mem with devmem2 but not loading the bitstream. Both caused similar errors, program crashes and kernel freezes, and it took a while to see that there were two errors.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.