Forum Discussion

Altera_Forum's avatar
Altera_Forum
Icon for Honored Contributor rankHonored Contributor
9 years ago

Check FPGA / bridges before accessing them

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

6 Replies

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Hi sunshine,

    the bridges are enabled:

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

    1

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

    1

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

    1

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

    Joachim
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    --- Quote Start ---

    Hi sunshine,

    the bridges are enabled:

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

    1

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

    1

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

    1

    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?
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    You can check the state of the FPGA configuration with:

    
    cat /sys/class/fpga/fpga0/status
    

    A well configured FPGA should return: "user mode".
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    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.
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    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.