When LEDs "flicker", it suggests a power problem to me.
Ensure that your board is getting clean stable power, and not being parasitically powered through the programmer's data lines or similar.
I'm guessing that the problem is that the SN-pin is dedicated to the hard macro (EFB) for the Configuration mode. For User mode you should use another pin, see the definition of spi_scsn, that can be placed on whichever user I/O you want. The pin on the generated EFB-block is probably the chip select for the User mode. Placing it on the SN pin will cause a no-fit since this pin is reserves for the ufm_sn (or just SN) function. The SN pin will be automatically used when enabling SLAVE_SPI_PORT.
Hope that helps, if you found another solution please let me know as we are doing more or less the same thing soon.
Response from Lattice on pinning:
1. Spi_clk --> Assign to "MCLK/CCLK" pin on Bank-2.
2. Spi_miso --> Assign to "SO/SPISO" pin on Bank-2.
3. Spi_mosi --> Assign to "SI/SISPI" pin on Bank-2.
4. Spi_scsn --> Assign to any GPIO (No bank preference).
5. Ufm_sn --> Assign to "SN" pin on Bank-2.
About EFB settings:
If you have instantiated "EFB" with SPI (either Master or Slave) enabled in your design then, the "SLAVE_SPI_PORT" attribute in the Diamond's "Global Preferences" automatically gets enabled after the Synthesis process. So, you need not have to set it exclusively, it will be taken care by the tool automatically.
Next is the IPExpress settings. In the IPExpress, along with enabling the " SPI" option, enable the "User Flash Memory" option as well. Then, in the "SPI" tab, select the
SPI Mode as "Slave", this is user mode SPI selection option..
Best Answer
The Lattice Diamond 2.1 help for bitgen on command line says this is only available for LatticeECP2S and LatticeXP2 devices. Look for bitgen -e -k and -s options. Maybe running these options on MachXO2 device works...