Tinyprog makes serial port disappear when attempting to program TinyFPGA-BX [SOLVED]


#1

I’m trying to get my TinyFPGA-BX up and running for the first time. I’m following the TinyFPGA BX User’s Guide.

tinyprog --update-bootloader appears to work successfully, in that it sees the board:

$ 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!

$

However, when I get to the step of uploading blink_project from Atom, it fails with:

Error: board TinyFPGA-BX not connected

What can I do to fix this? I’m on Ubuntu 20.04 and using Atom 1.55.0.


#2

I read up on how to do things from the command line. I did apio build, which seems to succeed, and then I did tinyprog -p hardware.bin, which failed. It seemed to first recognize the board, and then claim it wasn’t there:

$ 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
$

Where should I go for help with this?


#3

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

#4

Hi,

I am thinking of two possible problems. The first being that somebody else (like the modem manager is already messing around with the bootloader or a bad USB cable). Try with a few different cables. Also to understand what is going on you can look at the output from dmesg --follow (in a second terminal) while performing the operations.


#5

I tried a few cables, but they all have the exact same result. And the same cables are perfectly happy to program other development boards, just not TinyFPGA BX.

When I run tinyprog -l, dmesg --follow says:

[3146033.560523] usb 3-4: new full-speed USB device number 3 using ohci-pci
[3146033.800930] usb 3-4: New USB device found, idVendor=1d50, idProduct=6130, bcdDevice= 0.00
[3146033.800936] usb 3-4: New USB device strings: Mfr=0, Product=0, SerialNumber=0
[3146033.804178] cdc_acm 3-4:1.0: ttyACM0: USB ACM device
[3146055.088005] usb usb3-port4: disabled by hub (EMI?), re-enabling...
[3146055.088020] usb 3-4: USB disconnect, device number 3
[3146055.088038] cdc_acm 3-4:1.1: acm_start_wb - usb_submit_urb(write bulk) failed: -19
[3146055.088118] cdc_acm 3-4:1.0: failed to set dtr/rts
[3146055.436273] usb 3-4: new full-speed USB device number 4 using ohci-pci
[3146055.628253] usb 3-4: device descriptor read/64, error -62
[3146055.928252] usb 3-4: device descriptor read/64, error -62
[3146056.224240] usb 3-4: new full-speed USB device number 5 using ohci-pci
[3146056.420250] usb 3-4: device descriptor read/64, error -62
[3146056.720236] usb 3-4: device descriptor read/64, error -62
[3146056.828270] usb usb3-port4: attempt power cycle
[3146057.332236] usb 3-4: new full-speed USB device number 6 using ohci-pci
[3146057.748228] usb 3-4: device not accepting address 6, error -62
[3146057.936237] usb 3-4: new full-speed USB device number 7 using ohci-pci
[3146058.352233] usb 3-4: device not accepting address 7, error -62
[3146058.352280] usb usb3-port4: unable to enumerate USB device
[3146060.044204] usb 3-4: new full-speed USB device number 8 using ohci-pci
[3146060.284943] usb 3-4: New USB device found, idVendor=1d50, idProduct=6130, bcdDevice= 0.00
[3146060.284949] usb 3-4: New USB device strings: Mfr=0, Product=0, SerialNumber=0
[3146060.288115] cdc_acm 3-4:1.0: ttyACM0: USB ACM device

#6

Hi, perhaps also please try a different usb port or even try using a powered hub.

What does dmesg say

  • When you plug in ?
[3146033.560523] usb 3-4: new full-speed USB device number 3 using ohci-pci
[3146033.800930] usb 3-4: New USB device found, idVendor=1d50, idProduct=6130, bcdDevice= 0.00
[3146033.800936] usb 3-4: New USB device strings: Mfr=0, Product=0, SerialNumber=0
[3146033.804178] cdc_acm 3-4:1.0: ttyACM0: USB ACM device
  • When does the following happen:
[3146055.088005] usb usb3-port4: disabled by hub (EMI?), re-enabling...

What happens when you plug it in and type tinyprog -b (to get out of the bootloader?)


#7

I’ve tried all 5 USB ports on the front of the computer, and I tried one of the ports on the back.

I will look and see if I have a powered hub. I’m not sure I have one, but I’ll go through my stuff and see.

When I plug into the back of the computer, dmesg says:

[3184684.741644] usb 3-1: new full-speed USB device number 9 using ohci-pci
[3184684.965022] usb 3-1: device descriptor read/all, error -62
[3184685.165641] usb 3-1: new full-speed USB device number 10 using ohci-pci
[3184685.357646] usb 3-1: device descriptor read/64, error -62
[3184685.657645] usb 3-1: device descriptor read/64, error -62
[3184685.765673] usb usb3-port1: attempt power cycle
[3184686.273636] usb 3-1: new full-speed USB device number 11 using ohci-pci
[3184686.689630] usb 3-1: device not accepting address 11, error -62
[3184686.877633] usb 3-1: new full-speed USB device number 12 using ohci-pci
[3184687.293624] usb 3-1: device not accepting address 12, error -62
[3184687.293661] usb usb3-port1: unable to enumerate USB device
[3184688.985606] usb 3-1: new full-speed USB device number 13 using ohci-pci
[3184689.225022] usb 3-1: unable to read config index 0 descriptor/all
[3184689.225033] usb 3-1: can't read configurations, error -62
[3184689.425612] usb 3-1: new full-speed USB device number 14 using ohci-pci
[3184689.617594] usb 3-1: device descriptor read/64, error -62
[3184689.917596] usb 3-1: device descriptor read/64, error -62
[3184690.025615] usb usb3-port1: attempt power cycle
[3184690.529581] usb 3-1: new full-speed USB device number 15 using ohci-pci
[3184690.945578] usb 3-1: device not accepting address 15, error -62
[3184691.133581] usb 3-1: new full-speed USB device number 16 using ohci-pci
[3184691.549579] usb 3-1: device not accepting address 16, error -62
[3184691.549620] usb usb3-port1: unable to enumerate USB device
[3184693.245562] usb 3-1: new full-speed USB device number 17 using ohci-pci
[3184693.484024] usb 3-1: unable to read config index 0 descriptor/all
[3184693.484034] usb 3-1: can't read configurations, error -62
[3184693.677554] usb 3-1: new full-speed USB device number 18 using ohci-pci
[3184693.869547] usb 3-1: device descriptor read/64, error -62
[3184694.169544] usb 3-1: device descriptor read/64, error -62
[3184694.277569] usb usb3-port1: attempt power cycle
[3184694.781539] usb 3-1: new full-speed USB device number 19 using ohci-pci
[3184695.197530] usb 3-1: device not accepting address 19, error -62
[3184695.385532] usb 3-1: new full-speed USB device number 20 using ohci-pci
[3184695.801523] usb 3-1: device not accepting address 20, error -62
[3184695.801558] usb usb3-port1: unable to enumerate USB device
[3184697.493504] usb 3-1: new full-speed USB device number 21 using ohci-pci
[3184697.726034] usb 3-1: New USB device found, idVendor=1d50, idProduct=6130, bcdDevice= 0.00
[3184697.726041] usb 3-1: New USB device strings: Mfr=0, Product=0, SerialNumber=0
[3184697.729160] cdc_acm 3-1:1.0: ttyACM0: USB ACM device

When I run tinyprog -l, I get:

[3184789.705093] usb usb3-port1: disabled by hub (EMI?), re-enabling...
[3184789.705103] usb 3-1: USB disconnect, device number 21
[3184789.706084] cdc_acm 3-1:1.0: failed to set dtr/rts
[3184790.060425] usb 3-1: new full-speed USB device number 22 using ohci-pci
[3184790.260424] usb 3-1: device descriptor read/64, error -62
[3184790.560407] usb 3-1: device descriptor read/64, error -62
[3184790.856406] usb 3-1: new full-speed USB device number 23 using ohci-pci
[3184791.048419] usb 3-1: device descriptor read/64, error -62
[3184791.348412] usb 3-1: device descriptor read/64, error -62
[3184791.456443] usb usb3-port1: attempt power cycle
[3184791.960406] usb 3-1: new full-speed USB device number 24 using ohci-pci
[3184792.376386] usb 3-1: device not accepting address 24, error -62
[3184792.564405] usb 3-1: new full-speed USB device number 25 using ohci-pci
[3184792.980394] usb 3-1: device not accepting address 25, error -62
[3184792.980438] usb usb3-port1: unable to enumerate USB device
[3184794.672372] usb 3-1: new full-speed USB device number 26 using ohci-pci
[3184794.905075] usb 3-1: New USB device found, idVendor=1d50, idProduct=6130, bcdDevice= 0.00
[3184794.905082] usb 3-1: New USB device strings: Mfr=0, Product=0, SerialNumber=0
[3184794.908255] cdc_acm 3-1:1.0: ttyACM0: USB ACM device

The “disabled by hub (EMI?)” message is always the very first thing printed, the instant that I run tinyprog.

Pretty much the same thing. tinyprog crashes with an exception, and dmesg says:

[3185035.672220] usb usb3-port3: disabled by hub (EMI?), re-enabling...
[3185035.672234] usb 3-3: USB disconnect, device number 31
[3185035.673191] cdc_acm 3-3:1.0: failed to set dtr/rts
[3185036.037567] usb 3-3: new full-speed USB device number 32 using ohci-pci
[3185036.233551] usb 3-3: device descriptor read/64, error -62
[3185036.533553] usb 3-3: device descriptor read/64, error -62
[3185036.829538] usb 3-3: new full-speed USB device number 33 using ohci-pci
[3185037.025533] usb 3-3: device descriptor read/64, error -62
[3185037.325539] usb 3-3: device descriptor read/64, error -62
[3185037.433566] usb usb3-port3: attempt power cycle
[3185037.937540] usb 3-3: new full-speed USB device number 34 using ohci-pci
[3185038.357539] usb 3-3: device not accepting address 34, error -62
[3185038.545522] usb 3-3: new full-speed USB device number 35 using ohci-pci
[3185038.961523] usb 3-3: device not accepting address 35, error -62
[3185038.961567] usb usb3-port3: unable to enumerate USB device
[3185040.653497] usb 3-3: new full-speed USB device number 36 using ohci-pci
[3185040.886176] usb 3-3: New USB device found, idVendor=1d50, idProduct=6130, bcdDevice= 0.00
[3185040.886182] usb 3-3: New USB device strings: Mfr=0, Product=0, SerialNumber=0
[3185040.889346] cdc_acm 3-3:1.0: ttyACM0: USB ACM device

#8

I found a powered USB hub and gave it a try. That seems to have fixed the problem!

tinyprog still crashes with an exception:

$ tinyprog -p hardware.bin

    TinyProg CLI
    ------------
    Using device id 1d50:6130
    Only one board with active bootloader, using it.
    Programming /dev/ttyACM0 with hardware.bin
    Programming at addr 028000
    Waking up SPI flash
    135100 bytes to program
    Erasing: 100%|████████████████████████████| 135k/135k [00:01<00:00, 126kB/s]
    Writing: 100%|████████████████████████████| 135k/135k [00:00<00:00, 207kB/s]
    Reading: 100%|████████████████████████████| 135k/135k [00:00<00:00, 422kB/s]
    Success!
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 374, in main
    fpga.boot()
  File "/home/ppelleti/.local/lib/python3.8/site-packages/tinyprog/__init__.py", line 389, in boot
    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')
$

and dmesg says:

[3187747.122317] usb 2-4.4: USB disconnect, device number 9
[3187747.124610] cdc_acm 2-4.4:1.0: failed to set dtr/rts

However, I guess that doesn’t really matter, since it successfully programmed the FPGA, and the LED is blinking in the new pattern!

Thanks for your help! I appreciate it.


#9

Great!

This (to me) means that perhaps somebody is pulling the dtr/rts lines(I have seen this error on my setup but not currently). is there a process called modemmanager on the system? does after plugging

lsof /dev/ttyACM0 return anything (it should not) see [SOLVED]Irregular flash error


#10

Yes, there was:

$ ps -ef | fgrep -i modemmanager
root         874       1  0 Feb06 ?        00:00:00 /usr/sbin/ModemManager --filter-policy=strict
ppelleti  457716    3052  0 15:49 pts/0    00:00:00 grep -F -i modemmanager
$

Although lsof did not return anything:

$ lsof /dev/ttyACM0
$

So I followed this answer to disable modemmanager:

$ systemctl disable ModemManager.service
Removed /etc/systemd/system/dbus-org.freedesktop.ModemManager1.service.
Removed /etc/systemd/system/multi-user.target.wants/ModemManager.service.
$ systemctl stop ModemManager.service
$

And that fixed the trouble with tinyprog returning an exception.

It’s probably worth adding both of these things (to disable modemmanager, and to try a powered USB hub if things aren’t working) to the User Guide.