ZigEmbeddedGroup / microzig

Unified abstraction layer and HAL for several microcontrollers
zlib License
1.07k stars 81 forks source link

Suggestions re: STM32 from a Rust Embedded dev #179

Open jamesmunns opened 5 months ago

jamesmunns commented 5 months ago

Hey! Chiming in as someone doing embedded Rust things:

Just wanted to share particularly with respect to STM32 chips, which have an insane number of variants, SVD files that are often wrong, and a lot of challenging details, it might be worth looking at https://github.com/embassy-rs/stm32-data, which https://embassy.rs uses for the unified stm32 HAL. It is typically more actively patched and maintained for correctness than the upstream STM32 SVD data sources.

In general, SVD files often require patching and continued maintenance, https://github.com/embassy-rs/chiptool might be a good inspiration, which uses YAML files to apply patches and groupings, rather than hand-editing SVD files.

Feel free to close, or let me know if y'all would like to share notes on anything. Excited to see what you all build!

(edited title to make it more clear this is just my opinion, not like an "offical embedded rust position")

mattnite commented 5 months ago

Hey James! Thanks for pointing this out. I was planning on adding support for the yaml patches that svd2rust/chiptool uses to our code generation tool, but didn't realize there was a common place to maintain them.

We've got some major changes on the horizon but looking forward to working with embedded Rust folks in the future!

jamesmunns commented 5 months ago

AFAIK, stm32 is the only familiy big and active enough to merit centralized info like this. IIRC, some data was also pulled from stm's cubemx databases, and other sources, tho that might just be through yaml updates.

Other popular families generally have a good enough "quality + quantity" factor that occasional SVD patches are done in-repo.

Feel free to come hang out in the Matrix Room, esp if you want any opinions before trying out certain tools or approaches.

kuon commented 5 months ago

I use the stm32l0x1 serie, and I wrote a small library for my own use. It is very minimal at the moment, but it might be of some interest.

Feel free to copy/integrate whatever you feel is useful.

https://github.com/kuon/stm32l0x1-zig

ikskuh commented 4 months ago

Hey! Chiming in as someone doing embedded Rust things:

Heya! Thanks for the hints. Definitly better to use and contribute to an already existing community-maintained thing than make it our own.

We've got some major changes on the horizon but looking forward to working with embedded Rust folks in the future!

Absolutely! Rust and Zig together will probably make a really great experience for embedded development. Drivers in Zig, application logic in Rust should yield a pretty damn solid foundation for a new generation of devices :metal: