TL;DR - I created a gist for the entire WSL toolchain setup for the TinyFPGA.
The problem that I encountered: is that although a Windows DOS prompt sees the device:
C:\Users\gojimmypi>tinyprog TinyProg CLI ------------ Using device id 1d50:6130 Only one board with active bootloader, using it.
WSL does not:
gojimmypi@MYHOST: ~ 0 $ tinyprog TinyProg CLI ------------ Using device id 1d50:6130 No port was specified and no active bootloaders found. Activate bootloader by pressing the reset button.
Given the comments in my GitHub issue about libusb having never been supported in WSL, I wondered how it could have previously worked? Curiously, I discovered that the tinyFPGA can use either the serial port or the USB drivers (note the last two options: no libusb support in WSL, but COM ports via pyserial should work):
usage: tinyprog [-h] [-l] [-p PROGRAM] [-u PROGRAM_USERDATA] [--program-image PROGRAM_IMAGE] [-b] [-c COM] [-i ID] [-d DEVICE] [-a ADDR] [-m] [--update-bootloader] [--libusb] [--pyserial] optional arguments: -h, --help show this help message and exit -l, --list list connected and active FPGA boards -p PROGRAM, --program PROGRAM program FPGA board with the given user bitstream -u PROGRAM_USERDATA, --program-userdata PROGRAM_USERDATA program FPGA board with the given user data --program-image PROGRAM_IMAGE program FPGA board with a combined user bitstream and data -b, --boot command the FPGA board to exit the bootloader and load the user configuration -c COM, --com COM serial port name -i ID, --id ID FPGA board ID -d DEVICE, --device DEVICE device id (vendor:product); default is (1d50:6130) -a ADDR, --addr ADDR force the address to write the bitstream to -m, --meta dump out the metadata for all connected boards in JSON --update-bootloader check for new bootloader and update eligible connected boards --libusb try using libusb to connect to boards without a serial driver attached --pyserial use pyserial to connect to boards
So in theory, this should have forced the issue in WSL and used the serial port, but no luck:
tinyprog --pyserial --list TinyProg CLI ------------ Using device id 1d50:6130 No port was specified and no active bootloaders found. Activate bootloader by pressing the reset button.
sudo usermod -a -G dialout $USER sudo usermod -a -G tty $USER
Microsoft claims that Serial COM ports have been supported on WSL since Windows Insider Build 16176. There's also this WSL issue #1929 that indicates serial port issues have been resolved.
Annoyingly, although Linux starts counting at zero, Microsoft instead apparently decided to instead start at 1 for serial ports in WSL. Thus
/dev/ttyS0for Linux is COM1: on the PC, however COM1: will be
|Google Search Result for "linux list serial ports"|
I also opened a new Recognizing TinyFPGA BX in WSL topic on the tinyFPGA discourse site.
UPDATE: many thanks to lawrie.griffiths for his help on the tinyFPGA discourse thread for determining that although the
--metaparameters do not currently work in WSL, forcing a reboot with
-band most importantly, programming with
-pwhile explicitly naming the com port with the
-coption does work! Woohoo :)
Here are the commands in WSL of interest:
# force tinyFPGA to exit bootloader (reset or unplug board afterwards as needed) tinyprog -b -c /dev/ttyS12 # program the tinyFPGA, while explicitly naming the port tinyprog --com /dev/ttyS12 -p hello_word.bin
As a reminder, do not modify WSL filesystem file from Windows! Yes, I've seen some pretty weird things happen when I tested that. But feel free to edit any other files. For instance, the entire
C:\directory is available in WSL as
Check out my next blog on setting up a soft RISC-V CPU on the tinyFPGA.
Resources, Inspiration, Credits, and Other Links:
- TinyFPGA BX User Guide
- Serial Support on the Windows Subsystem for Linux
- How To Check and Use Serial Ports Under Linux
- github.com/Microsoft/WSL/issues/ - COM Port Access in WSL #1929
- superuser.com - How do I know which /dev/ttyS* is my serial port?
Please leave comments, ideas, suggestions below (moderated, sometimes delayed) or send me a message at gmail, or find me on twitter.