Linking Zephyr logging to UART powerdown #52902
Unanswered
allard-potma
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
This is a crosspost with the Nordic devzone, as I did not get a satisfactory answer there.
During the testing phase of my device I use the Zephyr (uart) logging module and the Zephyr shell module(CONFIG_SHELL_LOG_BACKEND=y). Shell is mostly disabled, and is enabled by placing a jumper. Because the device is battery powered the UART needs to be disabled when there is nothing to log(and shell jumper is not placed). Now I'm trying to link the Zephyr log system to UART powerdown. When the log module receives a log message it should disable powerdown of the UART. When the log module has processed the last log message, and the UART is done sending it, the UART powerdown should be enabled.
My first attempt was to link LTE_LC_EVT_MODEM_SLEEP_EXIT and LTE_LC_EVT_MODEM_SLEEP_ENTER to UART powerdown with pm_device_action_run. This works but leads to missing logs, as the modem sleep is not synced to the log module.
Second attempt was to write my own log processing thread (CONFIG_LOG_PROCESS_THREAD=y). I copied the one in log_core.c and added my UART powerdown code. This worked, but only polling, which is not good for the low power requirement. The semaphore that is supposed to release when a new log message is received is only usable when the processing thread from log_core.c is used(?). When using a custom thread the required timer is never initialized(log_process_thread_timer).
Third attempt was to add a custom log backend(LOG_BACKEND_DEFINE). Idea was to disable powerdown on the first call to the process function, and re-enable upon receiving the LOG_BACKEND_EVT_PROCESS_THREAD_DONE event. This did not work because it seems that my custom backend seems to override the shell log backend, although Zephyr should support multiple backends.
Another thing I may try is to override the shell_log_backend.c file with a custom one local to my project. This would require some CMake magic that I do not master.
Any suggestions on how to do this?
Beta Was this translation helpful? Give feedback.
All reactions