Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Flashing an FPGA Design to the BlackIce II
The Getting Started wiki page tells us how to load an FPGA bitstream into the BlackIce-II board, but that's just a volatile state: after powering down the board, the FPGA will once again be empty.
However, the standard
iceboot firmware of the STM32 controller (which handles the the volatile bitstream download as well) also
supports non-volatile bitstreams.
iceboot firmware works as follows:
- Power Up
- Initialize various aspects of the chip
- Check address location 0x0801F000 for the presence of an FPGA bitstream file. (The internal flash starts at address 0x08000000.) If present, the program the FPGA with the resident bitstream file.
- Monitor the USB1 port until an FPGA bitstream is detected. When detected, program the FPGA with the incoming bitstream.
Programming the FPGA Bitstream into the Internal Flash
You program the bitstream by bringing the STM32 into DFU mode. This is all nicely described in the [DFU operations on the BlackIce-II](DFU operations on the BlackIce-II) article.
Once in DFU mode, you program the bitstream like this:
sudo dfu-util -d 0483:df11 --alt 0 --dfuse-address 0x0801F000 -D <name of bitstream file>
For example, to program the
blink example of the BlackIce-II github repo:
ubuntu@ubuntu-xenial:~/projects/BlackIce-II$ cd examples/blink/ ubuntu@ubuntu-xenial:~/projects/BlackIce-II/examples/blink$ sudo dfu-util -d 0483:df11 --alt 0 --dfuse-address 0x0801F000 -D chip.bin dfu-util 0.9 Copyright 2005-2009 Weston Schmidt, Harald Welte and OpenMoko Inc. Copyright 2010-2016 Tormod Volden and Stefan Schmidt This program is Free Software and has ABSOLUTELY NO WARRANTY Please report bugs to http://sourceforge.net/p/dfu-util/tickets/ dfu-util: Invalid DFU suffix signature dfu-util: A valid DFU suffix will be required in a future dfu-util release!!! Opening DFU capable USB device... ID 0483:df11 Run-time device DFU version 011a Claiming USB DFU Interface... Setting Alternate Setting #0 ... Determining device status: state = dfuERROR, status = 10 dfuERROR, clearing status Determining device status: state = dfuIDLE, status = 0 dfuIDLE, continuing DFU mode device DFU version 011a Device returned transfer size 2048 DfuSe interface name: "Internal Flash " Downloading to address = 0x0801f000, size = 135100 Download [=========================] 100% 135100 bytes Download done. File downloaded successfully
Once completed, switch back to normal boot mode by putting the jumper back in place. Plug in the USB cable, and you'll see the LED blinking!
Note: the default
iceboot firmware will still allow the download of a new bitstream after it has programmed the FPGA with the
non-volatile bitstream after power up!
Erasing a Bitstream from the Internal Flash
Completely Erasing the Internal Flash
If you want to go back to the default state, where bitstreams are only uploaded over USB, yet need to erase the bitstream from the internal flash.
Use the following command completely erases the contents of the flash, and then reprograms the
sudo dfu-util -d 0483:df11 --alt 0 --dfuse-address 0x08000000:mass-erase:force -D ./firmware/iceboot/iceboot.raw
mass-erase:force option above!
After this, your BlackIce-II will be back in original condition.
If you're worried about completely bricking your board by erasing the internal flash completely, don't be: unlike some other microcontrollers, the STM32L433 has its DFU firmware stored an immutable internal ROM. So there will always be a way to reprogram it.
Just Erasing the Bitstream
If all you want to do is erase the bitstream from the flash, but leave the rest as is, just create a file with all zeros with the same size as a regular bitstream (135100 bytes), and program that as a bitstream.
dd if=/dev/zero of=zeroes.bin bs=135100 count=1 dfu-util -a 0 -s 0x0801f000 -D zeroes.bin