Skip to content

This project contains various GNAT Ada Run Time Systems (RTSs) targeted at Cortex boards: so far, the Arduino Due, the STM32F4-series evaluation boards from STMicroelectronics, and the BBC micro:bit

License

Notifications You must be signed in to change notification settings

reznikmm/esp32-gnat-rts

 
 

Repository files navigation

esp32-gnat-rts

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.

Install

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
  • gprbuild project manager
  • This package for GNAT Runtime Library and examples

Install ESP-IDF

Follow Get Started to install ESP-IDF.

Install Custom ESP32 toolchain with Ada enabled

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.

Install gprbuild project manager

Use GNAT Community Edition or install a native package:

apt install gprbuild

Install esp32-gnat-rts

Clone the repository:

git clone https://github.com/reznikmm/esp32-gnat-rts.git

Docker alternative

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

Usage

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.

Build hello_world

  1. Setup ESP-IDF environment:

    . <esp_path>/esp-idf/export.sh
    
  2. Build ESP-IDF application

    cd esp32-gnat-rts/examples/hello_world
    idf.py app
    
  3. Flash it

    cd esp32-gnat-rts/examples/hello_world
    idf.py -p /dev/ttyUSB0 app-flash
    
  4. 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.

ESP32 peripherals

The esp32 directory contains a draft implementation for peripherals access library. The examples/gpio has a blinking LED demo.

Maintainer

Max Reznik.

Contribute

Feel free to dive in! Open an issue or submit PRs.

License

The runtime license is GPL3 with GCC RunTime Exception.

About

This project contains various GNAT Ada Run Time Systems (RTSs) targeted at Cortex boards: so far, the Arduino Due, the STM32F4-series evaluation boards from STMicroelectronics, and the BBC micro:bit

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Ada 98.6%
  • C 1.2%
  • Other 0.2%