How to run the Acorn UART and GPIO loopback on a Raspberry Pi 5¶
You have an Acorn wired to a Raspberry Pi 5 and want to see that the serial pair of P2 carries in both directions.
The loopback design (pmod-loopback) returns on K2 the inverse of what it sees on J2, and nothing else: GPIO14 to J2, inverted, K2, GPIO15. It does not touch J5 or H5; the boot check tests those two wires with p2-gpio. On a card that runs the fpgas.online design, the boot check tests the same wires itself (p2-uart, p2-serial). The tests are on Acorn tests and their wires on a Raspberry Pi 5.
On a Compute Blade this cannot be done by hand in one boot. The load needs the header’s serial port off, and the test needs it on (why). The check tests the pair there with p2-uart and p2-serial.
This procedure is waiting for its run: test-designs issue #230.
What you need¶
An Acorn wired as on Acorn wiring on a Raspberry Pi 5, in the M.2 HAT slot, where the card is at
0001:01:00.0.The fpgas.online images in the card’s flash, so that it comes back after step 7. They go in as on How to install the fpgas.online images on an Acorn.
The kernel console off the FPGA’s serial port, and SysRq disabled: A Raspberry Pi 5’s settings for an Acorn. Check
cat /proc/cmdlinebefore the load.openFPGALoaderwith thelibgpiodcable, and the pin order10:9:11:8for--pins.The loopback bitstream in
LOOPBACK; for a CLE-215+ and the release’s file the name ispmod-loopback_acorn-cle-215p_vivado-vivado_sqrl_acorn.bit:The loopback and pin-ID designs are in no package. CI builds them and attaches them to the releases of fpgas.online-test-designs as
pmod-loopback_acorn-<variant>_vivado-vivado_sqrl_acorn.bitandpmod-pin-id_acorn-<variant>_vivado-vivado_sqrl_acorn.bit, for example in the releasevivado-bitstreams-v0.0-496-gf162f60. Build the pin-ID design frommain, not from that release. Copy the file to the host and put its name inLOOPBACKorPINID.A card that runs the fpgas.online design needs none of these files for the wiring check: on a Compute Blade, on a Raspberry Pi 5.
<variant>iscle-215p,cle-215orcle-101.
Steps¶
On the Pi, stop and mask the getty on the FPGA’s serial port; the port is free for the test.
$ sudo systemctl stop serial-getty@ttyAMA0 $ sudo systemctl mask serial-getty@ttyAMA0
On the Pi, detach the card’s PCIe endpoint, as before every JTAG load (why); the card no longer shows in
lspci.$ echo 1 | sudo tee /sys/bus/pci/devices/0001:01:00.0/remove
On the Pi, make sure
gpiochip0is the header’s GPIO chip, because thelibgpiodcable opensgpiochip0.The header’s GPIO chip is the one
gpiodetectlists aspinctrl-rp1; its number varies from 11 to 15. Where the Acorn packages are installed, the boot check makesgpiochip0a link to it whengpiochip0is missing. The link is gone at each reboot. Check which chipgpiochip0is:$ sudo gpiodetect $ ls -l /dev/gpiochip0
Skip the link if
ls -lshows-> gpiochipNwith N the number ofpinctrl-rp1, orgpiodetectlistsgpiochip0itself aspinctrl-rp1. If/dev/gpiochip0is missing or another chip, link it. The line below is forgpiochip15: put your chip’s number in place of 15.$ sudo ln -sfn /dev/gpiochip15 /dev/gpiochip0
On the Pi, load the loopback bitstream into SRAM; the load’s last line ends with
done 1.$ openFPGALoader --cable libgpiod --pins 10:9:11:8 $LOOPBACK
On the Pi, set the port and read it for three seconds without sending anything. Keep what it prints.
$ stty -F /dev/ttyAMA0 115200 raw -echo $ timeout 3 cat /dev/ttyAMA0 | od -An -tx1
On the Pi, read again while a word is sent. The loopback inverts each bit, so the bytes are not the bytes sent.
$ (sleep 1; echo test > /dev/ttyAMA0) & $ timeout 3 cat /dev/ttyAMA0 | od -An -tx1
At the switch, PoE-cycle the host’s port and wait more than 90 s. The card loads its flash images again, and
lspci -nn -s 0001:01:00.0lists it. A netbooted Pi’s root is thrown away at every reboot (Netboot and the NFS root). On a netbooted Pi, step 1’s mask, thegpiochip0link and the port settings go with it. On a Pi that boots from its own card, runsudo systemctl unmask serial-getty@ttyAMA0first.
Check¶
Run step 6 twice. When J2 and K2 both carry, step 6 prints more bytes than step 5 each time. That is the expected result; its run will show it (test-designs issue #230). Step 5 alone shows at most that K2 is driven: the design holds the idle line low, which the Pi reads as a break. The inverted bytes may arrive as framing errors, so the check counts bytes and cannot compare them; a loopback that can is test-designs issue #297.
If it fails¶
Two items below send you to the pin-ID design. Read its hazard first:
Warning
Never drive a Pi GPIO against an FPGA output. With the pin-ID design loaded, every P2 ball is an FPGA output, J2 included. Setting GPIO14 to a4 (TXD0) or op while pin-ID runs is then output against output on the J2 wire, and it crashes the Pi. Probe with pinctrl set 14 ip pn (input, no pull). Restore pinctrl set 14 a4 only once a design that treats J2 as an input is loaded.
Step 5 and step 6 both print nothing: K2 or GPIO15 is not connected, serial-getty holds the port, or the baud is wrong. Check that step 1 ran and step 5 set 115200. Then run pin ID and check that GPIO15 reads
K2.Step 6 prints no more bytes than step 5: nothing reached J2. J2 or GPIO14 is not connected, or K2 and J2 are not crossed over. Run pin ID and check that GPIO14 reads
J2, then give GPIO14 back withpinctrl set 14 a4and run again from step 4.After any failure: step 7’s PoE cycle puts the card and the Pi back.
The Pi reboots when the design loads: the kernel console is on the FPGA’s serial port; fix it as in the Pi’s settings.