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?