Blog coding article

Knurling-rs changelog #5

Jonas
Article

Knurling-rs changelog #5

Published on 2 min read
Knurling icon
Knurling
A tool set to develop embedded applications faster.
❤️ Sponsor

    This is the fifth changelog for Knurling-rs, our push to sustainably build better tooling for developing and debugging Rust software for embedded systems. Knurling-rs includes a suite of tools that make it easier to develop, log, debug, and test your embedded Rust libraries and applications!

    Knurling-rs is supported by our sponsors on GitHub. If you're interested in seeing more projects like this, consider becoming a sponsor today!

    Organizational

    Knurling-sessions will switch its update day to monday.

    New knurling-sessions content

    Since knurling-sessions has moved it's update day, no new content has been added today. But here's a sneak peek: On Monday, Block 2 will start, where we start writing the drivers for our CO2 sensor. ⚙️

    Remember: you can find the access credentials to all knurling-sessions materials in our sponsors team announcements.

    Improvements

    Several improvements to bandwidth usage in defmt were made. Since they were side effects of bug fixes, they are listed in the Fixes section below.

    New features

    As we were focusing on squashing bugs and preparing defmt for the crates.io release, no new features were added.

    Fixes

    defmt

    • #224 fixes a bug where loading ELF binaries that don't make use of defmt were rejected with an error by probe-run.
    • #226 fixes encoding of 1-variant enums, avoiding data corruption. Now, the discriminant of the enum is not encoded in the data stream anymore, because the variant is already known, which saves bandwidth.
    • #227 fixes the Format implementation of usize and isize, which were missing a check, resulting in data corruption.
    • #228 fixes a few bugs around how bools are encoded by the #[derive(Format)] macro, the Format implementation of bool, as well as how they're decoded again. It also simplified the derive macro.

      defmt compresses bools to save bandwidth: up to 8 bools in the encoded data are collected into a single byte. Previously, this compression accidentally stopped after every {:?} argument, flushing the collected bools to the output stream. Additionally, the Format impl for bool directly emitted a byte to the stream, instead of using this compression logic.

      This resulted in wasted bandwidth, as well as stream corruption issues, because the decoder logic didn't quite match the encoding side.

    Thanks to @Dirbaio for finding and reporting many of these bugs!

    probe-run

    • #87 and #92 update the defmt version, pulling in the bugfix from #224.

    Internal improvements

    • #222 adds snapshot testing to defmt's QEMU integration tests, to ensure that end-to-end usage of defmt works as expected. Previously, only unit tests were checked in CI, and the QEMU tests had to be checked manually.

    Sponsor this work

    Knurling is mainly funded through GitHub sponsors. Sponsors get early access to the tools we are building and help us to support and grow the knurling tools and courses. Thank you to all of the people already sponsoring our work through the Knurling project!