Nios® V/II Embedded Design Suite (EDS)
Support for Embedded Development Tools, Processors (SoCs and Nios® V/II processor), Embedded Development Suites (EDSs), Boot and Configuration, Operating Systems, C and C++
12599 Discussions

Check FPGA / bridges before accessing them

Altera_Forum
Honored Contributor II
1,763 Views

I want to access the switches on the tersIC DE0-Naoo-SoC board from Linux. I load the appropriate FPGA and access the LW bridge (with a c program). Everything works fine. 

 

But if, due to eg. misconfiguration, the FPGA is not loaded with the appropriate file the Linux programm will hang forever when accesing the bridge. Thus stopping the complete system! 

 

Is there a way to check from Linux if the address I want to access will work? 

 

Joachim
0 Kudos
6 Replies
Altera_Forum
Honored Contributor II
545 Views

If I am not mistaken, you can check the status of the bridge via: 

cat /sys/class/fpga-bridge/fpga2hps/enable 

cat /sys/class/fpga-bridge/hps2fpga/enable 

cat /sys/class/fpga-bridge/lwhps2fpga/enable 

 

https://rocketboards.org/foswiki/view/documentation/gsrd131programmingfpga
0 Kudos
Altera_Forum
Honored Contributor II
545 Views

Hi sunshine, 

 

the bridges are enabled: 

 

root@jwde0soc:~# cat /sys/class/fpga-bridge/lwhps2fpga/enable 

root@jwde0soc:~# cat /sys/class/fpga-bridge/hps2fpga/enable 

root@jwde0soc:~# cat /sys/class/fpga-bridge/fpga2hps/enable 

 

Still the program hangs when reading from an lwhps2fpga-Address (mapped with /dev/mem). 

 

Joachim
0 Kudos
Altera_Forum
Honored Contributor II
545 Views

 

--- Quote Start ---  

Hi sunshine, 

 

the bridges are enabled: 

 

root@jwde0soc:~# cat /sys/class/fpga-bridge/lwhps2fpga/enable 

root@jwde0soc:~# cat /sys/class/fpga-bridge/hps2fpga/enable 

root@jwde0soc:~# cat /sys/class/fpga-bridge/fpga2hps/enable 

 

Still the program hangs when reading from an lwhps2fpga-Address (mapped with /dev/mem). 

 

Joachim 

--- Quote End ---  

 

 

Looks like checking the bridge status may not be a viable option... since the hang happen if the FPGA is misconfigured, perhaps another way is to use the HPS FPGA manager to ensure that the configuration is executed successfully?
0 Kudos
Altera_Forum
Honored Contributor II
545 Views

You can check the state of the FPGA configuration with: 

cat /sys/class/fpga/fpga0/status  

 

A well configured FPGA should return: "user mode".
0 Kudos
Altera_Forum
Honored Contributor II
545 Views

Nope. The FPGA is configured sucessfully. But with the wrong rbf. 

 

The main problem is if some setup is wrong the FPGA does not have a register at the address I access.  

I could figure out from my software if I get a valid result. But the whole systems hangs after an access.  

So I am looking for a way to check prior to accessing the address. 

 

My customers want to build a drives control system with this and they don't like that some Linux process can hang up the whole system by just accessing a wrong address.
0 Kudos
Altera_Forum
Honored Contributor II
545 Views

This sounds like a design bug. Do you have any idea, why the the system hangs up? The only reasons i had so far are: 

  • unconfigured FPGA 

  • missing bridge in design 

  • FPGA Design in reset, or missing clock 

  • wrong handled waitrequest in design 

  • timing issue 

 

If you have several designs you could identify them with the GPI Pins from the HPS. There is no risk of hanging up.
0 Kudos
Reply