Command line build under windows

As python and node.js were already installed on my Windows 10 system, I was able to use npm to install webfpga-cli.

As a test, I tried to synth and flash blinky.v from the icestorm_examples repository. The synth command works fine, but the flash command just returns a prompt without any error message or doing anything. What might I have missed?

I know that my board is connected ok because I can synth and flash from the website with no problems.

Hi @bratoff, Windows 10 doesn’t seem to play nicely with the Node.js’s USB implementation.

We are working on converting the command utility to Python for better cross-platform support. Right now, only flashing is supported by the new tool. (Shout out to Dave Platt for the script!)


Use the Node.js utility to synthesize and create a bitstream. Then, use the Python utility to flash the device.

# Install the old Node.js utility to synthesize the HDL
# (Sounds like you have already successfully completed this step.)
$ npm install -g webfpga-cli
$ webfpga synth blinky.v
$ ls
bitstream.bin

# Fetch the new Python utility to flash your device
$ git clone https://github.com/webfpga/cli
$ cp cli/flash.py .
$ pip install pyusb
$ python flash.py bitstream.bin

Let me know how that works! Apologies for the slow software development. Almost done with production and shipping!

Well, it sorta works sometimes. I tried synth-ing and flashing (from icestorm_examples) both blinky.v and rgb.v. In each case the program only partially works, so the code must be getting corrupted in some way. In both cases I get the same python exception from flash.py. Here’s the output:

D:\bruce\Documents\WebFPGA\webfpga_icestorm_examples>python flash.py bitstream.bin
Config 1
        Interface 0,0
                Endpoint 129
AT: Hi
API: C_WEBUSB+
APR: 010106
Found programmer.
Checking for FPGA module and its flash configuration...
APWE: wren
AMQ: SA016WHEe
AMBE: DONE
AMQ: SA016WHEE
AMW: OK
  3413 !
Flashing complete
Exception ignored in: <function _AutoFinalizedObjectBase.__del__ at 0x000002769CED3A60>
Traceback (most recent call last):
  File "C:\Python37\lib\site-packages\usb\_objfinalizer.py", line 84, in __del__
    self.finalize()
  File "C:\Python37\lib\site-packages\usb\_objfinalizer.py", line 144, in finalize
    self._finalizer()
  File "C:\Python37\lib\weakref.py", line 548, in __call__
    return info.func(*info.args, **(info.kwargs or {}))
  File "C:\Python37\lib\site-packages\usb\_objfinalizer.py", line 104, in _do_finalize_object_ref
    obj._do_finalize_object()
  File "C:\Python37\lib\site-packages\usb\_objfinalizer.py", line 71, in _do_finalize_object
    self._finalize_object()
  File "C:\Python37\lib\site-packages\usb\backend\libusb1.py", line 604, in _finalize_object
    _lib.libusb_unref_device(self.devid)
OSError: exception: access violation writing 0x0000000000000024

D:\bruce\Documents\WebFPGA\webfpga_icestorm_examples>

The blue light does blink so I know there is communication with the programmer taking place. Any ideas?

Huh, that’s odd. The device communication is clearly working – and all of the setup/verification seems to be passing just fine. I will try debugging the script on a Windows machine tonight. Personally, I’ve never run it on Windows before.


I’ve updated the Python code to log all transmitted and received blocks. Would you mind grabbing the latest version of flash.py from Git and trying again? Also, it would be great if you used the exact same bitstream that I used: bitstream.bin, source.v. Then we can compare the tx/rx blocks exactly. I’m curious to see which one it fails on.

$ ./flash.py bitstream.bin 
Config 1
	Interface 0,0
		Endpoint 129
AT: Hi
API: C_WEBUSB+
APR: 000921
Found programmer.
Checking for FPGA module and its flash configuration...
APWE: wren
AMQ: SA016WHEe
AMBE: DONE
AMQ: SA016WHEE
AMW: OK
02ff812d452b5765645f30345f5365705f323031
395f30383a32363a32345f504d5f5554432b7368
61737461706c75738103ff3381067eaa997e5181
RESPONSE => 61 

040105928109206202b372015082820211810301
018b021086024085020186020486021086024084
02108602408502018602048602108602408c0202
860208
RESPONSE => 64 

8602208602808502028602088402028602088602
20860280850202860208ffffffffffffffffffca
040c3020d402c3d5040c3020d402c3d5040c3020
d402c3
RESPONSE => 64 

d5040c3020d402c3d5040c3020d402c3d5040c30
20d402c3d5040c3020d402c3d5040c3020d402c3
d5040c3020d402c3d5040c3020d402c3d5040c30
20d4
RESPONSE => 63 

02c3d5040c3020d402c3d5040c3020d402c3d504
0c3020d402c3d5040c3020d402c3d5040c3020a4
b002c3d5040c3020d402c3d5040c3020d402c3d5
RESPONSE => 61 

040c3020d402c3d5040c3020d402c3d5040c3020
d402c3d5040c3020d402c3d5040c3020d402c3d5
040c3020d402c3d5040c3020d402c3d5040c3020
d402c3
RESPONSE => 64 

... etc ...

Flashing complete