This repository generates GNAT runtimes that support all MCUs in the STM32F0 family.
The following runtime profiles are supported:
- light
- light-tasking
- embedded
Using the light-tasking-stm32f0xx runtime as an example, first edit your
alire.toml file and add the following elements:
- Add
light_tasking_stm32f0xxin the dependency list:[[depends-on]] light_tasking_stm32f0xx = "*"
- if applicable, apply any runtime configuration variables (see "Runtime Configuration" below).
Then edit your project file to add the following elements:
- "with" the run-time project file:
with "runtime_build.gpr";
- if you are using the light-tasking or embedded runtime profile, then
you also need to "with"
ravenscar_build.gpr:with "ravenscar_build.gpr";
- specify the
TargetandRuntimeattributes:for Target use runtime_build'Target; for Runtime ("Ada") use runtime_build'Runtime ("Ada");
- specify the
Linkerswitches:package Linker is for Switches ("Ada") use Runtime_Build.Linker_Switches; end Linker;
The runtime is configurable through the crate configuration variables.
The following variables configure the specific STM32F0 MCU that is being targeted:
| Variable | Values | Default | Description |
|---|---|---|---|
| MCU_Sub_Family | "F030", "F031", "F038", "F042", "F048", "F051", "F058", "F070", "F071", "F072", "F078", "F091", "F098" | "F072" | Specifies the sub-family part of the STM32F0 part number. For example, choose "F072" for the STM32F072RB. |
| MCU_Pin_Count | "C", "E", "F", "G", "K", "R", "V" | "R" | Specifies the pin count part of the STM32F0 part number. For example, this is the "R" in "STM32F072RB". |
| MCU_User_Code_Memory_Size | "4", "6", "8", "B", "C" | "B" | Specifies the "user code memory size" part of the STM32F0 part number. For example, this is the "B" in "STM32F072RB". |
By default, the runtime is configured for the STM32F072RB. If you are using
a different MCU, then you will need to configure the runtime by adding the
following to your alire.toml. For example, to configure the runtime for the
STM32F030F4:
[configuration.values]
light_tasking_stm32f0xx.MCU_Sub_Family = "F030"
light_tasking_stm32f0xx.MCU_Pin_Count = "F"
light_tasking_stm32f0xx.MCU_User_Code_Memory_Size = "4"By default, the runtime configures the clocks to provide a 48 MHz system clock from the high-speed internal (HSI) oscillator. The following crate configuration variables can be used to use a different clock tree configuration:
| Variable | Values | Default | Description |
|---|---|---|---|
| LSI_Enabled | true, false, | true | When true, the runtime will enable the low-speed internal (LSI) oscillator at startup. |
| HSE_Bypass | true, false, | false | When true, the runtime will use enable the HSE bypass feature to allow an external clock source to be used (setting HSEBYP in the clock configuration registers). When false, the HSE will be configured for an external crystal/ceramic resonator. |
| HSE_Clock_Frequency | 4000000 .. 32000000 | 8000000 | Specifies the frequency of the HSE clock in Hertz. The default is 8 MHz. |
| SYSCLK_Src | "HSI", "HSE", "PLL", "HSI48", | PLL |
Specifies the clock source to use for the system clock (SYSCLK).
|
| PLL_Src | "HSI_2", "HSI_PREDIV", "HSE_PREDIV", "HSI48_PREDIV", | HSI_2 |
Specifies the clock source to use for the input into the PLL.
|
| PREDIV | 1 .. 16 | 2 | Specifies the divider to use for the PLL clock input. |
| PLLMUL | 2 .. 16 | 12 | Specifies the PLL multiplier to use. |
| AHB_Pre | "DIV1", "DIV2", "DIV4", "DIV8", "DIV16", "DIV64", "DIV128", "DIV256", "DIV512" | DIV1 | Specifies the divider to use for the AHB prescaler. |
| APB_Pre | "DIV1", "DIV2", "DIV4", "DIV8", "DIV16" | DIV1 | Specifies the divider to use for the APB prescaler. |
Here's an example of configuring the runtime in alire.toml for a 32 MHz
system clock from a 16 MHz HSE oscillator:
[configuration.values]
# Configure a 16 MHz HSE crystal oscillator
light_tasking_stm32f0xx.HSE_Clock_Frequency = 16000000
light_tasking_stm32f0xx.HSE_Bypass = false
# Use the PLL as the SYSCLK source
light_tasking_stm32f0xx.SYSCLK_Src = "PLL"
# Configure the PLL input for a 16 MHz input from the HSE
light_tasking_stm32f0xx.PLL_Src = "HSE_PREDIV"
light_tasking_stm32f0xx.PREDIV = 1
# Configure the PLL to output 32 MHz (16 MHz * 2)
light_tasking_stm32f0xx.PLLMUL = 2
# Configure the AHB an APB to also run at 32 MHz
light_tasking_stm32f0xx.AHB_Pre = "DIV1"
light_tasking_stm32f0xx.APB_Pre = "DIV1"The following variables configure the interrupt stack sizes:
| Variable | Values | Default | Description |
|---|---|---|---|
| Interrupt_Stack_Size | Any positive integer | 1024 | Specifies the size of the primary stack used for interrupt handlers. |
| Interrupt_Secondary_Stack_Size | Any positive integer | 128 | Specifies the size of the secondary stack used for interrupt handlers. |
The runtime project files expose *_BUILD and and *_LIBRARY_TYPE GPR
scenario variables to configure the build mode (e.g. debug/production) and
library type. These variables are prefixed with the name of the runtime in
upper case. For example, for the light-tasking-stm32f0xx runtime the variables
are LIGHT_TASKING_STM32F0XX_BUILD and LIGHT_TASKING_STM32F0XX_LIBRARY_TYPE
respectively.
The *_BUILD variable can be set to the following values:
Production(default) builds the runtime with optimization enabled and with all run-time checks suppressed.Debugdisables optimization and adds debug symbols.Assertenables assertions.Gnatcovdisables optimization and enables flags to help coverage.
The *_LIBRARY_TYPE variable can be set to either static (default) or
dynamic, though only static libraries are supported on this target.
You can usually leave these set to their defaults, but if you want to set them explicitly then you can set them either by passing them on the command line when building your project with Alire:
alr build -- -XLIGHT_TASKING_STM32F0XX_BUILD=Debugor by setting them in your project's alire.toml:
[gpr-set-externals]
LIGHT_TASKING_STM32F0XX_BUILD = "Debug"