I have now changed my SoC and associated writeFlash C program to read from the uart into SDRAM memory and then program the flash memory from that.
I attempted to use it to write the bitstream of the trail example to address 0 in the flash memory. Reading it back confirms that it looks correct.
However, it does not boot into that bitstream when I power up the device.
Would you expect it to?
Or is there a way to cause the ice40 to boot from the flash memory?
I have put the generated verilog in a repository so that you can run the program without using SpinalHDL.
It needs a 3.3v usb to uart device with the RX pin connected to pin 34, and the TX pin connected to pin 33.
To make and run the bitstream, you do:
git clone https://github.com/lawrie/blackicemx_examples
And in another console:
stty -F /dev/ttyUSB0 raw -echo 115200
When you do the "make prog", you should see "Program Flash memory" on the second console.
You then do:
echo -e -n '\x00\x00\x00\x00' >/dev/ttyUSB0
echo -e -n '\x00\x02\x0f\xbc' >/dev/ttyUSB0
cat chip.bin >/dev/ttyUSB0
That sends address 0, length 135100 and the bitstream to the program, which writes it to the flash memory.
You can also use the program to program other data. like software binaries to other addresses.
Sending a bitstream produces a lot of output as it does a hex dump of the data it receives and a hex dump of a read back from the flash memory.