greatscottgadgets / apollo

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

JTAG failure on older Cynthion boards #45

Closed mossmann closed 5 months ago

mossmann commented 5 months ago

Seen so far on r0.3 and r0.4 hardware:

(venv) mossmann@costard:~/src/cynthion/cynthion/python$ ~/src/luna/examples/blinky/blinky.py 
INFO    | __init__    | Building and uploading gateware to attached Cynthion r0.3...
Traceback (most recent call last):
  File "/home/mossmann/src/luna/examples/blinky/blinky.py", line 41, in <module>
    top_level_cli(Blinky)
  File "/home/mossmann/src/cynthion/cynthion/python/venv/lib/python3.11/site-packages/luna/__init__.py", line 113, in top_level_cli
    products = platform.build(fragment,
               ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/mossmann/src/cynthion/cynthion/python/venv/lib/python3.11/site-packages/amaranth/build/plat.py", line 113, in build
    self.toolchain_program(products, name, **(program_opts or {}))
  File "/home/mossmann/src/cynthion/cynthion/python/venv/lib/python3.11/site-packages/cynthion/gateware/platform/core.py", line 79, in toolchain_program
    programmer.configure(bitstream)
  File "/home/mossmann/src/cynthion/cynthion/python/venv/lib/python3.11/site-packages/apollo_fpga/ecp5.py", line 461, in configure
    self._validate_status(status, expect_done=True)
  File "/home/mossmann/src/cynthion/cynthion/python/venv/lib/python3.11/site-packages/apollo_fpga/ecp5.py", line 334, in _validate_status
    error_handler("Failed to execute last command!{}".format(error_text))
  File "/home/mossmann/src/cynthion/cynthion/python/venv/lib/python3.11/site-packages/apollo_fpga/ecp5.py", line 318, in raise_error
    raise IOError(msg)
OSError: Failed to execute last command! (bitstream provides data past the device's SRAM array / ffffffff)

See https://github.com/greatscottgadgets/luna/pull/241 for how we first encountered this.

I was unable to reproduce this problem with older Apollo firmware (version unknown, but it was using 4 KiB bootloader), but immediately reproduced it upon updating Apollo firmware to 171556d.

mossmann commented 5 months ago

git bisect led me to 1db534c as the first bad commit.

mossmann commented 5 months ago

This bug happened because I started assuming in 1db534c that the button could be used on all platforms, but we never actually had the button working on Cynthion revisions r0.3 through r0.5.