Take the 2-minute tour ×
Electrical Engineering Stack Exchange is a question and answer site for electronics and electrical engineering professionals, students, and enthusiasts. It's 100% free, no registration required.

I'm working on an audio application where instead of storing audio data on an SD card (Waveshield on Arduino) I'm storing it on an SPI flash memory IC and rolling my own board with MCU, DAC, and amp.

I am using a Winbond W25Q80BVSSIG.

I'm pretty familiar with programming AVR using the AVRISP mkII or the USBTiny, is writing data to flash done with the same programmer? I haven't been able to find anything when looking for SPI flash memory programmers specifically.

This question is a follow up to this one.

share|improve this question
    
I don't know if there exists a programmer that specifically can do this easily for you, from a PC or something, but if there's a CPLD involved in your circuit, you could configure that to write data to the flash memory. –  deed02392 Dec 13 '12 at 9:17

7 Answers 7

up vote 6 down vote accepted
+50

If you are simply looking for a way to program the Winbond SPI flash with "pre-loaded" data that your microcontroller would read for use when it is running then what you will want to look into is a programmer that can do in-circuit programming of the SPI Flash chip. This also known as in-system-programming (ISP).

One choice is the programmer from DediProg. This USB connected device can program in circuit if you design your board correctly. They even sell an adapter clip that can attach into the SOW-16 package without having to design in a separate programming header on your board. DediProg has application information bulletins available to help with correct design for in circuit use. The main strategy for the design is to find a simple way to isolate the SPI interface drivers in your MCU system so that they do not interfere with the drivers in the SPI programming pod. The simplest way to do this is to put series resistors in the MCU driven lines between the MCU and the SPI Flash. The programmer would connect on the SPI flash side of the series resistors. Alternate methods could include adding a MUX or analog switches in the driven interface lines. An even more clever scheme is to add a "programming enable" input to the MCU that makes the software disconnect all the SPI I/Os from the SPI Flash chip (i.e. make all those GPIOs as inputs).

enter image description here

A second choice to also consider is the USB programer from ASIX. The Presto is able to do various types of SPI and I2C devices including SPI Flash devices. I have one of these devices specifically for programming Atmel MCUs and various types of SPI Flash devices. It is a more cost effective solution than the above unit but not quite as flexible. Their more expensive device called the Forte is able to do more things because it has more target interface pins.

enter image description here

Sometimes it can be beneficial to be able to connect a programmmer to a target board without having to add a programming header. One nice solution for this is to place a small set of pads in a special footprint defined by a company called TagConnect. They manufacture and sell a series of quick connect programming cables that have pogo pins that engage the special footprint on the board. There are 6-pin, 10-pin and 14-pin versions of the cable available to suit a range of applications. Cost of the cables are very reasonable.

enter image description here

share|improve this answer
    
This is very helpful. I am planning on programming the flash memory before soldering it to the final PCB. So far I've done this for MCU's and its worked well. I am undecided whether providing ISP pins on the PCB is a good idea or not, since they are not supposed to be reprogrammed once completed. –  JYelton Jan 14 '13 at 17:12
1  
@JYelton - In my experience it is a good idea to plan for ISP for several reasons. ECO's (Engineering Change Orders) are a fact of life in the product cycle. Someone or something will demand a change in the Flash content once you get into production. Flash chips are sometimes susceptible to unexpected noise disturbance in the circuit and end up having their content compromised. Another reason to provide for ISP. –  Michael Karas Jan 14 '13 at 17:37
    
Is there a "standard" header that is compatible with most of these programmers at least via bundled adapter cables ? I have seen 2x4 and 2x5 pin headers with a bunch of different pinouts Also see flashrom.org/Supported_hardware –  kert Mar 23 at 20:03

I bet you could do it with a Bus Pirate without going through your MCU... that lets you perform somewhat arbitrary serial interactions directly to a chip using SPI, I2C, or UART communication. It might take a bit of work to "script" it, but it would let you do the job probably.

I've also seen specialized tools for loading EEPROM's over I2C directly, but not flash and not SPI specifically.

share|improve this answer
    
I'm starting to wonder whether my selection of SPI flash is a good one, given how (apparently) obscure the methods are to write to the blasted things. –  JYelton Dec 13 '12 at 18:09
1  
That would take some serious scripting, but good idea anyhow. A little to complicated for my taste. Maybe you should consider an SD-card? Then you just need to care about the reading, writing to it with a computer –  Wilhelmsen Dec 13 '12 at 20:39
    
The current prototype uses an Arduino and Waveshield (which has an SD card reader). I want to get away from the SD card because I believe the cost will be less (no reader and card) and also more tamper proof. –  JYelton Dec 19 '12 at 8:34

I have never heard of any other tools talking SPI directly to such a chip, and I think it is impossible since "all" chips require different calls for different operations.

The chip needs SPI calls for write, read, change sector, data size etc. Under 7.2 Instructions chapter in the datasheet you can see all the SPI commands you can send to it. Hence, since all external flash memories does not have the same instruction set, you need to write a customized application for this one.

EDIT: Being a follow up, I would really recommend one of Atmels own SPI flash memories, since most of them already has written open available code for them. Looking at this post from AVRFreaks will provide you with code for some of Atmels AT45xxxx serial flash chips.

share|improve this answer
    
If I understand you correctly, I should write a program for my MCU that then writes the data to the flash memory? The problem is the MCU has less memory than the external flash, so I am somewhat at a loss. –  JYelton Dec 13 '12 at 15:38
    
Yes. You can send data from your computers serial line with UART which you write to the flash. Also, you could write several programs for the MCU, programming the flash some blocks at a time. It may be a little time consuming but it works since the external flash won't get erased as long as you keep track of changing sectors correctly –  Wilhelmsen Dec 13 '12 at 16:52
    
This is the correct answer. So you'll need a program on your PC to download chunks to the MCU which then writes them to flash. It helps if there is error checking and you don't have to write a new program on the PC; so I suggest you find some code for XMODEM or similar. –  pjc50 Dec 13 '12 at 16:54
    
@pjc50 ... not so fast on declaring the 'correct answer' :) –  vicatcu Dec 13 '12 at 17:41
    
Actually many programmers can program flash memories; and one of the common programming schemes used with the atmel micros is pretty close to SPI to start with. –  Chris Stratton Dec 14 '12 at 18:28

I purchased a "FlashCAT" programmer from Embedded Computers for about $30 US. It was surprisingly easy to connect to the PC via USB and write files to the Winbond flash memory. The methods and programmers in other answers are probably just as good, some more expensive or DIY, but this is a cheap and simple way that fits what I was seeking.

Here's a picture of the setup:

Programming with FlashCAT

The FlashCAT programmer is at left, connected to USB. It's running the SPI programming firmware (as opposed to JTAG) and supplying power to the flash memory. The supplied power is selectable (3.3V or 5V) with a jumper.

I have a SOIC to DIP socket on the breadboard to make it easy to program multiple chips. (You can see another flash memory IC sitting on the breadboard as well.)

FlashCAT Software

I haven't yet converted my audio file to the proper binary format, but I wrote a 211KB WAV file to memory just to test, pictured above. I then read it back and saved it as a new file, renamed it to .wav, and it plays correctly on the PC.

The next step will be to properly encode the file, and write the AVR software to read the data and send it through a DAC.

Disclaimer: I am not affiliated with Embedded Computers, I'm just a customer who picked something inexpensive and am sharing information about the experience with the product.

share|improve this answer

You should be able to re-purpose the USBtiny to program a flash memory instead of a target MCU if you are comfortable changing it's programming. However, there may not be enough memory on that to make it versatile enough to program both the MCU and the flash.

Somewhere I have a board from a project which has both an ATTINY and an SPI flash, and uses as an Arduino as a readily available "programmer". A slight modification of the ISP sketch is used to program the MCU with avrdude, then a custom utility sends a sequence which puts the sketch in a special mode and writes blocks of data to the SPI flash.

share|improve this answer

Contrary to some of the statements here, while there are some quirky SPI PROMs out there, there are also some standard instructions used by a large variety of SPI PROMs, including the one you've chosen.

As vicatcu already mentioned, there are good 'bit-bash' cables available that can directly program SPI. Signal-wise, SPI looks a lot like JTAG, so any bit-bash type of cable should be able to be used provide the interface is open source. The internal protocol of the flash is fairly simple.

We use the big brother of the part you're looking at to boot our FPGA boards (256M - 2G). The addressing has an extra byte to handle the storage volume, but otherwise the commands are basically identical.

The type of PROM you're using has to be erased by sector, then programmed by page. Reading is significantly faster than writing (in the case of the ones we use, programming can take half an hour, but reading the whole PROM takes under a second at 108MHz).

Now for the commands: There are way more commands available in these devices than are actually required to program them. You actually only need the following:

  • RDID (read ID) - just to verify the PROM and signalling before you do anything more complex.
  • WREN (write enable) - needed before every write.
  • PP (0x02 - page program) - needed to program a page.
  • SE (0x20 - sector erase) - returns bits in sector to '1'.
  • RDSR (0x05 - read status register) - needed to monitor erase / write cycle.
  • FREAD (0x0B - fast read) - read PROM data and verify write.

If you want more information look at answer notes on SPI programming for Xilinx FPGAs on their website (http://www.xilinx.com). They implement a reduced subset of commands so their FPGAs can boot from these devices.

I designed my own programmer to do this based on what I have available and wrote a programmer script in Python, but you can do the same using a cable. In your case, I would seriously consider doing everything indirectly through the MCU as Michael Karas suggests. You don't need to program the whole PROM from the MCU in one go - you can do it by sector.

share|improve this answer

You mentioned that you have a MCU in your design. What about using the MCU to interface between the PC USB or Serial port and the SPI Flash?

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.