Ada Drivers Library

Hello!
Could you help me how I can build an arbitrary stm32f429-discovery example project from Ada_Drivers_Library?
I am using Ubuntu linux, installed on Ali and can create/build native projects.
I installed the gnat-arm-elf toolchain with alr.
I tried the following:
I cloned the repository, and created a library project in-place with alr in the repo directory. Then I selected gnat-arm-elf toolchain.
Then I issued this:
alr exec – ./scripts/install_dependencies.py

The process stops with the following error:

ROOT_DIR :/home/ptihanyi/adawsp/Ada_Drivers_Library
/home/ptihanyi/adawsp/Ada_Drivers_Library/bb-runtimes already cloned
Running build command:
$ /usr/bin/python3 /home/ptihanyi/adawsp/Ada_Drivers_Library/bb-runtimes/install.py --arch=arm-eabi --prefix=/home/ptihanyi/.config/alire/cache/dependencies/gnat_arm_elf_12.2.1_9be2ca0e/bin/../arm-eabi/lib/gnat
install runtime sources for stm32f4

Dependency install command error (returned 1):
Traceback (most recent call last):
  File "/home/ptihanyi/adawsp/Ada_Drivers_Library/bb-runtimes/./build_rts.py", line 317, in <module>
    main()
  File "/home/ptihanyi/adawsp/Ada_Drivers_Library/bb-runtimes/./build_rts.py", line 293, in main
    projects += installer.install(
  File "/home/ptihanyi/adawsp/Ada_Drivers_Library/bb-runtimes/support/bsp_sources/installer.py", line 168, in install
    runtime_sources = self._find_rts_sources(destination, rts_descriptor)
  File "/home/ptihanyi/adawsp/Ada_Drivers_Library/bb-runtimes/support/bsp_sources/installer.py", line 145, in _find_rts_sources
    assert ret is not None, "Cannot find %s" % rts_json_file
AssertionError: Cannot find rts-sources.json
Traceback (most recent call last):
  File "/home/ptihanyi/adawsp/Ada_Drivers_Library/bb-runtimes/install.py", line 74, in <module>
    main()
  File "/home/ptihanyi/adawsp/Ada_Drivers_Library/bb-runtimes/install.py", line 70, in main
    subprocess.check_call(cmd)
  File "/usr/lib/python3.10/subprocess.py", line 369, in check_call
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['/usr/bin/python3', './build_rts.py', '--build', '--force', '--output=/home/ptihanyi/.config/alire/cache/dependencies/gnat_arm_elf_12.2.1_9be2ca0e/arm-eabi/lib/gnat', 'stm32f4', 'nucleo_f401re', 'stm32f429disco', 'stm32f469disco', 'stm32f746disco', 'stm32756geval', 'stm32f769disco', 'samg55', 'sam4s', 'samv71', 'openmv2', 'rpi2', 'feather_stm32f405', 'stm32f051r8-hsi', 'nrf52832', 'nrf52840', 'cortex-m0', 'cortex-m0p', 'cortex-m1', 'cortex-m3', 'cortex-m4', 'cortex-m4f', 'cortex-m7f', 'cortex-m7df', 'cortex-m23', 'cortex-m33f', 'cortex-m33df', 'rpi-pico', 'rpi-pico-smp']' returned non-zero exit status 1.

Many thanks!

@ptihanyi Ada Drivers Library is not completely compatible with the GNAT FSF available in Alire. So this script will not work. But you can still build the STM32F429-discovery examples.

Note that you will need GNAT FSF 11 compiler because the run-time libraries name changed in GNAT FSF 12.

$ cd Ada_Drivers_Library/examples/STM32F429_Discovery/
$ gprbuild -P blinky_f429disco.gpr 

Thanks a lot for the quick help! It’s working! :slight_smile:
Where can I find more information about the runtime name change?
I would try to port the example projects to GNAT FSF 12.

I should have done this earlier but here you go, I switched Ada Drivers Library to support GNAT FSF 12: Switch to GNAT FSF 12 support by Fabien-Chouteau · Pull Request #418 · AdaCore/Ada_Drivers_Library · GitHub

And for me it was a good exercise to explore in detail how the embedded runtime connects to the Ada Drivers Library!
By studying (and building) the “alire-project/GNAT-FSF-builds” anod recipes, the picture is starting to come together!
Thanks really a lot for the GNAT FSF support, and for the quick help!

Is there any “best practice” example of integrating the Ada Drivers Library into an Alire project?
I have a successful solution, but I don’t think it’s optimal or correct.
My main problem is that Alire stores the Compiler flags in ./config/project.gpr, but within ADL/boards the .gprs also define the Compiler flags.

Original “blinky” example project file:

with "../../boards/stm32f429_discovery/stm32f429_discovery_full.gpr";

project Blinky_F429Disco extends "../shared/common/common.gpr" is

  for Runtime ("Ada") use STM32F429_Discovery_Full'Runtime("Ada");
  for Target use "arm-eabi";
  for Main use ("blinky.adb");
  for Languages use ("Ada");
  for Source_Dirs use ("../shared/hello_world_blinky/src");
  for Object_Dir use "../shared/hello_world_blinky/obj/stm32f429disco";
  for Create_Missing_Dirs use "True";

  package Compiler renames STM32F429_Discovery_Full.Compiler;

end Blinky_F429Disco;

Sorry for the very basic question…

Can I ask for some help to generate a nucleo-l432 (stm32l432 based card) light runtime?
I downloaded the bb-runtimes repo modified for GNAT FSF 12 (https://github.com/Fabien-Chouteau/bb-runtimes/tree/gnat-fsf-12), but the documentation on porting is a bit outdated.
I can generate the runtimes for the available MCUs (and I can build them), but I want to create a new one for stm32l432. Mainly for learning purposes. :slight_smile:
Tanks!

A light runtime for cortex m comes with Gnat GCC FSF 12

I would not recommend making a custom run-time to get started. Here’s the most recent guide I wrote on doing embbeded Ada with Alire: Starting micro-controller Ada drivers in the Alire… | The AdaCore Blog

The compilers now come with run-times that can work on any micro-controller of a given CPU core family (e.g. Cortex-M0, Cortex-M4F, etc.). So you don’t have to make your own run-time.

1 Like