Serial Flash Memory Programmer Schematic

Posted by admin
$begingroup$

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.

Schematic Memory System

I am using a Winbond W25Q80BVSSIG.

Serial Flash Memory Programmer Schematic For Free. 5/31/2017 0 Comments. Check your AVR datasheet, go to “memory programming” and then “parallel programming” – check the signal names, all signals are described under the DIP4. In doctor memory there is a lot of free space so project may be developed all the time.

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.

Community
  • Oct 1, 2018 - Flash memory programming software. User's Manual. When writing data to the target system by using a serial interface of the host PC.
  • Serial Flash Programming of C2000™ Microcontrollers. The underlying principle for how a flash memory functions is the same. Flash of a C2000 device with Code Composer Studio™ software is actually loading flash algorithms into.
JYeltonJYelton
$endgroup$

7 Answers

$begingroup$

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).

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.

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.

Michael KarasMichael Karas
$endgroup$$begingroup$

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.

chwichwi
$endgroup$$begingroup$

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.

vicatcuvicatcu
$endgroup$$begingroup$

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:

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.)

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.

Memory

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.

JYeltonJYelton
$endgroup$$begingroup$

Kind of late to the discussion, but for anyone reading it after a search....

One thing I did not see mentioned, which is absolutely critical when programming SPI Flash chips is control of the Chip Select (CS_) pin. The Chip Select pin is used to punctuate commands to the SPI Flash. In particular, a transition from CS_ high to CS_ low must immediately precede the issuance of any Write operation op code (WREN, BE, SE, PP). If there is activity between the CS_ transition (i.e. after CS_ has gone low) and before the write op code is transmitted, the write op code will usually be ignored.

Also, what's not commonly explained in SPI Flash datasheets, because it's an inherent part of the SPI protocol, which is also critical, is that for every byte one transmits on the SPI bus, one receives a byte in return. Also, one cannot receive any bytes, unless one transmits a byte.

Typically, the SPI Master that the user is commanding, has a Transmit Buffer, which sends bytes out on the MOSI line of the SPI bus and a Receive Buffer, which receives bytes in from the MISO line of the SPI bus.

In order for any data to appear in the Receive buffer, some data must have been sent out the Transmit Buffer. Similarly, any time one sends data out of the Transmit buffer, data will appear in the Receive Buffer.

If one is not careful about balancing Transmit writes and Receive reads, one will not know what to expect in the Receive buffer. If the Receive buffer overflow, data is usually just spilled and lost.

So, when one sends a read command, which is a one byte op code and three address bytes, one will first receive four bytes of 'garbage' in the SPI Master Receive buffer. These four bytes of garbage correspond to the op code and three address bytes. While those are being transmitted, the Flash does not yet know what to Read, so it just returns four words of garbage.

Atmel Serial Flash Memory

Serial flash memory chips

After those four words of garbage are returned, in order to get anything else in the Receive Buffer, you must Transmit an amount of data equal to the amount that you want to Read. After the op code and address, it doesn't matter what you transmit, it's just filler to push the Read DAta from the SPI Flash to the Receive Buffer.

If you didn't keep careful track of those first four returned garbage words, you might think that one or more of them is part of your returned Read Data.

So, in order to know what you are actually getting from the receive buffer, it's important to know the size of your buffer, know how to tell whether it's empty or full (there's usually register status bit to report this) and keep track of how much stuff you've transmitted and how much you've received.

Before starting any SPI Flash operation, it's a good idea to 'drain' the Receive FIFO. This means check the status of the receive buffer and empty it (usually done by performing a 'read' of the Receive Buffer) if it is not already empty. Usually, emptying (reading) an already empty Receive Buffer does no harm.

The following information is available from the timing diagrams in datasheets of SPI Flashes, but sometimes folks overlook bits. All commands and data are issued to the SPI flash using the SPI bus. The sequence to read a SPI Flash is:

Note that steps 6 and 7 must be interleaved and repeated depending on the size of the read and the size of your Receive and Transmit Buffers. If you Transmit a larger number of words at one go, than your Receive Buffer can hold, you'll spill some data.

In order to preform a Page Program or Write command perform these steps. Page Size (typically 256 bytes) and Sector Size (typically 64K) and associated boundaries are properties of the SPI Flash you are using. This information should be in the datasheet for the Flash. I will omit the details of balancing the Transmit and Receive buffers.

Finally, if your write address is not on a page boundary (typically a multiple of 256 bytes) and you write enough data to cross the following page boundary, the data that should cross the boundary will be written to the beginning of the page in which your program address falls. So, if you attempt to write three bytes to address 0x0FE. The first two bytes will be written to 0x0fe and 0x0ff. The third byte will be written to address 0x000.

If you transmit a number of data bytes larger than a page size, the earlies bytes will be discarded and only the final 256 (or page size) bytes will be used to program the page.

As always, not responsible for consequences of any errors, typos, oversights, or derangement in the above, nor in how you put it to use.

Jeff WaltherJeff Walther
$endgroup$$begingroup$

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).

Serial Flash Memory Programmer Schematic Free

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:

Serial flash memory
  • 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.

JxjJxj
$endgroup$$begingroup$

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.

Chris StrattonChris Stratton
$endgroup$

protected by CommunityFeb 1 '17 at 12:40

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).
Would you like to answer one of these unanswered questions instead?

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

Designing with discrete flash is 1/10th the cost, uses a much smaller form factor, and requires significantly less specialized hardware than using SD flash cards.
This Instructable will show you how to add 1MB of discrete external flash memory to your microcontroller project with what I believe to be the least amount of effort possible. This is also a follow-on to my other twoll need to consider these tradeoffs for your design. The list below contains a few tradeoffs I think about when I need to decide if I want to use a single 8-pin DIP chip or a full-on SD solution:

Hardware Complexity (Choose: Discrete)

One way to add SD flash to an Arduino system is to use a shield, such as this one by Seeed Studio (three 'e's) I bought at my local Radio Shack for $15. While shields provide convenience for prototyping, the final production assembly might not have the budget or the space to include SD hardware. An 8-pin DIP package of a discrete flash chip is much easier to drop on a protoboard than an SD shield, assuming your development board even supports a shield.

Software Complexity (Choose: Discrete)

The SD flash subsystem commonly relies on the SDFat16/32 libraries. While the devices are an SPI interface, it makes sense to use FAT since any PC/MAC can then read this card. These libraries are large and can take up precious EEPROM space on smaller embedded controllers. Compatibility and integration into your build environment may require significant debug. The software required to drive a discrete flash chip with an SPI interface is trivial and very small, as you will soon see. Maybe this says more about me than the SDFat libraries, but I find them cumbersome to work with.

Capacity & Portability (Choose: SD)

SD flash wins big here, simply pop in a larger capacity SD card into the existing design with no modifications. Discrete SPI flash has lower density limits in the 8-pin DIP format. The SDFat library means any PC/MAC can read the files on the card.

Cost (Choose: Discrete)

SD cards range in price dramatically, and with an SD flash shield, can set you back $20-$30. WinBond 1MB chips cost about $2 from Mouser or Digikey.

Power (Choose: Discrete)

Energy requirements of flash depend on the manufacturer, production lot, device density, and process technology. SD cards are typically higher leakage power due to the higher densities, and higher dynamic power due to the higher access speeds. The WinBond chips I focus on in this Instructable require very little power, 6uW standby, 60mW page program, and 60mW chip erase. I wasn't able to find power data on the high-end super-fast SD cards, but the write speed is about 100x that of the WinBond. Since dynamic power is proportional to frequency, I can't imagine power would be less.

Speed (Choose: SD)

I haven't had any need for very fast flash memory write performance, but SD flash comes in many different product SKUs based on speed (mostly due to the demands of digital photography and the use of raw image formats). The WinBond SPI chips can't really compare: page program speed is 0.7ms for 256 bytes, which translates to 0.360MB/s, which is 100x slower than Team Corp.’s fastest Micro SD cards at ~40MB/s. I suspect they have multiple devices or arrays writing in parallel to achieve those speeds.

While this analysis most likely represents my own lazy biases, I find my brand of laziness to be rather prolific. That being said, any one of these vectors may be more important for your project, but my goal here is to call out the tradeoffs, and then illustrate the simplicity of this wonderful flash chip. (And I haven't even discussed using larger capacity parallel flash chips.)