A GNAT Ada Runtime library for ESP32 microcontrollers
This package includes GNAT Ada Run Time Systems (RTSs) based on
FreeRTOS and targeted at boards with
ESP32 MCUs (tested on
Wireless Stick (Gecko Board) by Heltec).
For discussions, visit Telegram Ada Group
or the dedicated
Google Group
for the parent cortex-gnat-rts project.
The RTSs are all Ravenscar-based, with additional restrictions
No_Exception_Propagation and No_Finalization.
No_Exception_Propagation means that exceptions can't be caught except
in their immediate scope; instead, a Last_Chance_Handler is called.
In each case, the board support for the RTS (configuration for size and
location of Flash, RAM; clock initialization; interrupt naming) is in
$RTS/adainclude.
The Ada source is either original or based on FSF GCC (mainly 4.9.1, some later releases too).
Any board with ESP32 should work. We have tested with
- Wireless Stick (Gecko Board) by Heltec
- TTGO T-Display ESP32 (Make sure to change LED pin to 2).
The package is based on Cortex-GNAT-RTS by Simon Wright.
Espressif provides a Espressif IoT Development Framework (ESP-IDF). This package uses the SDK to build an Ada project with FreeRTOS. So you need
- ESP-IDF
- Custom ESP32 toolchain with Ada enabled
gprbuildproject manager- This package for GNAT Runtime Library and examples
Follow Get Started to install ESP-IDF.
Download a toolchain from
Releases
and unpack and replace toolchain (look into
$HOME/.espressif/tools/xtensa-esp32-elf/esp-2020r3-8.4.0)
Alternatively, build it from sources as described here and here.
Use GNAT Community Edition or install a native package:
apt install gprbuild
Clone the repository:
git clone https://github.com/reznikmm/esp32-gnat-rts.git
You can use Docker image to simplify installation. We provide IDF Docker Image with replaced the toolchain.
Here is the example how to clone ESP GNAT Runtime and build the example:
git clone https://github.com/reznikmm/esp32-gnat-rts.git
cd esp32-gnat-rts
docker run --rm -v $PWD:/esp32-gnat-rts -w /esp32-gnat-rts/examples/hello_world/ reznik/gnat:idf-v4.3.1 idf.py build
ESP-IDF provides an
advanced build system
(developed on top of CMake) to build a project.
An ESP-IDF project can be seen as an amalgamation of a number of components.
The esp32-gnat-rts is a component for ESP-IDF. It should be used to link
Ada code into ESP-IDF application.
-
Setup ESP-IDF environment:
. <esp_path>/esp-idf/export.sh -
Build ESP-IDF application
cd esp32-gnat-rts/examples/hello_world idf.py app -
Flash it
cd esp32-gnat-rts/examples/hello_world idf.py -p /dev/ttyUSB0 app-flash -
See "Hello Ada!" output
idf.py monitor I (0) cpu_start: Starting scheduler on APP CPU. Hello from Ada!
The hello_world application is an ESP-IDF project.
It requires esp32-gnat-rts component as dependency.
The app_main subprogram called by FreeRTOS is declared in
environment_task.adb. It creates an environment task that
calls main function (created by gnatbind).
In turn main calls Hello_Ada procedure.
The Hello_Ada outputs "Hello Ada!" with puts provided by FreeRTOS.
The esp32 directory contains a draft implementation for
peripherals access library. The examples/gpio has a blinking LED demo.
Feel free to dive in! Open an issue or submit PRs.
The runtime license is GPL3 with GCC RunTime Exception.