I’ve recently released a some configurable bareboard runtime crates for several STM32 families, with support for the light, light-tasking, and embedded runtime profiles:
- STM32F0xx crates (GitHub page: GitHub - damaki/stm32f0xx-runtimes: GNAT Ada runtimes for the STM32F0 family):
- STM32G0xx crates (GitHub page: GitHub - damaki/stm32g0xx-runtimes: GNAT Ada runtimes for the STM32G0 family):
- STM32G4xx crates (GitHub page: GitHub - damaki/stm32g4xx-runtimes: GNAT Ada runtimes for the STM32G4 family):
The runtimes are based on GNAT FSF 15, but I could do releases for older versions of GNAT if there’s a demand for it.
Each runtime supports every device in the family. The runtime is configured for a specific device via crate configuration variables. For example, to configure the light_tasking_stm32g4xx runtime for the STM32G431K6 device, add the following to your project’s alire.toml
:
[configuration.values]
light_tasking_stm32g4xx.MCU_Sub_Family = "G431"
light_tasking_stm32g4xx.MCU_Flash_Memory_Size = "6"
The clock tree is also configurable. By default the runtime sets up the system clock from the PLL and the high-speed internal (HSI) oscillator, but you can also configure it for the HSE if your board has one (some Nucleo boards seem to have one) or configure a different clock speed if you want. Here’s an example of configuring the light_tasking_stm32g4xx runtime to generate a 170 MHz sytem clock from a 24 MHz HSE oscillator in alire.toml
:
[configuration.values]
# Configure a 24 MHz HSE crystal oscillator
light_tasking_stm32g4xx.HSE_Clock_Frequency = 24000000
light_tasking_stm32g4xx.HSE_Bypass = false
# Select PLLRCLK as the SYSCLK source
light_tasking_stm32g4xx.SYSCLK_Src = "PLLRCLK"
# Configure the PLL VCO to run at 340 MHz from the 24 MHz HSE (fVCO = fHSE * (N/M))
light_tasking_stm32g4xx.PLL_Src = "HSE"
light_tasking_stm32g4xx.PLL_N_Mul = 85
light_tasking_stm32g4xx.PLL_M_Div = 6
# Configure the PLLRCLK to run at 170 MHz from the 340 MHz VCO.
light_tasking_stm32g4xx.PLL_R_Div = 2
# Configure the AHB and APB to also run at 170 MHz
light_tasking_stm32g4xx.AHB_Pre = "DIV1"
light_tasking_stm32g4xx.APB1_Pre = "DIV1"
light_tasking_stm32g4xx.APB2_Pre = "DIV1"
See the projects’ GitHub pages (links above) for full details of what is configurable.
The hope is that these runtimes are flexible and easy-to-use enough that they help people get started with a new STM32 project quickly, without needing to build their own runtimes for their specific device/board since they can use and configure these runtimes instead.