avr-oxide

Crates.ioavr-oxide
lib.rsavr-oxide
version0.4.2
sourcesrc
created_at2021-08-22 08:48:13.948541
updated_at2024-06-07 08:33:23.343399
descriptionAn extremely simple Rusty operating system for AVR microcontrollers
homepagehttps://avroxi.de/
repositoryhttps://gitlab.com/snowgoonspub/avr-oxide
max_upload_size
id440589
size650,402
TimWalls (timwalls)

documentation

https://rustdoc.avroxi.de/avr_oxide/

README

AVR-Oxide

An extremely simple Rust runtime for AVR microcontrollers.

For more information and documentation, see the AVRoxide site.

Why?

AVRoxide was borne out of my frustration with attempting to develop for an Arduino Nano Every microcontroller board using the Rust programming language.

The Arduino Nano Every uses a different version of AVR microcontroller to the other Arduino family of boards - the ATmega4809. While there are HAL1 crates available for various Arduino boards, none of them works with this microcontroller, and that's a shame - it's actually a super nice chip and a good upgrade on the ones used in the 'traditional' Arduino boards. So, support for it in Rust would obviously be nice to have.

How we got here

Naturally, the first thing I tried to do was to adapt some of the existing HALs to work with the Nano Every. But this turned out to be a little trickier than I anticipated, and in any event I discovered there were some things that I didn't like about those HALs. This is in no way a reflection on the quality of thoes HALs - much more a reflection on my Rust abilities - but I found I wanted something a little simpler and easier to understand.

And so, the idea of putting together my own HAL come to mind. But, I also wanted to move a little higher up the pipeline - not just to abstract away the hardware, but also to put in place some standard patterns for things like a standard event loop that would hide some of the details of things like interrupt handling from the application developer.

Thus, AVRoxide is born! The Rusty runtime for AVR microcontrollers.

Supported Microcontrollers

  • ATmega 4809 (used on Arduino Nano Every)
  • ATmega 328P (used on Arduino Uno, Arduino Pro Mini and Arduino Nano)

Note that '328P support is currently at a very, very early stage, with only basic port pins and serial USARTs working. This chip also brings a new set of Rust/LLVM code generation bugs and challenges, and I haven't worked out how to deal with them all yet.

Documentation

Getting started guides are at https://avroxi.de/categories/gettingstarted/

Status

This is a work in progress

It currently is functional, with a whole bunch of caveats about the readiness of Rust on AVR generally, and usable to build simple programs.

The intention is to expand it beyond the minimal set of devices currently supported, in due course.

Now and forever - use at your own risk :-).

THERE ARE HEISENBUGS Particularly involving multithreading. Since I have reached a point of total exasperation attempting to track them down, for the timebeing I'm going to worry about other things and hope I come across the solution while working on something else. So, really really, don't use this for anything critical right now - consider it an adventure game :-).

Rust Toolchain

AVRoxide is built using the nightly Rust toolchain for AVR. Since 10th May 2022, you can use the regular nightly toolchain - thank you to Patryk27 for getting it working!

Update, 2024: Some recent changes in nightly are causing problems. But the relatively recent 2024-05-01 toolchain works fine, so that's what I'm currently using.

A Docker image containing a known-working version of the toolchain is also available on Docker Hub. This is the version used in my CICD to test the build; if you want to verify you can pull the same version using:

docker pull snowgoons/avr-rustbuilder:nightly-2024-06-06

Note that despite the later image date, this image also has the working nightly-2024-05-01 toolchain and sources pre-installed.

Footnotes

  1. Hardware Abstraction Layer

Commit count: 240

cargo fmt