-
Notifications
You must be signed in to change notification settings - Fork 594
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
Flusing log uart during fault #6660
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -512,6 +512,9 @@ static uart_dev_t g_uart4port = { | |
}; | ||
#endif | ||
|
||
#ifdef CONFIG_UART4_SERIAL_CONSOLE | ||
static bool g_log_flush_running; | ||
#endif | ||
/**************************************************************************** | ||
* Private Functions | ||
****************************************************************************/ | ||
|
@@ -573,7 +576,7 @@ static int rtl8730e_log_uart_irq(void *Data) | |
|
||
u32 txempty_en = LOGUART_GET_ETPFEI(IrqEn); | ||
if ((txempty_en == 0x4 && (reg_lsr & LOGUART_BIT_TP4F_EMPTY)) || (reg_lsr & LOGUART_BIT_TP4F_NOT_FULL)) { | ||
uart_xmitchars(&CONSOLE_DEV); | ||
(void)uart_xmitchars(&CONSOLE_DEV); | ||
} | ||
return 0; | ||
} | ||
|
@@ -921,7 +924,7 @@ void rtl8730e_uart_irq(uint32_t id, SerialIrq event) | |
} | ||
if (event == TxIrq) { | ||
priv->tx_level = TX_FIFO_MAX; | ||
uart_xmitchars(dev); | ||
(void)uart_xmitchars(dev); | ||
priv->tx_level = 0; | ||
} | ||
} | ||
|
@@ -1377,6 +1380,44 @@ int up_getc(void) | |
return ch; | ||
} | ||
|
||
/**************************************************************************** | ||
* Name: up_flush_console | ||
* | ||
* Description: | ||
* This function is used to ensure that all characters in the UART buffer | ||
* are transmitted. | ||
* | ||
* Input Parameters: | ||
* None | ||
* | ||
* Returned Value: | ||
* None | ||
* | ||
****************************************************************************/ | ||
void up_flush_console(void) | ||
{ | ||
#ifdef CONFIG_UART4_SERIAL_CONSOLE | ||
uint16_t nbyte; | ||
irqstate_t flags = enter_critical_section(); | ||
|
||
/* To avoid duplicated calling up_flush_console(). */ | ||
if (g_log_flush_running) { | ||
leave_critical_section(flags); | ||
return; | ||
} | ||
g_log_flush_running = true; | ||
|
||
do { | ||
while (!LOGUART_Ready()); | ||
nbyte = uart_xmitchars(&CONSOLE_DEV); | ||
} while (nbyte); | ||
Comment on lines
+1410
to
+1413
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How does this work? Currently it looks like we still rely on uart interrupts to send data. But interrupts are disabled. Wont it be better to use lldbg path instead? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The IRQ is calling uart_xmitchars() There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I meant uart_xmitchars path is through drivers (will call the drivers send function and it also has some signalling logic to wakeup other threads), but at this point, we are no longer using the driver's path to print logs. Instead we use lldbg, so I asked the above question, why not use up_putc instead of driver send. |
||
|
||
g_log_flush_running = false; | ||
|
||
leave_critical_section(flags); | ||
#endif | ||
} | ||
|
||
#else /* USE_SERIALDRIVER */ | ||
/**************************************************************************** | ||
* Name: up_putc | ||
|
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.
we should have leave_critical_section here.
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.
Thank you, Updated!