FPGA registers access from Linux userspace

From ArmadeusWiki
Revision as of 14:55, 8 April 2008 by FabienM (Talk | contribs)

Jump to: navigation, search


Changing FPGA IP's registers from Linux user space with fpgaregs

This tool allows you to access FPGA registers from linux userspace/console. This way you can easily debug your driver and your IP directly from the Linux console.

fpgaaccess driver

First, you have to compile fpgaaccess driver, select it from linux-menuconfig menu (Device Drivers ---> Armadeus specific drivers ---> FPGA Drivers ---> Armadeus fpgaaccess driver) :

$ make linux-menuconfig

You can select it under kernel or as module then compile it:

$ make

If you choose module (M) you have to insert it in kernel (the module is in armadeus/target/linux/modules/fpga/fpgaaccess/fpgaaccess.ko):

$ insmod fpgaaccess.ko

This will load a characters device, you can find Major and minor number in dmesg :

$ dmesg | grep fpgaaccess
fpgaaccess: MAJOR: 250 MINOR: 0

Then make the node :

$ mknod /dev/fpgaaccess c 250 0

fpgaregs user binary

If you want you can use the driver with system call pread() and pwrite(), but it easiest to use the program provided by driver : fpgaregs.

To compile it, go to target/linux/module/fpga/fpgaaccess directory then make it :

$ make fpgaregs

The generated file is located in target/linux/module/fpga/fpgaaccess. Now you can copy it on your target. Then in linux, launch it like that:

  • for read:
# fpgaregs hex_address
  • for write
# fpga hex_address hex_value
  • Examples:
    • Show register at internal FPGA address 0x0010:
# fpgaregs 0x10
    • Write 0x0123 to FPGA register 0x0020:
# fpgaregs 0x20 0x0123