Intel Flash Programming

Author: Paul Maddox

One of the things I liked most about this board was the fact that it hard a large (16Mbyte) flash memory on board, perfect for storing waveforms and samples!

But, how do you get your own data in the flash?

Those nice people at Xilinx have given us a 'quick' soloution in the Spartan-3E design examples page, its the fifth one down called PicoBlaze SPI Flash Programmer for the Spartan-3E Starter Kit Board This solution uses the PicoBlaze core and Serial port on board the FPGASynth.Spartan3EStarterKit

If you're only interested in programming the data in the Flash, thendo the following

  1. Download the zip file and extract it.
  2. Open Hyper Terminal and set it up according ot page 5 of the instructions.
  3. Run the install_parallel_flash_memory_uart_programmer.bat file.

Xilinx kindly give us a file ready to load, it's a frequency counter (nice chaps aren't they?). But for me what I was really interested in, was getting my own data into the FLASH..

Now, here lies a problem, the .MCS file is an 'intel hex format', this means it's not just a case of sending it a binary file (like an eprom image). You need to format it in the correct way, else the Flash Programmer puts the wrong data in all the wrong places in flash and won't ever 'exit'.

So, what is the correct file format?

Ok, the file is a 'text' file, so have 'notepad' handy. first things first, let's start with the first line, which tells the programmer about the file, I'm not going to go into the full 'blurb' as to why, but this will get you going ;-

:020000040000FA

next you need to send the data, it needs to be arranged in this format ;-

:10246200464C5549442050524F46494C4500464C33

Lets eplain this line of seemingly random characters

  • The ':' tells the progammer we've got something comming, you need this a fresh new line.
  • The next two digits are the record length, in hex, in this case '10' which is 16 bytes.
  • The next four digits are the address, again, in this case '2462'.
  • The next two are the 'record type' for us, this will almost certainly always be '00' (data record).
  • Then we have 16 lots of 8 bit data, again, in hex
  • Finally an 8 bit checksum

Having played with getting some data into the Flash for about 2 hours, I can confirm that the Xilinx example code ignores the checksum, so just put any value here (I used 'FF').

Finally at the end of the file you must have this line ;-

:00000001FF

This is the 'End of file', when the picoblaze sees this it'll stop writing to the Flash.

Points to note:

  • All the alpha characters used in file to donate hex values (a, b, c, d, e and f) MUST be in UPPER CASE, if you don't use upper case you're data will become corrupt!
  • Make sure that there are no trailing spaces at the end of the line (after the checksum) this confuses the hell out of the programming software, and you'll start seeing wierd addresses shooting up the screen as it's programming!
  • You can have 'Carriage Returns' between lines that start with a ':'
  • You can check your data is correct by using the 'r' command in hyperterminal (whilst the FPGA is still running the Flash programmer).

Finally, I've uploaded a file, which contains three 8 bit waveforms stored as 256byte full cycle waves.

  • a rising sawtooth,
  • a square wave (50/50 duty cycle)
  • a sine wave

Here it is - SAW_SQUARE_SINE.mcs

This should give you a start to putting your own wavedata into flash.. All that's left to do, is get the oscillator to read from flash, I'll post a soloution once I have it working.

For full details on the Intel Hex File Format, visit this page at keil.com.