NEORV32 does not have any dedicated output pin for the SPI flash write protect signal. On boards like the Tang Nano 20K, not driving this pin however means we can’t write to SPI flash. This breaks the upload firmware function in the bootloader, so here’s how to fix this.
In my initial NEORV32 port article, I solved this by compiling a custom bootloader. An alternative seemed to be permanently driving this pin high (which means disable write protect permanently, as it’s a low active signal). However, for some reason this breaks programming using the USB programmer and corrupts the flashed firmware.
As discussed in NEORV32 issue 1195, there is now a better solution with very recent NEORV32 revisions:
The rstn_wdt_o
output of the neorv32_top
module is high when the NEORV32 is executing software, but it is Z
, as long as the core is in reset.
If we connect this signal to the SPI flash write protect pin like this:
-- Write protect (low active) for flash chip
mspi_wp <= '1' when rstn_wdt_o = '1' else '0';
The mspi_wp
pin will be high when the core is executing and low when it is in reset.
This means when the core is running, it will drive the low-active mspi_wp
pin high and writing to SPI flash is possible.
This is a cleaner solution as it does not require a patched bootloader, and it does not need to have a GPIO pin connected for this signal. The solution is implemented in the latest revision in my NEORV32 repo.
When updating the NEORV32 you might notice that the RTL file names changed.
You don’t have to update the file list in the Makefile manually, NEORV32 ships the rtl/file_list_soc.f
for this.