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
logging: uart: support multiple instances #64917
Conversation
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.
Would be also good to add the chosen to docs
https://docs.zephyrproject.org/latest/build/dts/api/api.html#zephyr-specific-chosen-nodes
790999f
to
2beb974
Compare
Set the backend's context to its control block's context instead of NULL when doing `log_backend_enable`, as the log backend UART uses that later. Signed-off-by: Yong Cong Sin <ycsin@meta.com>
6886265
to
11748e7
Compare
/* | ||
* #if DT_NODE_HAS_COMPAT(DT_CHOSEN(zephyr_log_uart), zephyr_log_uart) | ||
* DT_FOREACH_PROP_ELEM_SEP(DT_CHOSEN(zephyr_log_uart), uarts, LBU_PHA_FN, ()); | ||
* #else | ||
* LBU_DEFINE(DT_CHOSEN(zephyr_log_uart), 0); | ||
* #endif | ||
*/ |
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.
|
||
/ { | ||
chosen { | ||
zephyr,log-uart = &log_uarts; |
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.
I think my preference would be either to use phandles property in the chosen node, or to simply use a child DT node under each UART selected to be a log backend.
However, the phandles approach does not seem to work for in the chosen node.
Personally, I think the chosen + node + phandles is kind of overkill.
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.
Alternatively, if it were possible to support a phandle array in chosen, that would be kind of ideal, but it might require some additional devicetree hacks.
Extends the log_backend_uart to support logging to multiple UART instances. Signed-off-by: Christopher Friedt <cfriedt@meta.com>
Add testcase for the multi-instance log backend uart using emulated uart. Signed-off-by: Yong Cong Sin <ycsin@meta.com>
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.
Can you do a build without these changes and with these changes (ARM cortex ideally) with 1 device and note the flash/RAM usage on both?
+1 to @nordicjm suggestion. I guess there will be increase so it would be good to wrap instance getting in some macro so that there is no code addition when 1 uart is used (99.99% of cases). |
Building
ROM reports:
|
main | PR | ||
---|---|---|---|
RAM | 122912 | 122912 | |
ROM | 56856 | 56864 | +8 |
char_out |
49 | 51 | +2 |
dropped |
16 | 22 | +6 |
format_set |
15 | 24 | +9 |
log_backend_uart |
16 | 16 | |
log_backend_uart_api |
28 | 28 | |
log_backend_uart_init |
1 | 21 | +20 |
log_const_log_uart |
8 | 8 | |
log_output_uart |
16 | 16 | |
panic |
23 | 29 | +6 |
process |
36 | 45 | +9 |
This PR, using zephyr,log-uart
, 2 instances
Path Size
=======================================
log_backend_uart.c 332
├── backend_cb_log_backend_uart0 8
├── backend_cb_log_backend_uart1 8
├── char_out 51
├── dropped 22
├── format_set 24
├── lbu_cb_ctx_0 12
├── lbu_cb_ctx_1 12
├── lbu_output_0 16
├── lbu_output_1 16
├── log_backend_uart0 16
├── log_backend_uart1 16
├── log_backend_uart_api 28
├── log_backend_uart_init 21
├── log_const_log_uart 8
├── panic 29
└── process 45
=======================================
log_backend_uart.c (RAM) 106
├── backend_cb_log_backend_uart0 8
├── backend_cb_log_backend_uart1 8
├── lbu_buffer_0 1
├── lbu_buffer_1 1
├── lbu_data_0 32
├── lbu_data_1 32
├── lbu_output_0_control_block 12
└── lbu_output_1_control_block 12
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.
Checked that for cortex-m and riscv32 overhead is even smaller. Looks ok for me.
Following zephyrproject-rtos#64917, the name of the UART log backend(s) are now defined to be `log_backend_uart##idx`, update the name used in the test to look for `log_backend_uart0`, which is the name of the UART logging backend when using the default `zephyr,console` node. Signed-off-by: Yong Cong Sin <ycsin@meta.com>
Extends the UART log backend to support multiple UART instances.
Building
samples/hello_world
withqemu_x86
using additional Kconfigs:ROM reports:
main
branchThis PR, using
zephyr,console
char_out
dropped
format_set
log_backend_uart
log_backend_uart_api
log_backend_uart_init
log_const_log_uart
log_output_uart
panic
process
This PR, using
zephyr,log-uart
, 2 instances