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

Interrupt lock missing in debug log functions #2652

Open
HiFiPhile opened this issue May 18, 2024 · 2 comments · May be fixed by #2653
Open

Interrupt lock missing in debug log functions #2652

HiFiPhile opened this issue May 18, 2024 · 2 comments · May be fixed by #2653

Comments

@HiFiPhile
Copy link
Collaborator

HiFiPhile commented May 18, 2024

What happened ?

Interrupt lock need to be added to log functions, calling from ISR could enter deadlock mostly for serial logging. #2649

Options:

  • Remove all logging from ISR.
  • Defer ISR logging, should be difficult with va_args.
  • Add interrupt lock, but macros need to be reworked since we don't know if they are called from device or host or typec stack in order to toggle interrupt accordingly.
  • Add a simple re-entrancy flag to skip printf.

Edit:
I must have bad memory, I met log racing while debugging dwc2 DMA with RTT but SEGGER_RTT_Write() is ISR-safe, it must happened inside libc printf().

How to reproduce ?

Run examples on ports who has log in ISR, like NRF5x.

@tlyu
Copy link
Contributor

tlyu commented May 18, 2024

I haven't had trouble with deadlocks with RTT on nRF52, compared to the Arduino core's Serial1.

On the other hand, anything with Bluetooth (Bluefruit lib; haven't tried anything lower level yet) seems to cause trouble with segfaults during debugging, including RTT.

@HiFiPhile
Copy link
Collaborator Author

I haven't had trouble with deadlocks with RTT on nRF52

I think it depends on timing (luck), implementation side they don't have interrupt lock.
https://github.com/NordicSemiconductor/nrfx/blob/4620e7ccfebc08dbd4c039bc7d530b62c4c68ca8/drivers/src/nrfx_uarte.c#L871

@HiFiPhile HiFiPhile linked a pull request May 19, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants