Article

Knurling-rs changelog #24

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

    This is the 24th 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!

    Highlights 🎉

    all good releases come in threes

    In today's changelog we don't feature one, not two, but three releases of our crates!

    First we are having flip-link which didn't have a release for five months. v0.1.3 features a smaller binary size & build time and improved documentation explaining the stack-overflow problem and the flip-link solution. Also we started to refactor code for readability and maintainability, which we will continue to focus on in the next time.

    The second candidate is defmt-test. v0.2.2 is mainly about cleaning the documentation about setup steps and extending our example code.

    Last but not least is probe-run. v0.2.2 ships many helpful improvements, like a more verbose logging level and bounds checking during stack unwinding. As a usability improvement, probe-run doesn't print a backtrace anymore (although it can be forced) if the the microcontroller halted without an error. This is because we observed many first-time users being unsure if their program ran successfully because backtraces usually only appear on error. Additionally, it is possible to limit the backtrace length using a configurable maximum.

    defmt-test: support more items in the #[tests] module

    One new defmt-test feature, which isn't part of the new release yet, is the support for all items inside the #[tests] module, except bare fns. Users can now define structs, consts etc. which are needed across various tests to reduce duplicate code.

    The following is possible now:

    #[defmt_test::tests]
    mod tests {
        use core::u8::MAX;
        use defmt::{assert, assert_eq};
    
        struct InitStruct {
            test: u8,
        }
    
        #[repr(C)]
        #[derive(Debug)]
        struct SomeData {
            elem1: u8,
            elem2: f32,
        }
    
        #[init]
        fn init() -> InitStruct {
            InitStruct {
                test: 8,
            }
        }
    
        #[test]
        fn change_init_struct(init_struct: &mut InitStruct) {
            assert_eq!(init_struct.test, 8);
            init_struct.test = 42;
        }
    
        #[test]
        fn test_for_changed_init_struct(init_struct: &mut InitStruct) {
            assert_eq!(init_struct.test, 42);
        }
    
        #[test]
        fn assert_true() -> () {
            assert!(true);
        }
    
        const CUSTOM_MAX: u8 = 255;
    
        #[test]
        fn assert_imported_max() {
            assert_eq!(CUSTOM_MAX, MAX);
        }
    }
    

    issue of the issue

    In this issue of the changelog we want to highlight an issue in the defmt issue tracker and ask you for help and input!

    In particular it is about defmt#426. It is currently impossible to support multiple defmt versions in your application or library. This is because defmt makes use of the links key in Cargo.toml, which demands that dependencies don't use the same links directive. Read more about this key in the cargo book.

    This for once makes breaking changes on our side more painful, because the whole defmt ecosystem needs to upgrade in a coordinated fashion to avoid incompatibility. Your own crate needs to have the exactly same defmt version like all of your dependencies and as soon they upgrade, you also have to.

    Now to the question part: Do you have a great idea how to ease or completely solve this problem? Do you know other projects which faced a similar issue and if yes, how did they deal with it? Your support is very much appreciated!

    Improvements 🦀

    defmt

    • #441 defmt-test: Support more items in #[tests] module

    probe-run

    • #190 Clarify cargo runner configuration in README.md. Thanks to bobmcwhirter!
    • #184 Add some bounds checking to unwinding
    • #183 Add troubleshooting tip for use with RTIC to README.md. Thanks to davidlattimore!

    Fixes 🔨

    defmt

    • #453 Remove minimum timestamp alignment

    knurling-session-20q4

    • #7 Fix links to example code

    Internal Improvements 🧽

    defmt

    • #454 Add netlify.toml
    • #33 Add clippy to CI

    knurling-session-20q4

    • #8 Extend netlify.toml with build command and publish dir
    • #12 Move .github/FUNDING.yml to crate root

    Version Update Notification 🆙

    probe-run reaches v0.2.2, defmt-test arrives at v0.2.2 and flip-link matures to v0.1.3.

    Sponsor this work

    Knurling-rs 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!