FPGA registers access from Linux userspace

From ArmadeusWiki
Revision as of 13:59, 8 May 2008 by Salocin68 (Talk | contribs) (fpgaregs user binary)

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 w hex_address or fpgaregs l hex_address where 'w' means a 16bits access and 'l' a 32bits access
  • for write
# fpgaregs w hex_address hex_value or fpgaregs l hex_address hex_value
  • Examples:
    • Read a 32bits register at internal FPGA address 0x0010:
# fpgaregs l 0x10
    • Write 0x0123 (16bits) to FPGA register 0x0020:
# fpgaregs w 0x20 0x0123