0
\$\begingroup\$

I am using the TinyFPGA BX for the first time, and tinyprog crashes when I try to program the board.

First, I run apio build, and that seems to work fine. But then I try to program the FPGA with tinyprog:

$ tinyprog -p hardware.bin

    TinyProg CLI
    ------------
    Using device id 1d50:6130
    Only one board with active bootloader, using it.
Traceback (most recent call last):
  File "/home/ppelleti/.local/lib/python3.8/site-packages/serial/serialposix.py", line 621, in write
    n = os.write(self.fd, d)
OSError: [Errno 19] No such device

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/ppelleti/.local/bin/tinyprog", line 8, in <module>
    sys.exit(main())
  File "/home/ppelleti/.local/lib/python3.8/site-packages/tinyprog/__main__.py", line 324, in main
    fpga = TinyProg(active_port, progress)
  File "/home/ppelleti/.local/lib/python3.8/site-packages/tinyprog/__init__.py", line 209, in __init__
    self.wake()
  File "/home/ppelleti/.local/lib/python3.8/site-packages/tinyprog/__init__.py", line 250, in wake
    self.cmd(0xab)
  File "/home/ppelleti/.local/lib/python3.8/site-packages/tinyprog/__init__.py", line 242, in cmd
    self.ser.write(bytearray(cmd_write_string))
  File "/home/ppelleti/.local/lib/python3.8/site-packages/tinyprog/__init__.py", line 66, in write
    self.ser.write(data)
  File "/home/ppelleti/.local/lib/python3.8/site-packages/serial/serialposix.py", line 655, in write
    raise SerialException('write failed: {}'.format(e))
serial.serialutil.SerialException: write failed: [Errno 19] No such device
$

Any idea why it is doing this and how I can fix it? Thanks!

I am on Ubuntu 20.04, and I followed the instructions in the TinyFPGA BX User Guide to install the TinyFPGA BX software. (It looks like it installed tinyprog 1.0.21.)

Additional Information:

Here are the most recent devices after I plug in the TinyFPGA BX:

$ ls -lt /dev | head
total 0
crw-rw-rw-  1 root tty       5,   2 Mar 13 15:45 ptmx
drwxr-xr-x  2 root root        4420 Mar 13 15:45 char
drwxr-xr-x  4 root root          80 Mar 13 15:45 serial
crw-rw----  1 root dialout 166,   0 Mar 13 15:45 ttyACM0
crw-rw-rw-  1 root tty       5,   0 Mar 12 17:34 tty
drwxrwxrwt  2 root root          40 Mar 11 11:28 shm
brw-rw----  1 root disk      7,  15 Mar 11 11:00 loop15
brw-rw----  1 root disk      7,   3 Mar 11 10:59 loop3
lrwxrwxrwx  1 root root           3 Mar 11 10:49 cdrom -> sr0
$

So I'm guessing that ttyACM0 is the TinyFPGA BX? Normally I would expect a USB serial device to show up as ttyUSB0; is there something fishy going on here?

When I try to update the bootloader, tinyprog says:

$ tinyprog --update-bootloader

    TinyProg CLI
    ------------
    Using device id 1d50:6130
    Only one board with active bootloader, using it.
    All connected and active boards are up to date!

$

So assuming I believe tinyprog, it found the board and the bootloader is up to date.

Update: 2021-03-14

It looks like running tinyprog makes the serial port go away.

The serial port is there:

$ apio system --lsserial
Number of Serial devices found: 1

/dev/ttyACM0
Description: ttyACM0
Hardware info: USB VID:PID=1D50:6130 LOCATION=4-3:1.0

and then I run tinyprog -l:

$ tinyprog -l

    TinyProg CLI
    ------------
    Using device id 1d50:6130
    Only one board with active bootloader, using it.
    Boards with active bootloaders:
Traceback (most recent call last):
  File "/home/ppelleti/.local/bin/tinyprog", line 8, in <module>
    sys.exit(main())
  File "/home/ppelleti/.local/lib/python3.8/site-packages/tinyprog/__main__.py", line 296, in main
    p = TinyProg(port)
  File "/home/ppelleti/.local/lib/python3.8/site-packages/tinyprog/__init__.py", line 227, in __init__
    self.meta = TinyMeta(self)
  File "/home/ppelleti/.local/lib/python3.8/site-packages/tinyprog/__init__.py", line 141, in __init__
    self.root = self._read_metadata()
  File "/home/ppelleti/.local/lib/python3.8/site-packages/tinyprog/__init__.py", line 169, in _read_metadata
    [self._parse_json(self.prog.read_security_register_page(p).replace(b"\x00", b"").replace(b"\xff", b"")) for p in [1, 2, 3]] +
  File "/home/ppelleti/.local/lib/python3.8/site-packages/tinyprog/__init__.py", line 169, in <listcomp>
    [self._parse_json(self.prog.read_security_register_page(p).replace(b"\x00", b"").replace(b"\xff", b"")) for p in [1, 2, 3]] +
  File "/home/ppelleti/.local/lib/python3.8/site-packages/tinyprog/__init__.py", line 269, in read_security_register_page
    return self.cmd(self.security_page_read_cmd, addr=page << (8 + self.security_page_bit_offset), data=b'\x00', read_len=255)
  File "/home/ppelleti/.local/lib/python3.8/site-packages/tinyprog/__init__.py", line 243, in cmd
    self.ser.flush()
  File "/home/ppelleti/.local/lib/python3.8/site-packages/tinyprog/__init__.py", line 69, in flush
    self.ser.flush()
  File "/home/ppelleti/.local/lib/python3.8/site-packages/serial/serialposix.py", line 673, in flush
    termios.tcdrain(self.fd)
termios.error: (5, 'Input/output error')

Immediately after doing this, the serial port is gone:

$ apio system --lsserial
Number of Serial devices found: 0

But if I wait a few seconds, it comes back:

$ apio system --lsserial
Number of Serial devices found: 1

/dev/ttyACM0
Description: ttyACM0
Hardware info: USB VID:PID=1D50:6130 LOCATION=4-3:1.0

So, what am I supposed to do about that?

\$\endgroup\$
8
  • \$\begingroup\$ it looks like you are trying to sends serial data to a non-existent serial port ... the last line is very clear ... did you not read the printout? \$\endgroup\$ Commented Mar 13, 2021 at 4:01
  • \$\begingroup\$ I'm just trying to program the TinyFPGA BX. If Tinyprog is using the wrong serial port, why is it doing that, especially since the first two lines suggest it has found the device? And more importantly, how do I fix it? And let's assume that the reason I'm asking the question here is because the answer is NOT obvious to me. \$\endgroup\$ Commented Mar 13, 2021 at 5:32
  • \$\begingroup\$ okay - wow. Those TinyFPGA BX boards are...special. Normally one uses a dedicated USB to SPI bridge to interface with an ICE40. However, here the ICE40 is used to serve as the bridge IC itself. Did you check if the device is correctly listed as a serial port? Maybe the bootloader (aka firmware which let the ICE40 act as an USB device) is corrupted. \$\endgroup\$ Commented Mar 13, 2021 at 23:02
  • \$\begingroup\$ Thanks, @ChristianB.! I've added some more information at the end of my original post. Does that help any? Is there anything else I can do to check that the bootloader is OK and that tinyprog is using the correct serial port? \$\endgroup\$ Commented Mar 14, 2021 at 0:01
  • \$\begingroup\$ Well maybe u are not alone: discourse.tinyfpga.com/t/usb-device-not-recognized-tinyfpga-bx/… but if you are lucky any of the solutions posted here might help: discourse.tinyfpga.com/t/… . Personally, I would recommend investing in a good dedicated USB to SPI bridge to directly address the flash. Ideally with support for other interfaces. Comes in handy if one deals with embedded stuff frequently. \$\endgroup\$ Commented Mar 14, 2021 at 20:58

2 Answers 2

0
\$\begingroup\$

Apparently, the problem was that the TinyFPGA BX was incompatible with the USB ports on my computer. (Not really sure why.)

Putting a powered USB hub between the computer and the TinyFPGA BX solved the problem.

There was also a secondary, less severe, problem caused by the modemmanager program, which is apparently a standard daemon that pokes random serial ports at inappropriate times. The solution was to disable it.

\$\endgroup\$
2
  • \$\begingroup\$ Seems like discourse was not the worse idea in the end. Nice to hear, that you found a working solution. \$\endgroup\$ Commented Mar 15, 2021 at 22:35
  • \$\begingroup\$ Yeah, I should have had more patience. I'd just gotten worried when I saw other questions there had gone unanswered, which is why I came over here and asked the same question. \$\endgroup\$ Commented Mar 16, 2021 at 1:37
0
\$\begingroup\$

TinyFPGA BX needs the most recent bootloader. There is a CLI option to updte the bootloader. I didn't see that mentioned in the discussions above. I've had good success with the TinyFPGA BX using icestudio IDE.

\$\endgroup\$
2
  • \$\begingroup\$ As I clearly stated in my original question, tinyprog --update-bootloader says that the bootloader is up-to-date. \$\endgroup\$ Commented Jul 14, 2021 at 18:48
  • \$\begingroup\$ Sorry, I read too fast. \$\endgroup\$ Commented Jul 14, 2021 at 18:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.