Skip to content
This repository has been archived by the owner on Dec 1, 2021. It is now read-only.

Add a tool to program Cyclone V FPGA on de10nano board from userspace #720

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

antonionevado
Copy link
Contributor

It adds a new tool to program Cyclone V FPGA found on de10 nano board.
From the command line, in Linux user space, this tool accepts an .rbf file and program the FPGA.
This tool has the same effect than rebooting the board.

Motivation and Context

Useful for debugging and testing.

Description

Is a new tool, nothing else was modified.
A binary is provided for easy use.

The procedure for configuring the FPGA is described in the Cyclone V configuration manual:

  1. Set the cdratio and cfgwdth bits of the ctrl register in the FPGA manager registers (fpgamgrregs) to
    match the characteristics of the configuration image. These settings are dependant on the MSEL pinsinput.

  2. Set the nce bit of the ctrl register to 0 to enable HPS configuration.

  3. Set the en bit of the ctrl registerto 1 to give the FPGA manager control of the configuration inputsignals.

  4. Set the nconfigpull bit of the ctrl registerto 1 to pull down the nCONFIG pin and put the FPGA portion of the device into the reset phase.

  5. Poll the mode bit of the stat register and wait until the FPGA enters the reset phase.

  6. Set the nconfigpull bit of the ctrl register to 0 to release the FPGA from reset.

  7. Read the mode bit of the stat register and wait until the FPGA enters the configuration phase.

  8. Clear the interrupt bit of nSTATUS (ns) in the gpio interrupt register (fpgamgrregs.mon.gpio_porta_eoi).

  9. Set the axicfgen bit of the ctrl register to 1 to enable sending configuration data to the FPGA.

  10. Write the configuration image to the configuration data register (data) in the FPGA manager module configuration data registers (fpgamgrdata). You can also choose to use a DMA controller to transfer the configuration image from a peripheral device to the FPGA manager.

  11. Use the fpgamgrregs.mon.gpio_ext_porta registers to monitor the CONF_DONE (cd) and nSTATUS (ns) bits.

  12. Set the axicfgen bit of the ctrl register to 0 to disable configuration data on AXI slave.

  13. Clear any previous DONE status bywriting a 1 to the dcntdone bit of the DCLK status register(dclkstat) to clear the completed status flag.

  14. Send the DCLKs required by the FPGA to enter the initialization phase.

  15. Poll the dcntdone bit of the DCLK status register (dclkstat) until it changes to 1, which indicates that all the DCLKs have been sent.

  16. Write a 1 to the dcntdone bit of the DCLK status register to clear the completed status flag.

  17. Read the mode bit of the stat register to wait for the FPGA to enter user mode.

  18. Set the en bit of the ctrl register to 0 to allow the external pins to drive the configuration input signals.

How has this been tested?

It is specific low level code for de10nano board. It has the single functionality of programming the FPGA chip and nothing else.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature / Optimization (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.

@antonionevado antonionevado added the enhancement New feature or request label Jan 10, 2020
@antonionevado antonionevado self-assigned this Jan 10, 2020
@blueoil-butler blueoil-butler bot added the CI: auto-run Run CI automatically label Jan 10, 2020
@bo-code-review-bot
Copy link

This PR needs Approvals as follows.

  • Ownership Approval for / from iizukak, tkng, ruimashita
  • Readability Approval for C++ from tkng, tsawada

Please choose reviewers and requet reviews!

Click to see how to approve each reviews

You can approve this PR by triggered comments as follows.

  • Approve all reviews requested to you (readability and ownership) and LGTM review
    Approval, LGTM

  • Approve all ownership reviews
    Ownership Approval or OA

  • Approve all readability reviews
    Readability Approval or RA

  • Approve specified review targets

    • Example of Ownership Reviewer of /: Ownership Approval for / or OA for /
    • Example of Readability Reviewer of Python: Readability Approval for Python or RA for Python
  • Approve LGTM review
    LGTM

See all trigger comments

Please replace [Target] to review target

  • Ownership Approval
    • Ownership Approval for [Target]
    • OA for [Target]
    • Ownership Approval
    • OA
    • Approval
  • Readability Approval
    • Readability Approval for [Target]
    • RA for [Target]
    • [Target] Readability Approval
    • [Target] RA
    • Readability Approval
    • RA
    • Approval
  • LGTM
    • LGTM
    • lgtm

@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

1 similar comment
@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
CI: auto-run Run CI automatically enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants