-
Notifications
You must be signed in to change notification settings - Fork 3k
NRF52: serial_api: Use polling for putc #8048
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
NRF52: serial_api: Use polling for putc #8048
Conversation
There are scenarios where putc is called within a critical section, e.g to log ASSERTs in early initialization code. The interrupts being disabled here prevents the handlers for the UARTE from executing. This breaks the tx_in_progress flag based approach. The tx_in_progress never gets reset. Poll on the TXDRDY instead. It can be recreated with a simple program as shown here: *************** Current Behavior **************** ++ MbedOS Error Info ++ Error Status: 0x80FF0100 Code: 256 Module: 255 Error Message: F ************** With Fix ************************* ++ MbedOS Error Info ++ Error Status: 0x80FF0100 Code: 256 Module: 255 Error Message: Fatal Run-time error Location: 0x2C0A9 Error Value: 0x0 Current Thread: Id: 0x20005520 Entry: 0x30EBF StackSize: 0x1000 StackMem: 0x20004520 SP: 0x20005490 For more info, visit: https://armmbed.github.io/mbedos-error/?error=0x80FF0100 -- MbedOS Error Info -- nrf failure at .\main.cpp:22 ***************************************************
This change allows the sleep profiler to work... otherwise it will hang as it tries to do a print in a critical section as discussed here: #8084 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Adding @marcuschangarm since he worked on a lot of this code.
/morph build |
Build : SUCCESSBuild number : 3197 Triggering tests/morph test |
Exporter Build : SUCCESSBuild number : 2789 |
Test : SUCCESSBuild number : 2997 |
… occasional "serial port stuck" issue.
There are scenarios where putc is called within a critical section, e.g
to log ASSERTs in early initialization code. The interrupts being
disabled here prevents the handlers for the UARTE from executing.
This breaks the tx_in_progress flag based approach. The tx_in_progress
never gets reset. Poll on the TXDRDY instead.
It can be recreated with a simple program as shown here: https://goo.gl/kLiAQF
*************** Current Behavior ****************
++ MbedOS Error Info ++
Error Status: 0x80FF0100 Code: 256 Module: 255
Error Message: F
************** With Fix *************************
++ MbedOS Error Info ++
Error Status: 0x80FF0100 Code: 256 Module: 255
Error Message: Fatal Run-time error
Location: 0x2C0A9
Error Value: 0x0
Current Thread: Id: 0x20005520 Entry: 0x30EBF StackSize: 0x1000 StackMem: 0x20004520 SP: 0x20005490
For more info, visit: https://armmbed.github.io/mbedos-error/?error=0x80FF0100
-- MbedOS Error Info --
nrf failure at .\main.cpp:22
Description
When in a critical section, the interrupts are disabled and hence the tx_in_progress will never get cleared
leading to an infinite wait.
Pull request type
Fix UART TX that is based on tx_in_progress variable. This may not get reset when in critical section.
Hence use polling.