FPGA registers access from Linux userspace: Difference between revisions

From ArmadeusWiki
Jump to navigationJump to search
FabienM (talk | contribs)
FabienM (talk | contribs)
No edit summary
Line 1: Line 1:
== FPGARegs usage ==
[[Category:FPGA]]
* Write to a FPGA address: ''fpgareg addr value''
 
# fpgaregs 1000 abcd
 
this will write 0xabcd (16bits only interface) at the FPGA internal address 0x1000
==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


* Read a FPGA address: ''fpgareg addr''
You can select it under kernel or as module then compile it:
  # fpgaregs 1000
  $ make
this will read the address 0x1000


For details take a look at this page: [[Linux Debug |Tips to debug under Linux]]
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


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


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


==Changing FPGA IP's registers from Linux user space with fpgaregs==
Then make the node :
$ mknod /dev/fpgaaccess c 250 0


This tool allows you to access FPGA registers from linux userspace/console. This way you can easily debug your driver directly from the Linux console.
=== fpgaregs user binary ===


First, you have enable this tool in Buildroot (package selection for target):
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.
$ make menuconfig


Once done, compile it:
To compile it, go to ''target/linux/module/fpga/fpgaaccess'' directory then make it :
  $ make
  $ make fpgaregs


The generated file is located in buildroot/build_arm_nofpu/fpgaregs-1.0/. Now you can copy it on your target.
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:
Then in linux, launch it like that:
  # fpgaregs address (for read) or fpga address value (for write)
*for read:
 
  # fpgaregs hex_address
===Examples:===
*for write
Show register at internal FPGA address 0x0010:
# fpga hex_address hex_value
  # fpgaregs 10
*Examples:
**Show register at internal FPGA address 0x0010:
  # fpgaregs 0x10


Write 0x0123 to FPGA register 0x0020:
**Write 0x0123 to FPGA register 0x0020:
  # fpgaregs 20 0123
  # fpgaregs 0x20 0x0123

Revision as of 14:55, 8 April 2008


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