-
Notifications
You must be signed in to change notification settings - Fork 8
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.
The 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.
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!
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 iceboot
:
sudo dfu-util -d 0483:df11 --alt 0 --dfuse-address 0x08000000:mass-erase:force -D ./firmware/iceboot/iceboot.raw
Note the 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.
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.
Like this:
dd if=/dev/zero of=zeroes.bin bs=135100 count=1
dfu-util -a 0 -s 0x0801f000 -D zeroes.bin