How to recover an Acorn with a bad image

You have an Acorn on a Raspberry Pi 5 whose golden image is bad, and want to write a good one back over JTAG.

The images and the flash layout are on the fpgas.online Acorn design. A bad operational image at 0x400000 needs nothing from you. The watchdog fires, the FPGA reloads from 0x0, the golden image brings PCIe up, and the host rewrites the operational slot. A Compute Blade is recovered only once the site operator has taken it out of service. There, use --pins 2:3:4:14 and the card’s address from lspci (how to run JTAG on a Compute Blade).

This procedure is waiting for its run: test-designs issue #228.

Danger

Never write flash address 0x0 during normal operation. The golden image there is the recovery mechanism. Overwrite it badly and the only way back is the SRAM bootstrap below. On a board whose JTAG does not answer, there is no way back at all. fpgas-acorn-flash refuses 0x0 without --i-know-this-writes-golden; litepcie_util does not check. Use 0x400000 for operational updates.

What you need

  • JTAG wired and answering --detect on the Pi (step 1). A card whose JTAG does not answer cannot be rescued, and its golden slot must not be written. The cards known not to answer: test-designs issue #209 and test-designs issue #214.

  • The JTAG wiring left connected on every deployed board. Without JTAG a bad golden image bricks the board until JTAG is reconnected.

  • openFPGALoader with the libgpiod cable, and the flash tool fpgas-acorn-flash from How to install the Acorn packages.

  • golden.bit, the golden build’s .bit (acorn_pcie_soc.py --variant <v> --golden --build, a Vivado build); the packages carry only the operational .bit. In the design’s release it is acorn-cle-215p-golden-sqrl_acorn.bit for a CLE-215+.

  • sqrl_acorn_fallback.bin and sqrl_acorn_operational.bin, the golden and operational flash images.

  • A copy of every file on the Pi after each reboot, because files under /home/pi do not survive one.

  • Power to the board until step 4 completes: the SRAM-loaded design is volatile.

Steps

  1. On the Pi, make sure gpiochip0 is the header’s GPIO chip, then read the IDCODE. It is 0x3636093 on a CLE-215+ (XC7A200T); a CLE-101 or LiteFury carries an XC7A100T and reports 0x3631093.

    The header’s GPIO chip is the one gpiodetect lists as pinctrl-rp1; its number varies from 11 to 15. Where the Acorn packages are installed, the boot check makes gpiochip0 a link to it when gpiochip0 is missing. The link is gone at each reboot. Check which chip gpiochip0 is:

    $ sudo gpiodetect
    $ ls -l /dev/gpiochip0
    

    Skip the link if ls -l shows -> gpiochipN with N the number of pinctrl-rp1, or gpiodetect lists gpiochip0 itself as pinctrl-rp1. If /dev/gpiochip0 is missing or another chip, link it. The line below is for gpiochip15: put your chip’s number in place of 15.

    $ sudo ln -sfn /dev/gpiochip15 /dev/gpiochip0
    
    $ openFPGALoader --cable libgpiod --pins 10:9:11:8 --detect
    
  2. On the Pi, detach the endpoint and load golden.bit into SRAM. With a corrupt golden image nothing is enumerated, so the detach reports No such file or directory: carry on.

    $ echo 1 | sudo tee /sys/bus/pci/devices/0001:01:00.0/remove
    
    $ openFPGALoader --cable libgpiod --pins 10:9:11:8 golden.bit
    
  3. On the Pi, bring the card back and list it; it enumerates as the design. If step 2’s detach found the card, rescan:

    $ echo 1 | sudo tee /sys/bus/pci/rescan
    $ lspci -nn -s 0001:01:00.0
    

    If the detach reported No such file or directory, the PCIe host bridge removed itself at boot, with no link to the card. Bind it again, with no unbind first. This command waits for its run on a Pi 5 (test-designs issue #228):

    $ echo 1000110000.pcie | sudo tee /sys/bus/platform/drivers/brcm-pcie/bind
    $ lspci -nn -s 0001:01:00.0
    
  4. On the Pi, write the golden image to 0x0, then the operational one to 0x400000; both writes complete.

    $ sudo fpgas-acorn-flash write sqrl_acorn_fallback.bin 0x0 --idcode 0x3636093 --i-know-this-writes-golden
    
    $ sudo fpgas-acorn-flash write sqrl_acorn_operational.bin 0x400000 --idcode 0x3636093
    
  5. At the switch, PoE-cycle the host’s port; the golden image boots from flash and chain-loads the operational one.

Check

After step 5 lspci -nn -s 0001:01:00.0 shows the design’s ID again, without any JTAG load. Step 3 shows the same line before the flash is written.

Memory controller [0580]: Xilinx Corporation Device [10ee:7021]

If it fails

  • Step 1 lists no idcode line, or prints nothing: this board cannot be rescued over JTAG; stop and repair the JTAG wiring.

  • Step 3 shows the SQRL ID 1e24:021f, or no device: the JTAG load did not take; go back to step 2 rather than writing flash.

  • Open file … FAIL after a reboot: the bitstream is gone, because /home/pi is a memory overlay (overlayroot=tmpfs); copy it again before each attempt.

  • The board lost power before step 4 completed: the flash still holds the corrupt golden image; start again from step 2.

  • The bind in step 3 reports No such device: the card still has no link; go back to step 2.

  • The rescan in step 3 finds nothing on a Pi that booted with the card: re-probe the slot’s root complex. The re-probe commands are under “If it fails” on How to check an Acorn’s PCIe link by hand on a Raspberry Pi 5.

Next