Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix control transfers on SAMD #80

Open
wants to merge 1 commit into
base: gh-pages
Choose a base branch
from
Open

Fix control transfers on SAMD #80

wants to merge 1 commit into from

Conversation

reillyeon
Copy link
Collaborator

On SAMD-based boards it appears that the entire control transfer reply
needs to be passed to USB_SendControl() at once. The original code took
advantage of making multiple calls to construct replies from smaller
chunks. This has been rewritten to construct and send the entire
responce at once.

Fixes #79.

On SAMD-based boards it appears that the entire control transfer reply
needs to be passed to USB_SendControl() at once. The original code took
advantage of making multiple calls to construct replies from smaller
chunks. This has been rewritten to construct and send the entire
responce at once.

Fixes #79.
@reillyeon
Copy link
Collaborator Author

@TedNIVAN, can you verify this fix on your SAMD board? I don't have an AVR board to test on at the moment. @jpliew, is there any chance you could give me a hand verifying this?

@TedNIVAN
Copy link

@TedNIVAN, can you verify this fix on your SAMD board? I don't have an AVR board to test on at the moment. @jpliew, is there any chance you could give me a hand verifying this?

@reillyeon Didn't work for me.

@reillyeon
Copy link
Collaborator Author

Thanks for checking. It looks like something else is broken here as well.

@TedNIVAN
Copy link

Alright. Please let me know if you managed to figure it out.

@gpelizzo
Copy link

gpelizzo commented Nov 27, 2020

Hi, let m know if I can help. I've few SAMD boards for testing. Cheers

@jpliew
Copy link
Contributor

jpliew commented Dec 28, 2020

Before this pull request I was also facing symptoms like #41, #60, #69

Tested this pull request with the following

  1. Windows 8.1 & 10, Linux
  2. Chrome Version 87.0.4280.88 (Official Build) (64-bit)
  3. ATmega32U4
  4. SAMD (Adafruit Feather M0 Express)

Tested all working fine.

This pull request should fix issue #41, #60, #69

I would like to suggest to have this pull request merged.

As for Android, this pull request works ok for the AVR (ATmega32U4) but not working for SAMD. In chrome://usb-internals Chrome can see the device, upon clicking Inspect the following screenshot shows the error

Screenshot_20201228-151425

@jpliew
Copy link
Contributor

jpliew commented Dec 28, 2020

@TedNIVAN could you explain what exactly you want to do with your app and webusb please? It will me much easier if you can explain your use case and proper recommendation can be provided. From your app fruity market, I am not able to see how it is used with a webusb device.

@jpliew
Copy link
Contributor

jpliew commented Jan 3, 2021

@reillyeon , I did a bit more digging on Android Chrome. Below are the logs, when clicking Get Device Configuration Descriptor on page chrome://usb-internals

My opinion is Android Chrome does not like the way Arduino SAMD's USBCore.cpp doing the _dry_run and _pack_message sending them all at once. 0x62 bytes (98 bytes) packet might have blown off the buffer already ??

Will you be able to check Android Chrome's (Version 87.0.4280.101) source why it behave differently than the desktop Chrome ?

SAMD When Clicking Get Configuration Descriptor

handleStandardSetup
        GET_DESCRIPTOR
                bmRequestType=  0x80
                bRequest=       0x6
                wValueL=        0x0
                wValueH=        0x1
                wIndex=         0x0
                wLength=        0x12
        PluggableUSB().getDescriptor=0
        USB_DEVICE_DESCRIPTOR_TYPE
                sendControl len=0x12
                12 01 10 02 EF 02 01 40 9A 23 1B 80 00 01 01 02 03 01
handleStandardSetup
        GET_DESCRIPTOR
                bmRequestType=  0x80
                bRequest=       0x6
                wValueL=        0x0
                wValueH=        0x2
                wIndex=         0x0
                wLength=        0x4
        USB_CONFIGURATION_DESCRIPTOR_TYPE
                sendControl len=0x42
        dry_run
                sendControl len=0x17
        dry_run
                sendControl len=0x9
        pack_message
                sendControl len=0x42
        pack_message
                sendControl len=0x17
        pack_message
                sendControl len=0x62
                09 02 62 00 03 01 00 A0 32 08 0B 00 02 02 02 00 00 09 04 00 00 01 02 02 00 00 05 24 00 10 01 04 24 02 06 05 24 06 00 01 05 24 01 01 01 07 05 81 03 10 00 10 09 04 01 00 02 0A 00 00 00 07 05 02 02 40 00 00 07 05 83 02 40 00 00 09 04 02 00 02 FF 00 00 00 07 05 04 02 40 00 00 07 05 85 02 40 00 00

ATMEGA34U4 When Clicking Get Configuration Descriptor

handleStandardSetup
        GET_DESCRIPTOR
                bmRequestType=  0x80
                bRequest=       0x6
                wValueL=        0x0
                wValueH=        0x2
                wIndex=         0x0
                wLength=        0x9
        USB_CONFIGURATION_DESCRIPTOR_TYPE
                sendControl len=0x42
                08 0B 00 02 02 02 01 00 09 04 00 00 01 02 02 00 00 05 24 00 10 01 05 24 01 01 01 04 24 02 06 05 24 06 00 01 07 05 81 03 10 00 40 09 04 01 00 02 0A 00 00 00 07 05 02 02 40 00 00 07 05 83 02 40 00 00
                sendControl len=0x17
                09 04 02 00 02 FF 00 00 00 07 05 04 02 40 00 00 07 05 85 02 40 00 00
                sendControl len=0x9
                09 02 62 00 03 01 00 A0 FA
                sendControl len=0x42
                08 0B 00 02 02 02 01 00 09 04 00 00 01 02 02 00 00 05 24 00 10 01 05 24 01 01 01 04 24 02 06 05 24 06 00 01 07 05 81 03 10 00 40 09 04 01 00 02 0A 00 00 00 07 05 02 02 40 00 00 07 05 83 02 40 00 00
                sendControl len=0x17
                09 04 02 00 02 FF 00 00 00 07 05 04 02 40 00 00 07 05 85 02 40 00 00
handleStandardSetup
        GET_DESCRIPTOR
                bmRequestType=  0x80
                bRequest=       0x6
                wValueL=        0x0
                wValueH=        0x2
                wIndex=         0x0
                wLength=        0x62
        USB_CONFIGURATION_DESCRIPTOR_TYPE
                sendControl len=0x42
                08 0B 00 02 02 02 01 00 09 04 00 00 01 02 02 00 00 05 24 00 10 01 05 24 01 01 01 04 24 02 06 05 24 06 00 01 07 05 81 03 10 00 40 09 04 01 00 02 0A 00 00 00 07 05 02 02 40 00 00 07 05 83 02 40 00 00
                sendControl len=0x17
                09 04 02 00 02 FF 00 00 00 07 05 04 02 40 00 00 07 05 85 02 40 00 00
                sendControl len=0x9
                09 02 62 00 03 01 00 A0 FA
                sendControl len=0x42
                08 0B 00 02 02 02 01 00 09 04 00 00 01 02 02 00 00 05 24 00 10 01 05 24 01 01 01 04 24 02 06 05 24 06 00 01 07 05 81 03 10 00 40 09 04 01 00 02 0A 00 00 00 07 05 02 02 40 00 00 07 05 83 02 40 00 00
                sendControl len=0x17
                09 04 02 00 02 FF 00 00 00 07 05 04 02 40 00 00 07 05 85 02 40 00 00

@Delonous
Copy link

Any updates on this? I seem to be running into the same above errors in the screenshot on desktop chrome. On both gh-pages and samd-fix.
Windows 10
Chrome 88.0.4324.182
MKR ZERO
Arduino SAMD Boards 1.8.9

@jpliew
Copy link
Contributor

jpliew commented Feb 18, 2021

@Delonous if you try the pull request, this fixes the SAMD issues on desktop.

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.

WebUSB on Android Smartphone
5 participants