
AVR-Ada
AVR-Ada brings Ada to AVR microcontrollers via Alire, offering configurable crates, runtime support, and peripheral access for 94 devices.

Despite the arrival of competing 32-bit platforms such as ARM Cortex-M or RISC-V32 years ago, AVR microcontrollers are still widely used in embedded systems and will remain a major platform for years to come. This is why we are very happy to see AVR-Ada making AVR microcontrollers easily accessible via the Alire ecosystem.
AVR-Ada is one of the first, if not the first, open-source low-level embedded Ada projects. Rolf, who has been leading the project since the beginning, has now adapted it to the Alire workflow. The result is a collection of crates covering the run times, access to peripherals, and common features such as timekeeping or string manipulation.
One specific challenge addressed by Rolf is the wide variety of devices in the AVR family. There are 94 different microcontrollers supported in AVR-Ada! On the implementation side, the project is using hardware description files provided by the vendor to generate specifications and peripheral representations in Ada. On the user side, an Alire feature provides a way to specify which one of those devices is targeted.
The feature is called “crate configuration”, a way for crates to expose a list of variables that can be set by other crates depending on them. These variables are then converted to constants in Ada and GPR files which in turn alter the behavior/implementation of the crate. This is particularly useful for embedded applications where compile time allocations and optimizations are crucial.
For example, the avr_mcu crate defines the following variables:
[configuration.variables]
AVR_MCU = { type = "String", default = "atmega328p" }
Sec_Stack_Size = { type = "Integer", first = 0, last = 1024, default = 63 }
Clock_Frequency = { type = "Integer", first = 0, default = 0 }As a user, if I want to develop an application for the Arduino UNO which is equipped with an ATmega328P, I only have to set the variable in my crate’s manifest file (alire.toml):
[[depends-on]]
avrada_mcu = “^2.2.0”
avrada_lib = “^2.1.0”
[configuration.values]
avrada_rts.AVR_MCU = “atmega328p”
avrada_rts.Clock_Frequency = 16000000and all the AVR-Ada libraries will be correctly configured.


