zephyrproject-rtos / zephyr

Primary Git Repository for the Zephyr Project. Zephyr is a new generation, scalable, optimized, secure RTOS for multiple hardware architectures.
https://docs.zephyrproject.org
Apache License 2.0
10.48k stars 6.41k forks source link

drivers: usb_dc_mcux: processing endpoint callbacks in ISR context causes assertion #40638

Closed ottojo closed 2 years ago

ottojo commented 2 years ago

Describe the bug When using USB networking, the driver accesses networking functions which lock mutexes from ISR context. This leads to failed assertion mutexes cannot be used inside ISRs..

To Reproduce (Working on providing a minimal example...)

Expected behavior Assertion should not fail, the interface should not be enabled from ISR context.

Impact The network interface seems to work, but this makes it impossible to me to use __ASSERT, since the program can't run with CONFIG_ASSERT enabled.

Logs and console output (WIP)

Environment (please complete the following information):

jfischer-no commented 2 years ago

@ottojo There is no workaround, USB_DeviceNotificationTrigger needs to be offloaded to a thread/workqueue.

danieldegrasse commented 2 years ago

@ottojo I can reproduce the error on a RT1064 EVK building the "echo_server" sample with the following command: west build -p always -b mimxrt1064_evk samples/net/sockets/echo_server -DOVERLAY_CONFIG=overlay-netusb.conf -DCONFIG_ETH_MCUX=n -DCONFIG_ASSERT=y. On my board, #42019 fixes the issue (per @jfischer-no's suggestion of offloading the ISR to a thread) can you verify that branch works for you?