rust-embedded-community / usb-device

Experimental device-side USB framework for microcontrollers in Rust.
MIT License
451 stars 76 forks source link

UsbBus constructor implementations can cause MCU faults in --debug run mode #112

Open ianrmhill opened 1 year ago

ianrmhill commented 1 year ago

When constructing a new UsbBus with usb-device 0.2.9 (atsamd21g implementation running on a SAMD21G17D without compile-time optimizations) fatal CPU errors can arise on the target device.

Likely this is due to stack overflow issues as it occurs while allocating a largish chunk of memory and may be a change more for the atsamd-hal/thumbv6m code that implements the UsbBus, but should check.

Some error and stack trace info: UsbBusATSAMD21G17DDebugInfo.txt

ryan-summers commented 1 year ago

Both myself and another Matrix user noted that our projects seemed to freeze up when calling UsbDevice.freeze(). We both were able to resolve it by updating the HAL that we were using to the latest version, and we had the suspicion that this was related to new cortex-m critical-section functionalities. We haven't investigated further, but I wanted to leave this breadcrumb.

This was specifically for STM32F4xx devices