Spi Serial Flash Programmer Schematic Design
This is a very simple Arduino sketch and Python 3 client to program SPI flash chips. It's probably not very nice or tolerant, but it does at least have error correction and fast verification.

The requirements are pySerial and clint. Both modules can be installed with pip:
Usage
Serial NOR Flash Our serial NOR solutions are purpose-built to meet the needs of consumer electronics, industrial, wired communications, and computing applications. Our industry-standard devices are easy to design in, saving valuable development time while ensuring compatibility with existing and future designs. This four-signal interface to configure a Xilinx FPGA from an SPI serial flash, the FPGA is the master device and the SPI serial flash is the slave device. Application Note: Spartan-3E and Virtex-5 FPGAs XAPP951 (v1.3) September 23, 2010 Configuring Xilinx FPGAs with SPI Serial Flash Author: Stephanie Tapp.
- Program the Arduino with sketch
- Connect the SPI flash chip as described
- Run python client on PC to talk to programmer
Connecting a chip
Connect the chip as follows, assuming you have an 3.3V 8-pin SSOP Flash chip.You will need an Arduino running at 3.3V logic. See 3.3V Conversion to convert your Arduino to 3.3V.
Or use one of the following devices running at 3.3V:
| Chip pin | Arduino pin |
| 1 /SS | 10 |
| 2 MISO | 12 |
| 3 /WP | +3.3V |
| 4 GND | GND |
| 5 MOSI | 11 |
| 6 SCK | 13 |
| 7 /HOLD | +3.3V |
| 8 VDD | +3.3V |
Commands
Troubleshooting
- Try reducing the serial speed from 115200 to 57600. You'll have to edit the value in both the .ino and the .py.
- Play with the SPCR setting in the .ino according to the datasheet.
License [CC0][http://creativecommons.org/publicdomain/zero/1.0/]
To the extent possible under law, the authors below have waived all copyright and related or neighboring rights to spi-flash-programmer.
- Leonardo Goncalves
- Nicholas FitzRoy-Dale, United Kingdom
- Tobias Faller, Germany
I used this to write a 16MB flash chip for the wr703n router running OpenWRT. Recent versions of OpenWRT detect the larger Flash and automatically use it, so you don't need to do any patching. U-Boot still thinks the chip is 4MB large, but Linux doesn't seem to care. So all you need to do is copy the image and write the ART (wireless firmware) partition to the right spot, which is right at the end of Flash.
I guess if you do a system upgrade which puts the kernel image somewhere after the first 4MB you might be in trouble, so upgrade u-boot before doing that.
Connect the original chip and dump it:
python3 spi_flash_programmer_client.py -s 4096 -f wr703n.orig.bin read
Connect the new chip and write it:
python3 spi_flash_programmer_client.py -s 4096 -f wr703n.orig.bin write
Verify the write.
python3 spi_flash_programmer_client.py -s 4096 -f wr703n.orig.bin verify
Write the ART partition to the final 64k of the chip (the magic numbers are 16M-64K and 4M-64K respectively).
python3 spi_flash_programmer_client.py -f wr703n.orig.bin --flash-offset 16711680 --file-offset 4128768 write
Verify the ART partition.
python3 spi_flash_programmer_client.py -f wr703n.orig.bin --flash-offset 16711680 --file-offset 4128768 verify
Solder the new chip in.
If you try this, let me know!
This example uses the OLIMEXINO-32U4 to flash a Olimex iCE40HX8K-EVB. The steps should also work with a iCE40HX1K-EVB.
The board is connected using the UEXT connector.
Spi Flash Programmer
$begingroup$Device have Serial NOR Flash chip MX25L6406E located on the rear of the PCB (SO-8/SOIC-8 Package). Is it possible to program chip without desoldering it? (In-system programming). As I know, it depends mainly on specific design.
closed as unclear what you're asking by Marcus Müller, winny, Dmitry Grigoryev, Nick Alexeev♦Aug 14 '18 at 23:49
Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.
2 Answers
$begingroup$So you're asking how to determine whether a chip can be in-system programmed.
There's a lot of factors to that, but the ones I can think of are:
- selective powering: Can you power the memory IC without starting the rest of the system? If giving power to that IC means you power the microcontroller it's connected to, and you have no way of stopping that microcontroller from using the SPI lines you want to connect to to talk to the memory chip, then this can't work. In essence, you'll have a hard time if the memory IC and the microcontroller run from the same power supply, and the microcontroller doesn't have an externally accessible reset pin. Also, if the same power supply powers other components, what will happen?
- Side effects of the programming itself: are there other devices on the SPI bus? When the microcontroller is powered of, will these have a chip select line that is deasserted, i.e. will they know that they're not 'meant' to be talked to?
- Pin direction problems: Now, your MCU is powered off or in reset, but you power your memory and do some communication on the SPI bus. In which state are the pins of the MCU that connect to the memory when powered off/ in reset? Are they shorted to ground, pulled up to VCC? Is it OK to apply e.g. 3.3V to pins when the MCU is powered off, or will it be damaged?
In-system programming a chip without knowledge of the rest of the design is fraud with dangers.
First the device needs to have power. If the board works with it's own supply you are lucky.
If not you you have to supply the voltage. The power pin (lets assume 3V3) will be connected to the power of all other 3V3 pins. Thus you have to provide enough current to drive all the 3V3 logic. This is your first chance to blow up the board as the 3V3 supply might not like it to have power driven INTO its output. Also there may be other chips on the board which run of a different supply. Only partial powering the board may damage them.
Lets's assume you have safely supplied power. Next you have to drive the SPI signals: CS, SCLK and MOSI. But these pins will already be connected to other chips on the board*. Here is your second chance to blow up the board. If you drive them externally, you have two outputs working against each other. To get a good quality signal, you probably have to drive the signals harder then the existing chips. Therefore you are likely to damage the existing signal driver chips.
*The existing in-system driver software may be able to disconnect (tri-state) the normal driver chips if the device is to be programmed. However the board may be designed for the SPI chip to be programmed before it is soldered soldered. IN which case the board will not be designed for in-system prorgamming.
OldfartOldfart