pico-ice
RaspberryPi Pico with an iCE40 FPGA
|
The FPGA normally boots from a dedicated serial NOR flash. This flash can be programmed by the Pico processor which exposes the flash to the host OS as either a removable drive or a DFU endpoint.
On Windows, while the RaspberryPi guide mentions using Visual Studio Code with a plugin a an IDE, better results were obtained by using the WSL2 environment.
You would need a compiler toolchain installed for building the UF2 Utils on your system. On Windows, you can use https://github.com/microsoft/uf2 instead, which contains uf2conv.py.
Out of the box, the default firmware should already be present on your board. You can skip step 1 if this is the case.
rgb_blink.bin
into an UF2 rgb_blink.uf2
with the UF2 Utils: $ bin2uf2 -o rgb_blink.uf2 rgb_blink.bin
pico-ice
. Open it.rgb_blink.uf2
file to that drive you just attached. As soon as you copy the file over,t he pico-ice will reboot and allow the FPGA to come up depending on the code running in the Pico processor.Install the DFU utilities.
a. For Windows, yosys-hq tabby-cad: double-clicking on start.bat
on the OSS CAD Suite installation opens a prompt with the dfu-util command available.
b. For other systems you can install the dfu-util package.
dfu-util -l
. This should list the pico-ice as a DFU device: Found DFU: [1209:b1c0] ver=0100, devnum=105, cfg=1, intf=0, path="1-4.4", alt=0, name="iCE40 DFU (flash)", serial="DE62A435436F5939" Found DFU: [1209:b1c0] ver=0100, devnum=105, cfg=1, intf=0, path="1-4.4", alt=1, name="iCE40 DFU (CRAM)", serial="DE62A435436F5939"
-R
flag. $ dfu-util --alt 0 --download rgb_blink.bin --reset # to flash $ dfu-util --alt 1 --download rgb_blink.bin # to volatile memory
The APIO project is a command line tool to fetch and use the oss-cad-suite FPGA toolchain based on Yosys.
It will bring an up-to-date build environment running quickly.
On Windows, you will first need to setup the libusbK
driver for pico-ice DFU (CRAM)
with Zadig or with UsbDriverTool (doc).
# Download the latest APIO dev version (with pico-ice support): pip3 install git+https://github.com/FPGAwars/apio # Download and install oss-cad-suite apio install -a # Build a new directory with a "blinky" example project inside mkdir pico-ice-blinky; cd pico-ice-blinky apio examples -f iCE40-UP5K/blink # Set the board to "pico-ice" apio init --sayyes --board pico-ice # Build the project using yosys/nextpnr apio build # Plug your pico-ice board and upload the blinky project to it apio upload
If apio upload
fails, it is also possible to convert the .bin
file to .uf2
with uf2-utils or uf2conv.py: doc.
The OSS CAD Suite project is a pre-compiled package of several tools. It provides a complete solution for building, debugging, simulating, uploading Hardware Description Language (HDL). It is based on Yosys.
As explained on the installation instructions, you can download it and extract it to a directory of your choice.
Several pico-ice-sdk examples rely on a $OSS_CAD_SUITE
variable set to the full path where you extracted these files.
On Windows, you can run these examples from the cygwin environment, under which you can navigate to the example repositories and try them.
You can access the utilities directly from a shell environment after adding the $OSS_CAD_SUITE
to the $PATH
.
If you used apio
to install OSS CAD Suite:
export OSS_CAD_SUITE="$HOME/.apio/packages/tools-oss-cad-suite" export PATH="$PATH:$OSS_CAD_SUITE/bin"
Once the FPGA bitfile transfers over using the DFU protocol, the Pico will check for whether the DONE pin goes high indicating a successful boot. This would make the CDONE green LED bright. If this doesnt happen for whatever reason, the DFU utility will throw an error indicating that this did not succeed.
The user writing a custom firmware with the pico-ice-sdk should take care of starting the FPGA from the MCU. Review the pico_fpga example for how this can be done, as well as the ice_fpga library documentation. The USB DFU provided as part of the pico-ice-sdk must also be enabled for the DFU interface to show-up. The pico_usb_uart example project have it enabled by default.
This error might occur when a communication error occurs.
dfu-util
might need to be run as super user.To create an udev rule, add a file named /etc/udev/rules.d/99-pico-ice.rules
with this content:
SUBSYSTEM=="usb", ATTRS{idVendor}=="1209", ATTRS{idProduct}=="b1c0", MODE="0666"
Then reboot or run the following commands:
sudo udevadm control --reload-rules sudo udevadm trigger
For devices with multiple DFU devices connected, the --device 1209:b1c0
flag is needed:
dfu-util --alt 0 --download rgb_blink.bin --reset --device 1209:b1c0
Alternatively, the dfu-util --list
result will allow selecting a device per number:
dfu-util --alt 0 --download rgb_blink.bin --reset --devnum 0
This could be due that there was no response from the flash chip, and the RP2040 is endlessy waiting the write confirmation. If you had an earlier board, it could be due to the fact the TX and RX pins were swapped, and do not work for the old board anymore.
The UF2 file format contains the destination addresses of each block. In case you used other tools than those provided, it is possible that that the addresses were outside the valid range of the flash chip. Try to copy the CURRENT.UF2 to NEW.UF2 upon that same directory, and unmount the device. This should trigger a restart of the device. This restart device should appear from the debug UART: board_dfu_complete: rebooting
.
This message sometimes comes from dfu-util
when the -R
flag is not used. With the -R
flag, the pico-ice will reboot at the end of the transfer, and DFU-util should not complain anymore.