nrf52840 usb stack halts after random amount of time #2165
Replies: 3 comments 1 reply
-
After some further testing with modified write function to this: void USB::write(uint8_t* data, int len) {
while (!tud_hid_ready()) {
delay(1);
}
// Serial.printf("sending usb data\n");
// for (int i = 0; i < len; i++) Serial.print(data[i], HEX);
// Serial.println();
if (tud_hid_report(0, data, len)) {
//Serial.println("SENT!");
}
else {
Serial.println("FAILED TO SEND!");
}
} I am getting absolutely spammed with |
Beta Was this translation helpful? Give feedback.
-
Moved to dicussion since there is too much of other code involving platform + integration. There is no easy way to verify if the bug comes from 3rd party code e.g incorrectly usage of API. You can try to narrow the issue by testing with one of the stock example with minimal changes. |
Beta Was this translation helpful? Give feedback.
-
As far as i can see, there is no similar example ie I based my code on: but it doesn't receive data at all and this is where the problem comes from, just sending data from mcu to pc works, when bidirectional transfers comes into play, issues starts to become visible EDIT: I got further with queues, by replacing entire usb device task with this: [[noreturn]] void usb_device_task(void* param) {
struct USBMessage usbTaskMessage = {};
// RTOS forever loop
while (true) {
tud_task();
if (tud_hid_ready() && xQueueReceive(usbQueue, &usbTaskMessage, 1) == pdPASS) {
tud_hid_report(0, usbTaskMessage.data, usbTaskMessage.len);
}
}
} However i still do not know what may cause this issue, perhaps tud_task is suppose to be executed synchronously with sending reports? |
Beta Was this translation helpful? Give feedback.
-
Operating System
Windows 10
Board
custom nrf52840
Firmware
Arduino n-able core
(I am NOT using their built in tinyusb)
I have made simple example repo with all the code necessary including test app (in nodejs, but anything that can send data to hid usb will do the trick)
https://github.com/kaminaris/tinyusb-nrf52
What happened ?
USB halts after a completely random period of time, causing it to not work at all until one of the apps gets restarted, seems like i am getting errors
usb not ready!
How to reproduce ?
testapp
npm i
, run app in directorytestapp
withnpm run start
oryarn start
Debug Log as txt file (LOG/CFG_TUSB_DEBUG=2)
USBD Setup Received 80 06 00 01 00 00 12 00
Get Descriptor Device
Queue EP 80 with 18 bytes ...
USBD Xfer Complete on EP 80 with 18 bytes
Queue EP 00 with 0 bytes ...
USBD Xfer Complete on EP 00 with 0 bytes
USBD Setup Received 00 09 01 00 00 00 00 00
Set Configuration
Open EP 81 with Size = 64
Open EP 01 with Size = 64
Queue EP 01 with 64 bytes ...
HID opened
Bind EP 81 to driver id 0
Bind EP 01 to driver id 0
USB Mounted
Queue EP 80 with 0 bytes ...
USBD Xfer Complete on EP 80 with 0 bytes
USB TICK! 3 1c034
USBD Setup Received 02 01 00 00 81 00 00 00
Clear Feature
HID control request
Queue EP 80 with 0 bytes ...
USBD Xfer Complete on EP 80 with 0 bytes
0d 0
USBD Xfer Complete on EP 01 with 63 bytes
HID xfer callback
got data 63
Queue EP 81 with 64 bytes ...
Queue EP 01 with 64 bytes ...
USBD Xfer Complete on EP 01 with 63 bytes
HID xfer callback
got data 63
usb not ready!
Queue EP 01 with 64 bytes ...
USBD Xfer Complete on EP 81 with 64 bytes
HID xfer callback
USBD Bus Reset : Full Speed
USBD Setup Received 80 06 00 01 00 00 40 00
Get Descriptor Device
Queue EP 80 with 18 bytes ...
USBD Xfer Complete on EP 80 with 18 bytes
Queue EP 00 with 0 bytes ...
USBD Xfer Complete on EP 00 with 0 bytes
USBD Bus Reset : Full Speed
USBD Setup Received 80 06 00 01 00 00 12 00
Get Descriptor Device
Queue EP 80 with 18 bytes ...
USBD Xfer Complete on EP 80 with 18 bytes
Queue EP 00 with 0 bytes ...
USBD Xfer Complete on EP 00 with 0 bytes
USBD Setup Received 00 09 01 00 00 00 00 00
Set Configuration
Open EP 81 with Size = 64
Open EP 01 with Size = 64
Queue EP 01 with 64 bytes ...
HID opened
Bind EP 81 to driver id 0
Bind EP 01 to driver id 0
USB Mounted
Queue EP 80 with 0 bytes ...
USBD Xfer Complete on EP 80 with 0 bytes
USBD Setup Received 02 01 00 00 81 00 00 00
Clear Feature
HID control request
Queue EP 80 with 0 bytes ...
USBD Xfer Complete on EP 80 with 0 bytes
USB TICK! 3 1c0340d 0
USBD Xfer Complete on EP 01 with 63 bytes
HID xfer callback
got data 63
Queue EP 81 with 64 bytes ...
Queue EP 01 with 64 bytes ...
USBD Xfer Complete on EP 81 with 64 bytes
HID xfer callback
USBD Bus Reset : Full Speed
USBD Setup Received 80 06 00 01 00 00 40 00
Get Descriptor Device
Queue EP 80 with 18 bytes ...
USBD Xfer Complete on EP 80 with 18 bytes
Queue EP 00 with 0 bytes ...
USBD Xfer Complete on EP 00 with 0 bytes
USBD Bus Reset : Full Speed
Screenshots
I have checked existing issues, dicussion and documentation
Beta Was this translation helpful? Give feedback.
All reactions