Olimex Support Forum

Others => FPGA => Topic started by: cdan on April 03, 2026, 01:04:38 PM

Title: SPI Programming Sequence for iCE40HX8K-EVB
Post by: cdan on April 03, 2026, 01:04:38 PM
I am using an external programmer (pico-serprog) to program the iCE40HX8K via SPI. Programming only works if C_RESET is pulled LOW before powering on the board. If C_RESET is pulled LOW after power is already applied, SPI communication fails.

Can you confirm: When C_RESET is pulled LOW while the board is already powered on, do the SDI, SDO, and SCK pins on the FPGA chip enter high-impedance (Hi-Z) state? Is there a specific reset/power-on sequence required for the iCE40 to enter SPI programming mode?
Title: Re: SPI Programming Sequence for iCE40HX8K-EVB
Post by: LubOlimex on April 07, 2026, 08:14:26 AM
Yes, this is expected way to reliably be able to program via SPI. This is mentioned in our guides, for example when using OLIMEXINO-32U4 to re-program the board via Arduino IDE:

https://github.com/OLIMEX/iCE40HX1K-EVB/tree/master/programmer/olimexino-32u4%20firmware

Notice this part in the README.md:

"BUT+RST to start USB to Serial Hold BUT down until last restart, i.e. for a rather long time. Think of BUT as a shift-button to RST, but that must be held down a long time after RST has been released.

This is useful when developing FPGA-projects that use serial communication with the computer that you used to program it with. You don't have to buy an extra USB to serial converter or use an extra USB cable or port."
Title: Re: SPI Programming Sequence for iCE40HX8K-EVB
Post by: olin on April 15, 2026, 07:25:59 PM
Hi cdan,

can you clarify what you try to do? Is it:
a) program the Flash IC on iCE40HX8K via SPI?
or
b) execute the FPGA bitstream on iCE40HX8K via SPI?

These are 2 different things.
If you do option b) you need to swap MOSI and MISO lines on your MCU.
Also, to execute bitstream you need to keep the SPI_CS low BEFORE you raise
the C_RESET pin High (during FPGA reset), or else the FPGA will try to use Flash IC to read the bitstream from.

Swapping MISO and MOSI lines is easy on some MCUs (like ESP32) because it is software defined. On others MCUs that is not so simple, and Olimex designers though about it, and added a hardware option on their EVB board to swap MISO / MOSI lines. See note 2 on the schematic, it says:
"2. When iCE40HX8K Direct SRAM programming is used, unmount R9 and populate R19!"
That seems like a good option, but it is quite hard for a hobbyist with intermediate soldering skills to solder 0201 resistor in a tiny space. The 2 resistors (R9/R19) should have been designed as 0805 (or at least 0603) for that option to be useful.