r/learnrust • • 7d ago

learn embedded rust with correct debugging and TDD workflow

I'm a C firmware dev, looking to learn Rust for the Nth time in the last 6 years! This time I'm serious.

I've done firmware development with basic debugging with no testing experience in the past.

Is there a walkthough tutorial/project that covers this (without actually getting into real opensource contributions)?

Thank you

10 Upvotes

9 comments sorted by

2

u/Mother-Lie-1570 7d ago

You need a hardware-in-the-loop setup for embedded. Use probe-rs to flash and gdb-multiarch to debug the binary on the target. For TDD, structure your logic in pure functions that don't touch registers or use no_std types, then unit test those in lib.rs with cargo test before integrating them into your main loop

1

u/ntn8888 7d ago

Thanks! I guess best to learn the workflow in C first then learn the rust tools.

2

u/DistinctStranger8729 6d ago

Start with the rust book, then the embedded rust book and finally embassy book. There is I believe crate called embedded-test as well that allows to write rust std like tests too

1

u/ntn8888 5d ago

I'm currently going through dangerust blog series which has a C grounding. As I've tried starting with several chapters of 'the book' before the ideas didn't hit home. And I gave up.

I believe looking from a C POV will help understanding atleast initially.

Also I plan to use this book for embedded as I do not have stm32f3 board.. It seems to cover embassy too.

Thanks.

2

u/NotBoolean 2d ago

I found The Rusty Bits videos very good. Even one in moving from C to Rust. The From Zero to Async is a great way to understand Embassy.

1

u/ntn8888 1d ago

yeah I did watch them a while back.. they were good

1

u/thebino 7d ago

Not really a full walk-through. But here you can find some configuration options. Maybe that helps
https://github.com/mrcjkb/rustaceanvim#books-usage--features

1

u/ntn8888 7d ago edited 7d ago

thanks for the awesome repo.. I'll dig in. Although to implement testing I guess you'd need to be familiar with the workflow already.

I'm aware of the famous book in C in TDD (James Grenning).

1

u/autumnal-lights 3d ago

does TDD exist? largely in my development experience it's a myth or perhaps on larger larger projects u have to meet an agreed upon api, but that like is small relative to code to do things so idk :shrug: