greatscottgadgets / apollo

microcontroller-based FPGA / JTAG programmer
BSD 3-Clause "New" or "Revised" License
61 stars 29 forks source link

Use JTAG to invoke offline mode #28

Closed mossmann closed 11 months ago

mossmann commented 11 months ago

From a user's perspective, FPGA configuration state transitions with Apollo currently look like:

image

(Transient states in blue automatically progress to a subsequent state.)

(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:

image

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.

mossmann commented 11 months ago

This also speeds up several apollo commands that were taking five seconds for no good reason.