defmt VS avr-hal

Compare defmt vs avr-hal and see what are their differences.

defmt

Efficient, deferred formatting for logging on embedded systems (by knurling-rs)

avr-hal

embedded-hal abstractions for AVR microcontrollers (by Rahix)
Our great sponsors
  • WorkOS - The modern identity platform for B2B SaaS
  • InfluxDB - Power Real-Time Data Analytics at Scale
  • SaaSHub - Software Alternatives and Reviews
defmt avr-hal
17 30
713 1,188
5.0% -
8.8 8.8
8 days ago 5 days ago
Rust Rust
Apache License 2.0 Apache License 2.0
The number of mentions indicates the total number of mentions that we've tracked plus the number of user suggested alternatives.
Stars - the number of stars that a project has on GitHub. Growth - month over month growth in stars.
Activity is a relative number indicating how actively a project is being developed. Recent commits have higher weight than older ones.
For example, an activity of 9.0 indicates that a project is amongst the top 10% of the most actively developed projects that we are tracking.

defmt

Posts with mentions or reviews of defmt. We have used some of these posts to build our list of alternatives and similar projects. The last one was on 2023-07-31.
  • I built a column staggered keyboard with firmware written in Rust!
    5 projects | /r/rust | 31 Jul 2023
    As someone who had only done embedded programming in the Arduino IDE, utilizing the defmt crate for logging with OpenOCD and GDB was an amazing experience. Although I still had no idea on to implement USB-HID for actually sending the key reports, until I discovered the usbd-human-interface-device crate and everything became so much easier. I just needed to create an iterator over Keyboard events and the crate would handle the rest as an added benefit the crate also supports multiple devices, so adding mouse support was as easy as creating a separate iterator over WheelMouseReport.
  • Testing a no_std crate with QEMU and defmt-test?
    1 project | /r/rust | 16 Jun 2023
    I think I want to use the QEMU emulator (as suggested in the Embedded Rust Book) and tests created with defmt-test. But I can't figure out how to get them to work together.
  • Are there any `no_std` logging or printing libraries (for Wasm targets, or even embedded devices)
    1 project | /r/rust | 12 Apr 2023
    On embeded defmt is often used https://github.com/knurling-rs/defmt
  • Debugging and profiling embedded applications.
    8 projects | /r/rust | 30 Mar 2023
    defmt is a great framework for general logging.
  • Print From a Multi-Platform no_std Embedded Library
    1 project | /r/rust | 18 Jan 2023
  • Native Reflection in Rust
    2 projects | news.ycombinator.com | 15 Dec 2022
    Great writeup! The defmt logging crate uses a linker script to extract debug symbols so that you get nicely formatted stack traces on embedded systems. It works on linux, macos and windows. I wonder if the same technique can be applied to this project. It needs a runner though so may not be the right approach.

    https://github.com/knurling-rs/defmt

  • Smallest logging implementation?
    2 projects | /r/rust | 4 Nov 2022
  • From arduino to rust via avr-hal
    2 projects | /r/rust | 16 Oct 2022
    Just played with embedded stuff today. defmt can be used for logging instead of println since there's not really a stdout when running on bare metal.
  • Are costly debuggers from vendors necessary?
    1 project | /r/embedded | 22 Jun 2022
    yYeah. For example, instead of printf("Variable X = %d, y=%f", x, y), where the micro then formats the string and pushes it out a serial port, blocking until its sent, I can write LOG("Variable X = %d, Y=%f, x, y), and what actually happens is a unique pointer to the string, and a tagged raw int and float get pushed onto a buffer, which takes about 15 instructions and takes up 16 bytes in the buffer. The buffer is then asynchronously sent out over the serial port, and the PC knows how to map the string ID to the actual string (this can by dynamically fetched from the micro or stored like debug info if there's not enough flash for the strings), and applies the formatting. There's an added bonus that it's super easy to take any variable which is logged and plot it live over time. There's also stuff like if the system crashes and the watchdog resets it, the buffer can be read out from memory to catch anything which wasn't sent out yet. It's a bit more of a complex system to set up but it really makes printf feel like the stone age when you get to using it. For an example of a similar system in rust, https://github.com/knurling-rs/defmt is implementing the same ideas (I don't know of any publicly available equivalent in C or C++, but you can implement it the same, though C++ is easier and it helps to know your way around a linker script to make something properly ergonomic).
  • Creating formatted strings with no_std on embedded
    1 project | /r/rust | 1 May 2022
    If the build constraints are amenable for your project, you might also enjoy knurling-rs' defmt logging framework.

avr-hal

Posts with mentions or reviews of avr-hal. We have used some of these posts to build our list of alternatives and similar projects. The last one was on 2023-07-04.
  • Arduino Uno issue with interfacing with a dht11 sensor.
    4 projects | /r/rust | 4 Jul 2023
    /* * For examples (and inspiration), head to * * https://github.com/Rahix/avr-hal/tree/main/examples * * NOTE: Not all examples were ported to all boards! There is a good chance though, that code * for a different board can be adapted for yours. The Arduino Uno currently has the most * examples available. */ #![no_std] #![no_main] use dht_sensor::*; use panic_halt as _; #[arduino_hal::entry] fn main() -> ! { let dp = arduino_hal::Peripherals::take().unwrap(); let pins = arduino_hal::pins!(dp); let mut serial = arduino_hal::default_serial!(dp, pins, 57200); let mut pin3 = pins.d3.into_opendrain_high(); let mut delay = arduino_hal::Delay::new(); ufmt::uwriteln!(serial, "{}", "waiting for sensor...").unwrap(); arduino_hal::delay_ms(2000); loop { match dht11::Reading::read(&mut delay, &mut pin3) { Ok(dht11::Reading { temperature, relative_humidity, }) => ufmt::uwriteln!(serial, "{}°, {}% RH", temperature, relative_humidity).unwrap(), Err(_e) => ufmt::uwriteln!(serial, "Error {}", "Unable to read").unwrap(), } arduino_hal::delay_ms(2000); } }
  • What are the scenarios where "Rewrite it in Rust" didn't meet your expectations or couldn't be successfully implemented?
    16 projects | /r/rust | 9 Jun 2023
    I found the generics a lot less of a problem when I realized I could parametrize on things like embedded_hal::serial::Write instead of UsartOps https://github.com/Rahix/avr-hal/pull/264/commits/17ed15321cb8fcf8aedb1f8133be1f189eb06a6f
  • not entirely new to rust, but very new to rust+arduino,.... eli5 the differences between these projects?
    2 projects | /r/rust | 12 Jan 2023
    I've come across avr-rust, avr-hal and both seem to have arduino stuff, wondering which is the most beginner friendly? (I have a bit of experience with the regular arduino IDE but want to switch over to doing all the stuff in rust for a challenge)
  • Hey Rustaceans! Got a question? Ask here (1/2023)!
    11 projects | /r/rust | 3 Jan 2023
    fyi, a minor follow-up at https://github.com/Rahix/avr-hal/issues/388
  • Rust and arduino?
    2 projects | /r/rust | 12 Dec 2022
    I have contributed a little to this. avr-hal I have done a couple little hobby projects with it as well, but I can't say it's the best thing out there.
  • Learning Embedded rust
    7 projects | /r/rust | 18 Nov 2022
    All you need is in the documentation: https://rahix.github.io/avr-hal/arduino_hal/index.html even though reading the documentation without knowing what you're looking for can be quite difficult, so looking at some examples might be more helpful.
  • Five simple steps to use any Arduino C++ library in a Rust project 🦀
    11 projects | dev.to | 13 Nov 2022
    Rust language shares all advantages of efficient C++ code. With the rust community growing year after year, more and more people try using rust to program their Arduino boards. Consequently, the Arduino Rust ecosystem have significantly developed in the last couple of years. The Hardware Abstraction Layer for AVR microcontrollers avr-hal, Rudino library and ravedude CLI utility to make Rust development for AVR microcontrollers easier are just a few examples of the solid foundation developed so far.
  • The coincidental typos compiled..
    1 project | /r/rust | 20 Oct 2022
    Today I was toying with the arduino again, making an attached LED matrix print awesome messages better than it previously had. I wanted to use millis() found in the examples in the unsurpassed avr-hal crate, to orchestrate the duration it should show (part of) a character before moving on. But that is all besides the point. I made a few mistakes that coincidentally compiled and as such made me believe I was doing things right. (Perhaps I should note here that I am visually impaired so it is a bit easier for me to glance over smaller differences.)
  • From arduino to rust via avr-hal
    2 projects | /r/rust | 16 Oct 2022
    There's a blink example in the repo for the avr-hal crate.
  • Hey Rustaceans! Got a question? Ask here! (34/2022)!
    11 projects | /r/rust | 24 Aug 2022
    I'm trying to make an Arduino display text on an LCD using I2C (HD44780). So far, I've used arduino-hal from the avr-hal crate (github.com/Rahix/avr-hal) to program the Arduino, and I wonder if anyone happens to know of a library/crate which is compatible with it? So far I've only found ag-lcd which doesn't seem to work with I2C.

What are some alternatives?

When comparing defmt and avr-hal you can also consider the following projects:

cargo-embed - a cargo extension for working with microcontrollers

avrd - AVR device definitions

probe-run - Run embedded programs just like native ones

rust - Rust for the xtensa architecture. Built in targets for the ESP32 and ESP8266

trice - 🟢 super fast 🚀 and tiny 🐥 embedded device 𝘾 printf-like trace ✍ code, works also inside ⚡ interrupts ⚡ and real-time PC 💻 logging (trace ID visualization 👀)

ruduino - Reusable components for the Arduino Uno.

flip-link - Adds zero-cost stack overflow protection to your embedded programs

llvm-project - The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.

nanoprintf - The smallest public printf implementation for its feature set.

atsamd - Target atsamd microcontrollers using Rust

itm - ARMv7-M ITM packet protocol decoder library crate and CLI tool.

rustc_codegen_gcc - libgccjit AOT codegen for rustc