Difference between revisions of "FPGA registers access from Linux userspace"

From ArmadeusWiki
Jump to: navigation, search
(FPGARegs usage)
Line 1: Line 1:
== FPGARegs usage ==
 
* Write to a FPGA address: ''fpgareg addr value''
 
# fpgaregs 1000 abcd
 
this will write 0xabcd (16bits only interface) at the FPGA internal address 0x1000
 
 
* Read a FPGA address: ''fpgareg addr''
 
# fpgaregs 1000
 
this will read the address 0x1000
 
 
For details take a look at this page: [[Linux Debug |Tips to debug under Linux]]
 
 
 
[[Category:FPGA]]
 
[[Category:FPGA]]
  
Line 15: Line 4:
 
==Changing FPGA IP's registers from Linux user space with fpgaregs==
 
==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 directly from the Linux console.
 
  
First, you have enable this tool in Buildroot (package selection for target):
+
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.
$ make menuconfig
+
  
Once done, compile it:
+
=== 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
 
  $ make
  
The generated file is located in buildroot/build_arm_nofpu/fpgaregs-1.0/. Now you can copy it on your target.
+
If you choose module (M) you have to insert it in kernel (the module is in armadeus/target/linux/modules/fpga/fpgaaccess/fpgaaccess.ko):
Then in linux, launch it like that:
+
  $ insmod fpgaaccess.ko
  # fpgaregs address (for read) or fpga address value (for write)
+
  
===Examples:===
+
This will load a characters device, you can find Major and minor number in dmesg :
Show register at internal FPGA address 0x0010:
+
 
  # fpgaregs 10
+
$ 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:
+
**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