circuitpython: samd: REPL disconnect problems after tinyusb PR

PR #1321 has caused problems with uploading files over the serial REPL.

Using latest master:

pi@agl:~/circuitpython/workdirs/test/circuitpython$ git log -1 --oneline
0ea31ec15 (HEAD -> test, origin/master, origin/HEAD, master) Merge pull request #1339 from dhalbert/3.x-frozen-swap

I’m unable to put a 460k file using ampy:

pi@cp:~/work/circuitpython/ampy $ python3 ampy/cli.py -p /dev/ttyACM1 put ../workdirs/test/circuitpython/ports/atmel-samd/build-metro_m4_express/firmware.uf2
Traceback (most recent call last):
  File "/home/pi/.local/lib/python3.5/site-packages/serial/serialposix.py", line 537, in write
    n = os.write(self.fd, d)
OSError: [Errno 5] Input/output error

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "ampy/cli.py", line 419, in <module>
    cli()
<snip>
  File "/home/pi/.local/lib/python3.5/site-packages/serial/serialposix.py", line 571, in write
    raise SerialException('write failed: {}'.format(e))
serial.serialutil.SerialException: write failed: [Errno 5] Input/output error

Kernel log:

pi@cp:~/work/circuitpython/ampy $ dmesg
[98691.837544] cdc_acm 1-1.4:1.0: failed to set dtr/rts
[98691.937608] usb 1-1.4: reset full-speed USB device number 100 using dwc_otg
[98692.070296] cdc_acm 1-1.4:1.0: ttyACM1: USB ACM device
[98692.074569] sd 0:0:0:0: [sda] 4089 512-byte logical blocks: (2.09 MB/2.00 MiB)
[98692.091618]  sda: sda1

Nothing special on the LEDs. With another tool I use for upload that checks the file timestamp before uploading, I sometimes get a new device name ttyACM2 after the usb reset:

[80063.522775] usb 1-1.4: reset full-speed USB device number 81 using dwc_otg
[80063.655651] cdc_acm 1-1.4:1.0: ttyACM2: USB ACM device
[80063.664710] sd 1:0:0:0: [sdc] 4089 512-byte logical blocks: (2.09 MB/2.00 MiB)
[80063.682308]  sdc: sdc1

Zero size file (since it’s not closed I suppose):

Adafruit CircuitPython 4.0.0-alpha.2-172-g0ea31ec15 on 2018-11-15; Adafruit Metro M4 Express with samd51j19
>>> os.stat('firmware.uf2')
(32768, 0, 0, 0, 0, 0, 0, 1542319926, 1542319926, 1542319926)

Working commit

Checkout commit beofre tinyusb PR:

git checkout d08747d374057b24803b429bbf6474a2e4dcea5c
<snip>
HEAD is now at d08747d37... Merge pull request #1319 from dhalbert/origin/arturo182_bleio_pr_1289

Did this 3 times without failure:

pi@cp:~/work/circuitpython/ampy $ python3 ampy/cli.py -p /dev/ttyACM1 put ../workdirs/test/circuitpython/ports/atmel-samd/build-metro_m4_express/firmware.uf2

ampy get (doesn’t support binary files?) didn’t work so I couldn’t check that the files are equal, but at least the size matches:

pi@cp:~/work/circuitpython/ampy $ ls -l ../workdirs/test/circuitpython/ports/atmel-samd/build-metro_m4_express/firmware.uf2
-rwxrwxrwx 1 root root 473600 Nov 15 22:06 ../workdirs/test/circuitpython/ports/atmel-samd/build-metro_m4_express/firmware.uf2

Adafruit CircuitPython 4.0.0-alpha.2-135-gd08747d37-dirty on 2018-11-15; Adafruit Metro M4 Express with samd51j19
>>> os.stat('firmware.uf2')
(32768, 0, 0, 0, 0, 0, 473600, 1542316836, 1542316836, 1542316836)

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 15 (8 by maintainers)

Most upvoted comments

USB trace attached, see packets 43978, thats where it ‘hangs’, and then 44064 is when it resets and reappears - MSD is back but CDC connection is gone

image

beagle trace.zip