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

NRF52840: usb composite MSC + HID (with CONFIG_ENABLE_HID_INT_OUT_EP) #15507

Closed
dmazzella opened this issue Apr 17, 2019 · 22 comments · Fixed by #15646
Closed

NRF52840: usb composite MSC + HID (with CONFIG_ENABLE_HID_INT_OUT_EP) #15507

dmazzella opened this issue Apr 17, 2019 · 22 comments · Fixed by #15646
Assignees
Labels
area: USB Universal Serial Bus bug The issue is a bug, or the PR is fixing a bug platform: nRF Nordic nRFx priority: medium Medium impact/importance bug

Comments

@dmazzella
Copy link

Describe the bug
Composite usb device MSC + HID does not work on Windows, the device does not complete the installation.
MSC can be either configured with either one of CONFIG_DISK_ACCESS_RAM or CONFIG_DISK_ACCESS_FLASH, HID has CONFIG_ENABLE_HID_INT_OUT_EP=y

To Reproduce

  1. git clone https://github.com/dmazzella/zephyr.git
  2. cd zephyr/samples/subsys/usb/hid_w_out_ep-mass/
  3. mkdir build && cd build
  4. cmake -GNinja -DBOARD=nrf52840_pca10059 ..
  5. ninja
  6. flash zephyr.hex with Nrf Connect -> Programmer

Expected behavior
After writing the firmware using nRF Connect Programmer, I expect a composite MSC + HID device (PCA10059) to be properly recognized.
This is the case on Linux and macOS but on Windows 10 the USB composite device appears as unknown device.

Impact
Showstopper.

Screenshots or console output
56220817-6000ab80-6069-11e9-94cd-1c83c5b6e534
56220810-5d05bb00-6069-11e9-9e10-9b1e2b9f8410

Environment (please complete the following information):

  • OS:
    • Built on Windows 10 WSL, uname output Linux dma-pc 4.4.0-17763-Microsoft #379-Microsoft x86_64 x86_64 x86_64 GNU/Linux
    • Tested on Windows 10 - Version 1809 (build SO 17763.437)
  • Toolchain:
    • Zephyr version: 1.14.99
  • Commit SHA or Version used:
    • zephyrproject-rtos/zephyr 47b7c79

Additional context
I can try only with NRF52840 PCA10059

@dmazzella dmazzella added the bug The issue is a bug, or the PR is fixing a bug label Apr 17, 2019
@anddam
Copy link

anddam commented Apr 17, 2019

I figure #15486 can be closed now.

@masz-nordic masz-nordic added the area: USB Universal Serial Bus label Apr 17, 2019
@finikorg
Copy link
Collaborator

finikorg commented Apr 17, 2019

I tested on reel_board sample samples/subsys/usb/hid with enabled MSC, works fine. Does it work for you?

@dmazzella
Copy link
Author

yes, it work. The problem is triggered by enabling CONFIG_ENABLE_HID_INT_OUT_EP=y

@finikorg
Copy link
Collaborator

yes, it work. The problem is triggered by enabling CONFIG_ENABLE_HID_INT_OUT_EP=y

It works for me on reel_board with enabled CONFIG_ENABLE_HID_INT_OUT_EP=y

@dmazzella
Copy link
Author

can you please paste your .conf used for test?

this is mine for nrf52840_pca10059 with sample samples/subsys/usb/hid

CONFIG_USB=y
CONFIG_USB_DEVICE_STACK=y
CONFIG_USB_COMPOSITE_DEVICE=y
CONFIG_USB_DEVICE_HID=y
CONFIG_ENABLE_HID_INT_OUT_EP=y
CONFIG_USB_DEVICE_PRODUCT="Zephyr HID sample"
CONFIG_USB_HID_BOOT_PROTOCOL=y

CONFIG_USB_MASS_STORAGE=y
CONFIG_USB_MASS_STORAGE_LOG_LEVEL_ERR=y
CONFIG_DISK_ACCESS_RAM=y
CONFIG_MASS_STORAGE_DISK_NAME="RAM"

CONFIG_LOG=y
CONFIG_USB_DRIVER_LOG_LEVEL_ERR=y
CONFIG_USB_DEVICE_LOG_LEVEL_ERR=y

without CONFIG_ENABLE_HID_INT_OUT_EP=y work fine for me.

@dmazzella
Copy link
Author

@finikorg @masz-nordic none of you have the chance to try with nrf52840_pca10059?

@masz-nordic
Copy link
Collaborator

I was able to reproduce with nrf52840_pca10059.
GET_DESCRIPTOR(Configuration) gets stalled. Its size is 64 bytes (which is equal to the size of an IN transaction). Probably a zero length packet should be added.

@dmazzella
Copy link
Author

@masz-nordic can i try something?

@finikorg
Copy link
Collaborator

@dmazzella to verify that issue @masz-nordic mentioned you can add another HID, it will increase descriptor table.

@dmazzella
Copy link
Author

@masz-nordic @finikorg I tried adding another HID and the device on Windows works as expected.
Is a fix without adding a second HID possible?

@finikorg finikorg added the platform: nRF Nordic nRFx label Apr 20, 2019
@finikorg
Copy link
Collaborator

@masz-nordic @finikorg I tried adding another HID and the device on Windows works as expected.
Is a fix without adding a second HID possible?

This should be fixed for the board device controller, I think this is serious issue, since all control packets multiple of 64 bytes fails, according to this finding.

@dmazzella
Copy link
Author

dmazzella commented Apr 28, 2019

@finikorg i have tried with commit d44086d and now on macOS I have this error:

MBP-di-Damiano:~$ sudo dmesg
Command 0x1100 completed. inCount: 2 data:0x0Command 0x2 completed. inCount: 2 data:0x4Command 0x1 completed. inCount: 2 data:0x1101Command 0x16 completed. inCount: 2 data:0xc0Command 0xa completed. inCount: 2 data:0xfc35Command 0xb completed. inCount: 2 data:0xfba4Command 0x12 completed. inCount: 2 data:0x5bCommand 0x13 completed. inCount: 2 data:0xffffCommand 0xf completed. inCount: 2 data:0x698Command 0x10 completed. inCount: 2 data:0x13d5SmartBattery: finished polling type 4
USBMSC Identifier (non-unique): ABCDEF012345 0x2fe3 0x100 0x11, 1
Report bytes: input:2 output:2 feature:1Collections : 2Buttons     : input:0 output:0 feature:0Values      : input:1 output:1 feature:0Element value capacity 96Report count: 3Report ID: 0 input:0 output:0 feature:0Report ID: 1 input:16 output:8 feature:8Report ID: 2 input:8 output:16 feature:8USB device 2FE3010014300000 - will be reset!
005288.316806 IOUSBHostHIDDevice: IOUSBHostHIDDevice::interruptReadComplete: IO error 0xe00002ed, 9 retries remaining
005290.163284 AppleUSBHostCompositeDevice@: AppleUSBHostCompositeDevice::ConfigureDevice: unable to set a configuration (0xe0005000)
USB device 2FE3010014300000 - failed to re-instantiate!
USB device 2FE3010014300000 - USB Mass Storage stack will be terminated!
USB device 2FE3010014300000 - fConsecutiveResetCount = 1.
MBP-di-Damiano:~$

with nrf52840_pca10059 with sample samples/subsys/usb/hid my .conf:

CONFIG_USB=y
CONFIG_USB_DEVICE_STACK=y
CONFIG_USB_COMPOSITE_DEVICE=y
CONFIG_USB_DEVICE_HID=y
CONFIG_ENABLE_HID_INT_OUT_EP=y
CONFIG_USB_DEVICE_PRODUCT="Zephyr HID sample"
CONFIG_USB_HID_BOOT_PROTOCOL=y

CONFIG_USB_MASS_STORAGE=y
CONFIG_USB_MASS_STORAGE_LOG_LEVEL_ERR=y
CONFIG_DISK_ACCESS_RAM=y
CONFIG_MASS_STORAGE_DISK_NAME="RAM"

CONFIG_LOG=y
CONFIG_USB_DRIVER_LOG_LEVEL_ERR=y
CONFIG_USB_DEVICE_LOG_LEVEL_ERR=y

@dmazzella
Copy link
Author

@finikorg nrf52840_pca10059 with sample samples/subsys/usb/mass my .conf:

CONFIG_STDOUT_CONSOLE=y
CONFIG_GPIO=y
CONFIG_USB=y
CONFIG_USB_DEVICE_STACK=y
CONFIG_USB_DEVICE_PRODUCT="Zephyr MSC sample"
CONFIG_LOG=y
CONFIG_USB_DRIVER_LOG_LEVEL_ERR=y
CONFIG_USB_MASS_STORAGE=y
CONFIG_USB_DEVICE_LOG_LEVEL_ERR=y
CONFIG_USB_MASS_STORAGE_LOG_LEVEL_ERR=y
CONFIG_DISK_ACCESS_RAM=y
CONFIG_MASS_STORAGE_DISK_NAME="RAM"

error:

MBP-di-Damiano:~$ sudo dmesg
USBMSC Identifier (non-unique): ABCDEF012345 0x2fe3 0x100 0x11, 1
USB device 2FE3010014300000 - will be reset!
006311.172343 AppleUSBHostCompositeDevice@: AppleUSBHostCompositeDevice::ConfigureDevice: unable to set a configuration (0xe0005000)
USB device 2FE3010014300000 - failed to re-instantiate!
USB device 2FE3010014300000 - USB Mass Storage stack will be terminated!
USB device 2FE3010014300000 - fConsecutiveResetCount = 1.
MBP-di-Damiano:~$ 

@finikorg
Copy link
Collaborator

@dmazzella So does it work in Windows?

@dmazzella
Copy link
Author

dmazzella commented Apr 29, 2019

@dmazzella So does it work in Windows?

samples/subsys/usb/mass with conf:

CONFIG_STDOUT_CONSOLE=y
CONFIG_GPIO=y
CONFIG_USB=y
CONFIG_USB_DEVICE_STACK=y
CONFIG_USB_DEVICE_PRODUCT="Zephyr MSC sample"
CONFIG_LOG=y
CONFIG_USB_DRIVER_LOG_LEVEL_ERR=y
CONFIG_USB_MASS_STORAGE=y
CONFIG_USB_DEVICE_LOG_LEVEL_ERR=y
CONFIG_USB_MASS_STORAGE_LOG_LEVEL_ERR=y
CONFIG_DISK_ACCESS_RAM=y
CONFIG_MASS_STORAGE_DISK_NAME="RAM"

YES

samples/subsys/usb/hid with conf:

CONFIG_USB=y
CONFIG_USB_DEVICE_STACK=y
CONFIG_USB_COMPOSITE_DEVICE=y
CONFIG_USB_DEVICE_HID=y
CONFIG_ENABLE_HID_INT_OUT_EP=y
CONFIG_USB_DEVICE_PRODUCT="Zephyr HID sample"
CONFIG_USB_HID_BOOT_PROTOCOL=y

CONFIG_USB_MASS_STORAGE=y
CONFIG_USB_MASS_STORAGE_LOG_LEVEL_ERR=y
CONFIG_DISK_ACCESS_RAM=y
CONFIG_MASS_STORAGE_DISK_NAME="RAM"

CONFIG_LOG=y
CONFIG_USB_DRIVER_LOG_LEVEL_ERR=y
CONFIG_USB_DEVICE_LOG_LEVEL_ERR=y

YES

@dmazzella
Copy link
Author

dmazzella commented Apr 30, 2019

@finikorg nrf52840_pca10059 with samples samples/subsys/usb/cdc_acm and samples/subsys/usb/cdc_acm_composite they don't work anymore on Windows, MacOS and Linux.

The COM port (on Windows) ttyACM0 (on Linux) is accessible but i can't see ouput.

on Linux:

[13651.218439] perf: interrupt took too long (3201 > 3192), lowering kernel.perf_event_max_sample_rate to 62250
[13934.173344] usb 1-10: new full-speed USB device number 10 using xhci_hcd
[13934.324811] usb 1-10: New USB device found, idVendor=2fe3, idProduct=0100
[13934.324817] usb 1-10: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[13934.324822] usb 1-10: Product: Zephyr CDC ACM sample
[13934.324826] usb 1-10: Manufacturer: ZEPHYR
[13934.324829] usb 1-10: SerialNumber: 0.01
[13934.365212] cdc_acm 1-10:1.0: ttyACM0: USB ACM device
[13934.365976] usbcore: registered new interface driver cdc_acm
[13934.365976] cdc_acm: USB Abstract Control Model driver for USB modems and ISDN adapters

ada@ada-pc ~ sudo picocom -b 115200 /dev/ttyACM0
picocom v2.2

port is        : /dev/ttyACM0
flowcontrol    : none
baudrate is    : 115200
parity is      : none
databits are   : 8
stopbits are   : 1
escape is      : C-a
local echo is  : no
noinit is      : no
noreset is     : no
nolock is      : no
send_cmd is    : sz -vv
receive_cmd is : rz -vv -E
imap is        : 
omap is        : 
emap is        : crcrlf,delbs,

Type [C-a] [C-h] to see available commands

Terminal ready

Thanks for using picocom
ada@ada-pc ~


@finikorg
Copy link
Collaborator

--- a/subsys/usb/usb_descriptor.h
+++ b/subsys/usb/usb_descriptor.h
@@ -34,8 +34,8 @@
 #define USB_STRING_DESCRIPTOR_LENGTH(s)        (sizeof(s) * 2)
 
 /* Automatic endpoint assignment */
-#define AUTO_EP_IN                     0x81
-#define AUTO_EP_OUT                    0x01
+#define AUTO_EP_IN                     0x80
+#define AUTO_EP_OUT                    0x00

Does this help?

@dmazzella
Copy link
Author

--- a/subsys/usb/usb_descriptor.h
+++ b/subsys/usb/usb_descriptor.h
@@ -34,8 +34,8 @@
#define USB_STRING_DESCRIPTOR_LENGTH(s) (sizeof(s) * 2)

/* Automatic endpoint assignment */
-#define AUTO_EP_IN 0x81
-#define AUTO_EP_OUT 0x01
+#define AUTO_EP_IN 0x80
+#define AUTO_EP_OUT 0x00

Does this help?

Yes now work correctly

@dmazzella
Copy link
Author

dmazzella commented Apr 30, 2019

@finikorg sorry if I said that now it works without having tested on all three operative systems.

  • Windows: work correctly
  • MacOS:
    • samples/subsys/usb/mass: still does not work
    • samples/subsys/usb/cdc_acm: work correctly
    • samples/subsys/usb/cdc_acm_composite: work correctly
    • samples/subsys/usb/hid-cdc: work correctly
  • Linux: untested

@dmazzella
Copy link
Author

@finikorg @masz-nordic any progress on this issue?

@finikorg
Copy link
Collaborator

finikorg commented May 7, 2019

@finikorg @masz-nordic any progress on this issue?

@dmazzella So what is the issue now? samples/subsys/usb/mass does not work on Mac? In all configurations or only with OUT_EP?

@dmazzella
Copy link
Author

@finikorg samples/subsys/usb/mass does not work on Mac in all configurations.

i have used nrf52840_pca10059 with .conf:

CONFIG_STDOUT_CONSOLE=y
CONFIG_GPIO=y
CONFIG_USB=y
CONFIG_USB_DEVICE_STACK=y
CONFIG_USB_DEVICE_PRODUCT="Zephyr MSC sample"
CONFIG_LOG=y
CONFIG_USB_DRIVER_LOG_LEVEL_ERR=y
CONFIG_USB_MASS_STORAGE=y
CONFIG_USB_DEVICE_LOG_LEVEL_ERR=y
CONFIG_USB_MASS_STORAGE_LOG_LEVEL_ERR=y
CONFIG_DISK_ACCESS_RAM=y
CONFIG_MASS_STORAGE_DISK_NAME="RAM"
MBP-di-Damiano:~$ sudo dmesg
USBMSC Identifier (non-unique): ABCDEF012345 0x2fe3 0x100 0x11, 1
USB device 2FE3010014400000 - will be reset!
000397.390821 AppleUSBHostCompositeDevice@: AppleUSBHostCompositeDevice::ConfigureDevice: unable to set a configuration (0xe0005000)
USB device 2FE3010014400000 - failed to re-instantiate!
USB device 2FE3010014400000 - USB Mass Storage stack will be terminated!
USB device 2FE3010014400000 - fConsecutiveResetCount = 1.
MBP-di-Damiano:~$ sudo dmesg

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: USB Universal Serial Bus bug The issue is a bug, or the PR is fixing a bug platform: nRF Nordic nRFx priority: medium Medium impact/importance bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants