Skip to content

Support defmt in Rust code on Zephyr #60

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

Open
d3zd3z opened this issue Feb 26, 2025 · 0 comments
Open

Support defmt in Rust code on Zephyr #60

d3zd3z opened this issue Feb 26, 2025 · 0 comments

Comments

@d3zd3z
Copy link
Collaborator

d3zd3z commented Feb 26, 2025

Currently, we support the Rust log frame work, which can send messages either through printk, or Zephyr's log framework. This certainly works, but it ends up bringing in the entire formatting framework on the Rust side (in addition to printk on the Zephyr side).

Many embedded projects in Rust use the defmt framework to log messages. This is a deferred logging framework that encodes the log messages in a binary format, where log strings are not included in the image, but referenced by index. A host-side tool reads this stream, and formats the messages. It reads the elf image, where the various string constants are placed in a section that is not in the image.

A common backend for defmt is to use a channel in RTT. Zephyr has RTT support, and also supports multiple channels. Rather that try to somehow combine these, the proposal here is to use a second channel to encode the defmt messages.

Implementing this requires implementing a backend for defmt. This will take the data passed in, and send using the Zephyr interface to RTT that already exists.

The defmt authors are open to patches that would allow it to receive messages from both the Zephyr log channel as well as the defmt channel. Without these patches, the defmt-print tool would be able to print the rust-side defmt messages, and something else, such as socat, could be used to view Zephyr logs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Development

No branches or pull requests

1 participant