This repo provides a crate with a Rust Logger implementation for use on an embedded device with Zephyr RTOS. bindgen
and cbindgen
are used to bind Rust calls to Zephyr RTOS's log2 implementation
Include this crate in another crate that needs a logger implementation and make the usual log macro calls like log::trace!("2.0 * 2.0 = {}", 2. * 2.);
. With a high initialization priority, the global logger is initialized to call the matching LOGDBG, LOGINF, LOGWRN, or LOGERR macro in the bridging C.
In order to build there are several tools to install
thumbv7em-none-eabihf
thumbv8m.main-none-eabihf
cargo install cargo-make,cbindgen
brew install llvm
llvm-config
needs to be in your PATH
echo 'export PATH="/opt/homebrew/opt/llvm/bin:$PATH"' >> ~/.zshrc
sudo xcode-select --install
If you have all of that, then cargo make test
should work.
In the example, we have a blinky
application compiled for NRF52 or NRF53. The CMakeLists.txt of the sample project adds logz as a static library, exposes the headers to sample app, and runs the build with cargo whenever you build.