Close

Drag-n-Drop FPGA Loading

A project log for FPGA Helper

A programming and communication interface for FPGAs

greggreg 06/01/2024 at 03:220 Comments

It is now possible to drag-n-drop an image onto an Altera FPGA.

This project has taken many detours, often due to a lack of time for software development (or my preference for circuit-board design).  In any case the latest detour came when I learned about the PICO-DIRTYJTAG project by Patrick Dussud.  This project enables the $4 Raspberry Pi RP2040 Pico board to work with openFPGALoader to program a wide variety of FPGAs.  This would save me quite a bit of time with software development, or so I thought.

Getting PICO-DIRTYJTAG working with openFPGALoader was a breeze.  My first test was to load an image into the MAX10 10M08 Evaluation Kit that does not include an integrated loader.  openFPGALoader "supports" MAX10 through SVF files, which technically works, but is painfully slow.  So slow that I decided to find a better software solution.  I had stalled on my previous efforts to implement an SVF interpreter and decided to look for some other options.  Altera also provides STAPL JAM and JBC files for programming, and these are a little more embedded friendly.  JBC files convert JAM files to byte code and are more space efficient, so I opted to implement a JBC loader.  

Contrary to some pages on the Intel website, the JAM and JBC player code has NOT been discontinued.  You can still find it if you know where to look.  I downloaded the code and started porting to the RP2040 Pico board.

Unlike an SVF file that must run linearly, JAM files have advanced features such as looping that requires the ability to go back in the file.  This means that you can't simply stream through it, but you need to store it.  The Pico board does not have enough RAM to hold a JBC file, but fortunately the flash is large enough to easily hold the full image for a small device like the 10M08.

The Raspberry Pi RP2040 includes a UF2 based bootloader for firmware updates.  This makes loading images a breeze.  No drivers or tools are needed to load the firmware because it appears like a USB drive that most operating systems recognize.  

One way to get the JBC image into flash would be to build it into the firmware image when you compile.  This would work, but is not ideal since it requires you to rebuild the firmware for every new FPGA image.  We can streamline this process by leveraging the brilliance of the UF2 format created by Michal Moksal.  We instead of converting the JBC data to a C include file and compiling it to an image that will eventually be converted to UF2, we can convert it directly into UF2 format.  We just need to add a header with the file size of the JBC file.

Depending on what was running last on the Pico board, you may need to swap the firmware before adding the JBC data, and there could be compatibility issues between the firmware and JBC header.  The simplest solution is to combine the JBC UF2 file with a compatible firmware image so that it works reliably regardless of what was previously loaded on the Pico board.

So this is what I did.  I re-wrote the uf2conv.py script to take an existing UF2 firmware image, extract the family code, recalculate the number of blocks to include the JBC file and header, and concatenated the header uf2 block and the newly converted JBC blocks to file.  

This new combined UF2 file can be drag-n-dropped onto the Pico board and will immediately program the FPGA through the pico-dirty-blaster adapter

The pico-jbi.uf2 JBC player firmware and the uf2jbc.py generator script are available at the pico-dirty-blaster github repo.

Discussions