You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Arch: allIssues that apply to all architecturesArea: DriversDrivers issuesOS: MacIssues related to MacOS (building system, etc)Type: BugSomething isn't working
for some configurations, it's possible for a system to use both of low-level up_putc and the uart (drivers/serial/serial.c) on the console.
for an example, printf(stdout) goes to the uart and syslog() goes to up_putc.
the uart uses a semaphore (dev->xmitsem) interlocked with the kernel critical section to deal with interrupts.
although how up_putc is implemented is device-specific, it usually disables interrupts, performs polling-based i/o, and then restores the interrupts.
unfortunately, with SMP, the latter sometimes can "consume" the hardware events which would otherwise have triggered tx interrupts, which the former might be waiting for. if it happens, the former can block forever.
i was mainly looking at the esp32 implementation. but other implementations look similar.
an obvious fix would be to wrap up_putc with the critical section. but i'm not feeling too happy with the approach.
@patacongo what do you think? I know this implementation exists since initial NuttX versions
up_putc was only added originally to get some very early output to assist in CPU bringup and analyzing assertions. That was about 17 or more years ago. It normally just printed things like ABCDEF to let you know where the power-up reset logic failed..
For some of the early CPUs, I had only LEDs and low level serial output to perform the entire bring-up. It is really amazing what you can do with very little if you have to.
up_putc was used in various other, less appropriate ways since... Such as getting interrupt level serial output.
Using serial output to support CPU bring-up with serial output is not so important with today's modern, cheap debuggers. Perhaps up_putc() could even just be removed.
@patacongo what do you think? I know this implementation exists since initial NuttX versions
up_putc was only added originally to get some very early output to assist in CPU bringup and analyzing assertions. That was about 17 or more years ago. It normally just printed things like ABCDEF to let you know where the power-up reset logic failed..
For some of the early CPUs, I had only LEDs and low level serial output to perform the entire bring-up. It is really amazing what you can do with very little if you have to.
up_putc was used in various other, less appropriate ways since... Such as getting interrupt level serial output.
Using serial output to support CPU bring-up with serial output is not so important with today's modern, cheap debuggers. Perhaps up_putc() could even just be removed.
it's still useful for early in the boot, where i guess it's fine. (maybe until we boot secondary CPUs.)
i guess we can avoid most of problematic cases by removing CONFIG_SYSLOG_DEFAULT. how do you think?
@yamt I agree! It still useful and we need to keep it. No idea why Syslog is using it by default, it could be an option, instead of default output channel
Arch: allIssues that apply to all architecturesArea: DriversDrivers issuesOS: MacIssues related to MacOS (building system, etc)Type: BugSomething isn't working
Activity
acassis commentedon Nov 6, 2024
@patacongo what do you think? I know this implementation exists since initial NuttX versions
patacongo commentedon Nov 7, 2024
up_putc was only added originally to get some very early output to assist in CPU bringup and analyzing assertions. That was about 17 or more years ago. It normally just printed things like ABCDEF to let you know where the power-up reset logic failed..
For some of the early CPUs, I had only LEDs and low level serial output to perform the entire bring-up. It is really amazing what you can do with very little if you have to.
up_putc was used in various other, less appropriate ways since... Such as getting interrupt level serial output.
Using serial output to support CPU bring-up with serial output is not so important with today's modern, cheap debuggers. Perhaps up_putc() could even just be removed.
esp32_serial.c: make up_putc take the critical section
esp32s3_serial.c: make up_putc take the critical section
yamt commentedon Nov 7, 2024
it's still useful for early in the boot, where i guess it's fine. (maybe until we boot secondary CPUs.)
i guess we can avoid most of problematic cases by removing CONFIG_SYSLOG_DEFAULT. how do you think?
acassis commentedon Nov 7, 2024
@yamt I agree! It still useful and we need to keep it. No idea why Syslog is using it by default, it could be an option, instead of default output channel
Disable SYSLOG_DEFAULT by default
SYSLOG_DEFAULT: wrap up_putc/up_nputs calls with critical section
SYSLOG_DEFAULT: wrap up_putc/up_nputs calls with critical section
esp32_serial.c: make up_putc take the critical section
esp32s3_serial.c: make up_putc take the critical section
Disable SYSLOG_DEFAULT by default
yamt commentedon Nov 19, 2024
i guess this was not really SMP-specific.
consider that:
#14761 should be enough to fix the case as well.
xiaoxiang781216 commentedon Nov 19, 2024
but is uart_write protected by the critical section too?
yamt commentedon Nov 19, 2024
i'm not sure what you meant. but a literal answer is "yes".
SYSLOG_DEFAULT: wrap up_putc/up_nputs calls with critical section
SYSLOG_DEFAULT: wrap up_putc/up_nputs calls with critical section
casaroli commentedon Nov 8, 2026
Possibly fixed by #14761.