Shrike-fi FPGA test
===================

This is the test I used to compare two Shrike-fi boards. You can run it on
your own board to check that my code is doing the right thing.

It does not need the shrike module. It loads the bitstream into the FPGA
using plain MicroPython only. I did it this way so the same code runs on a
board with the normal MicroPython and on a board with the SHRIKE_FI build.


Videos
------

  fpga_config_raw_test_video.mp4   the main test running on both boards
  spi_check_test_video.mp4         the SPI test running on both boards

In the videos the good board and the bad board are side by side, running
the same script. On the good board the FPGA LED blinks. On the bad board it
stays dark the whole time.


Scripts and files
-----------------

  fpga_config_raw.py      main test, loads led_blink.bin into the FPGA
  led_blink.bin           unchanged copy of test/bitstreams/v1_4/led_blink.bin
                          sha256 1405c6cfde1e129ca6cbfaac0a36af67
                                 affee7450118077a6b8d7536749066e6
                          size 46408 bytes

  spi_check.py            second test, talks to the GPIO extender over SPI
  gpio_extender_14pin.bin unchanged copy from
                          examples/gpio_extender_14pin/bitstream/
                          sha256 84bb52c1f2c3b78c7801c1888bf138b9
                                 81538f68fdfcf8c829c45020b8aec261
                          size 46408 bytes
  gpio_extender_14pin.py  the driver from the repo, with the pin numbers
                          changed for Shrike-fi (see note at the bottom)


How to run the main test
------------------------

Copy the files to the board, then run the script:

  mpremote connect <PORT> cp led_blink.bin :led_blink.bin
  mpremote connect <PORT> run fpga_config_raw.py

Watch the board while it runs. It does two things:

  1. Blinks the MCU LED (GPIO21) five times. This is only a check that the
     board is alive and that you are looking at the right board.
  2. Loads led_blink.bin into the FPGA, then waits 15 seconds. The FPGA LED
     should blink about once per second.

On a good board both LEDs blink. On my bad board the MCU LED blinks but the
FPGA LED stays dark the whole time.


How to run the SPI test
-----------------------

  mpremote connect <PORT> cp gpio_extender_14pin.bin :gpio_extender_14pin.bin
  mpremote connect <PORT> cp gpio_extender_14pin.py :gpio_extender_14pin.py
  mpremote connect <PORT> run spi_check.py

This writes a few patterns to the FPGA and reads them back. On a good board
the values that come back change with what was written and most bits match.
On my bad board every read returns 0x3FFF no matter what is written.

Note: this test loads the GPIO extender bitstream, which does not use the
FPGA LED. So after running it the FPGA LED stays dark even on a good board.
That is normal. Run fpga_config_raw.py again if you want the LED blinking.


Pin numbers
-----------

I took these from the shrike module inside your own SHRIKE_FI firmware:

  EN    GPIO9
  PWR   GPIO8
  SPI   id 2, sck GPIO12, mosi GPIO11, miso GPIO13
  SS    GPIO10

They match the table in docs/shrike_pinouts.md.

Note: gpio_extender_14pin.py in the repo has RP2040 pin numbers in it
(SPI id 0, sck 2, mosi 3, miso 0, cs 1). Those pins are not the FPGA bus on
Shrike-fi, so I changed them to the ones above. The change is only in the
__init__ method. The main test does not use this file at all, because
led_blink does not use SPI.
