Domipheus Labs

Stuff that interests Colin ‘Domipheus’ Riley

Content follows this message
If you have enjoyed my articles, please consider these charities for donation:
  • Young Lives vs Cancer - Donate.
  • Blood Cancer UK - Donate.
  • Children's Cancer and Leukaemia Group - Donate.

Writing the SPI flash of the miniSpartan3 FPGA board

Posted Jul 22, 2021, Reading time: 4 minutes.

Despite playing with my miniSpartan3 board for quite a while, I’d never attempted to write my FPGA designs to the SPI flash on the board. This means that the FPGA board didn’t do anything until I deployed my design onto it manually - quite useless if you were using the board for a real project, and on power-on you needed it to go to work immediately.

Turns out though, it is fairly simple to do, as long as you have the larger XC3S200A variant with an Atmel AT45DB041D flash chip - that’s the only way I’ve been able to validate this method with. Here are the steps you need to follow.

How to flash your miniSpartan3 (with s200a FPGA)

First, you’ll need to use utilities from the xc3sprog project. You use this to deploy your designs anyway, so should be familiar with it. You will want to update to the latest version, and we need to grab a file from the source distribution.

The version I used for testing on Windows is build-win32_rev780_stripped.tar.gz. The other file you’ll need to download is xc3sa_vq100.bit.

The way this works is that we’ll program the xc3sa_vq100.bit file onto our FPGA. What this does is configures the FPGA to use the SPI flash pins in a way that can subsequently be programmed, by allowing the FPGA to forward the commands on to the flash. Just by luck, this bitfile is set up for the Spartan3 200A FPGA on the miniSpartan3 I have.

Once that step completes successfully, we will then re-run xc3sprog with our design .bit, this time with the -I command which lets it know we are programming the SPI flash though the fpga.

The two commands are:

  1. xc3sprog -c ftdi xc3sa_vq100.bit
  2. xc3sprog -c ftdi -I your_design.bit

An example output of writing my LED test projct:

C:\dev\xc3sprog>xc3sprog.exe -c ftdi xc3sa_vq100.bit
XC3SPROG (c) 2004-2011 xc3sprog project $Rev$ OS: Windows
Free software: If you contribute nothing, expect nothing!
Feedback on success/failure/enhancement requests:
        http://sourceforge.net/mail/?group_id=170565
Check Sourceforge for updates:
        http://sourceforge.net/projects/xc3sprog/develop

Libusb not found, expect failure
Could not open FTDI device (using libftdi): usb_find_busses() failed
Using FTD2XX,
DNA is 0xb5513bdfa1138aff

C:\dev\xc3sprog>xc3sprog.exe -c ftdi -I minispartan3_leds.bit
XC3SPROG (c) 2004-2011 xc3sprog project $Rev$ OS: Windows
Free software: If you contribute nothing, expect nothing!
Feedback on success/failure/enhancement requests:
        http://sourceforge.net/mail/?group_id=170565
Check Sourceforge for updates:
        http://sourceforge.net/projects/xc3sprog/develop

Libusb not found, expect failure
Could not open FTDI device (using libftdi): usb_find_busses() failed
Using FTD2XX,
JEDEC: 1f 24 0x00 0x00
status: 9c
Found Atmel Device, Device ID 0x2400: AT45DB041
Unique number:
108070284c00f8240000d424ffff2fff0c0cec2a6c0c6c9c105490ffffffffff
fcfcffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
264 bytes/page, 2048 pages = 540672 bytes total
Verify: Success!

And that’s all you need! You should now be able to power cycle the miniSpartan3 board and see your design in action - in this case some FPGA counting LEDs.

But what if I have the smaller variant of miniSpartan3?

The reason I’m writing this post is because I was asked for advice on this very topic, however for the smaller XC3S-50a FPGA variant of miniSpartan3. My miniSpartan3 is the larger one, and this procedure runs fine. I was able to build a version of the xc3sa_vq100.bit file used earlier for the smaller FPGA using the other sources in the xc3sprog repo, but sadly this got even more confusing - as the JEDEC id that was being forwarded during the second part of step was corrupt.

I tweeted out the other day:

This is because the smaller miniSpartan3 board that was failing seems to have a different SPI flash with a completely different pinout - one which will not work here at all.

So yeah - if anyone has one of these boards, please tell me what flash chip you have! Quite puzzled by this one.

Wrap up

Thanks for reading. Any comments or questions can be directed to me on Twitter @domipheus.