Hi everyone, I’m trying to hook up external QSPI f...
# caravel-board
k
Hi everyone, I’m trying to hook up external QSPI flash (this one, specifically). Has anyone done this before? I’m looking for an example piece of code that enables pass-through mode so that we can transfer data directly to the QSPI flash.
t
Hello Kylee (also @User, who was looking for example code): The Winbond chip is exactly what we're using on the development board, so it is fully compatible (although I think most flash SPI chips use the same command codes). On the Efabless development board, you will need to remove the pull-up resistor R16 from the flash SCK line, because that causes the clock to rise along with CSB when pass-through mode ends, and confuses the SPI flash into thinking another command started. There is also a 0 ohm resistor R11 that needs to be removed, but I caught that issue early and I think Jeff has been removing that before mailing the boards out.
You will probably want to clone the repository https://github.com/efabless/caravel_board . In that repository, find the python script
firmware/util/caravel_hkflash.py
, which will flash a hex file to the SPI flash chip using pass-through mode. The basics of pass-through mode is pretty simple: Just send the command byte
0xc4
to Caravel's housekeeping SPI, and then all data after that is communicating directly with the SPI flash until you raise CSB. Every command done that way has to be prefixed with the
0xc4
command.
This is an example bit of code I wrote that runs a simple test to check the GPIOs under management control. Configuring GPIOs 19 to 37 is straightforward. Configuring GPIOs 0 to 18 requires using the script
slippage.py
that I posted in my conversation above with Weston. I plug in the hex values I want the GPIOs to be set to, and the script gives me back the values I need to set the registers to, to get that result. For management-controlled modes, the SoC checks the local value of the configuration, so I have to rewrite all the configuration values after I do the transfer. For user-controlled modes, that's not necessary. Also, due to the bit slipping, there are some limitations on what modes neighboring GPIOs can be set to; again, the user controlled modes don't have those limitations.
Note that the
caravel_board
repository also has a few (less complicated) examples under the
firmware/
directory. I just created a new directory called
benchtest
, copied the Makefile from the
blink
directory, and changed "blink" to "benchtest" as needed.