Skip to content

Conversation

@deadprogram
Copy link
Member

@deadprogram deadprogram commented Mar 31, 2020

This PR should correct the last issues for atsamd21 and atsamd51 USB CDC by sending a zero length packet when USB transfer is complete on endpoint 0.

This fix is 100% due to awesome research by @sago35 thank you very much!

@aykevl
Copy link
Member

aykevl commented Apr 1, 2020

I can confirm that this PR works for me (Linux kernel version 5.4) on both the Arduino Nano 33 IoT and the Adafruit Circuit Playground Bluefruit.

Unrelated: I noticed that for the CPB it gives an error:

error: failed to flash /tmp/tinygo446225229/main.uf2: rename /media/ayke/CPLAYBTBOOT/flash.uf2.tmp /media/ayke/CPLAYBTBOOT/flash.uf2: no such file or directory

It still works, but this (somewhat cosmetic) error should probably be fixed eventually.

@sago35
Copy link
Member

sago35 commented Apr 1, 2020

USB-CDC now works without adding sendZlp() in handleUSBIRQ().
But it's not yet known which changes are affecting them.
I've only fixed the code in SAMD51 (usb.go + machine_atsamd51.go).
Tested with pyportal (samd51) + windows10 only.

The changes are outlined below.

  • made to resemble the arduino source (github.com/adafruit/ArduinoCore-samd/cores/arduino/USB/USBCore.cpp)
    • Added usbPackMessage (probably unnecessary)
    • Fix handleStandardSetup().
    • Fix sendDescriptor()
  • ClearBits() and then SetBits() from SetBits().
  • Return Ack for Start of frame.
  • Removed sendZlp() in handleUSBIRQ().

I'm going to organize it tomorrow so that it's only a necessary change.
If possible, I would like you to check the operation on Linux, etc.
@deadprogram

sago35@22b4a22
sago35@7b03ada

…t again when sending

Signed-off-by: Ron Evans <ron@hybridgroup.com>
@deadprogram deadprogram force-pushed the bugfix/usb-cdc-zlp-trcpt branch from 8f09138 to d34b260 Compare April 1, 2020 18:15
Copy link
Member

@niaow niaow left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works for me!

@sago35
Copy link
Member

sago35 commented Apr 1, 2020

Works fine.

@deadprogram
Copy link
Member Author

This branch now appears good to merge.

@niaow niaow merged commit 5d539df into dev Apr 2, 2020
@aykevl aykevl deleted the bugfix/usb-cdc-zlp-trcpt branch April 2, 2020 21:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants