From a user's perspective, FPGA configuration state transitions with Apollo currently look like:
(Transient states in blue automatically progress to a subsequent state.)
In "offline" mode the FPGA is in initialization triggered with the ECP5's PROGRAMN pin.
In "unconfigured" mode the FPGA is in initialization triggered by JTAG.
You can't avoid starting up from flash and going into user mode.
You can't program flash without going to offline or unconfigured mode first.
You can't configure from JTAG in offline mode.
You can't go to offline mode without subsequently configuring from flash.
You can't reconfigure from unconfigured mode (so the RESET button has no effect on the FPGA).
Configuration errors (e.g. empty flash) result in a state equivalent to unconfigured mode.
(I'm using "offline" and "unconfigured" as names for two separate states because that is what they are called in the code, more or less. Really the FPGA is both offline and unconfigured in both of those states, and the ECP5 documentation uses "offline mode" to refer to even more of the above states.)
Most of the drawbacks of the state machine are due to limitations of the offline and unconfigured modes. It would be desirable to have a single offline mode from which any state transition can be made. After some experimentation I determined that there is no way to support JTAG configuration from offline mode; once the PROGRAMN pin is pulled low, the only way to get back to user mode is through configuration from flash. It is possible, however, to support all state transitions from unconfigured mode which is invoked by JTAG.
This PR consolidates to a single "offline" mode (which is most similar to "unconfigured" mode above). The new state machine looks like:
In "offline" mode the FPGA is in initialization triggered by JTAG.
The PROGRAM button (on Cynthion only) allows the user to force offline mode.
All user actions have a result that is invariant to the previous state.
Configuration errors result in a state equivalent to offline mode.
Cynthion <r1.3.0 always configures from flash at power-on due to hardware/bootloader limitations.
Most of the complexity in the PR is in firmware which did not previously do JTAG things other than passing through JTAG operations from the host. In my tests it increased the size of the firmware binary by 172 bytes with GCC 10.3.
From a user's perspective, FPGA configuration state transitions with Apollo currently look like:
(Transient states in blue automatically progress to a subsequent state.)
PROGRAMN
pin.(I'm using "offline" and "unconfigured" as names for two separate states because that is what they are called in the code, more or less. Really the FPGA is both offline and unconfigured in both of those states, and the ECP5 documentation uses "offline mode" to refer to even more of the above states.)
Most of the drawbacks of the state machine are due to limitations of the offline and unconfigured modes. It would be desirable to have a single offline mode from which any state transition can be made. After some experimentation I determined that there is no way to support JTAG configuration from offline mode; once the
PROGRAMN
pin is pulled low, the only way to get back to user mode is through configuration from flash. It is possible, however, to support all state transitions from unconfigured mode which is invoked by JTAG.This PR consolidates to a single "offline" mode (which is most similar to "unconfigured" mode above). The new state machine looks like:
Most of the complexity in the PR is in firmware which did not previously do JTAG things other than passing through JTAG operations from the host. In my tests it increased the size of the firmware binary by 172 bytes with GCC 10.3.