# Ada for xtensa esp32 (LX6/LX7) \[DRAFT!\]

**URL:** https://forum.ada-lang.io/t/ada-for-xtensa-esp32-lx6-lx7-draft/1132
**Category:** General
**Tags:** embedded
**Created:** [September 1, 2024, 12:08pm UTC](https://forum.ada-lang.io/t/ada-for-xtensa-esp32-lx6-lx7-draft/1132 "2024-09-01T12:08:31Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![Max](https://forum.ada-lang.io/user_avatar/forum.ada-lang.io/max/32/21_2.png) [@Max](https://forum.ada-lang.io/u/Max)
#### Post date: [September 1, 2024, 12:08pm UTC](https://forum.ada-lang.io/t/ada-for-xtensa-esp32-lx6-lx7-draft/1132/1 "2024-09-01T12:08:31Z")

</div>

I have built a cross-compiler for [xtensa-esp32-elf](https://en.wikipedia.org/wiki/ESP32). Several members of the [telegram channel](https://t.me/+8W6Y75pkslU1ZDgx) expressed interest in supporting Ada on this platform. I spent some time and built a toolchain using [Alire’s scripts](https://github.com/alire-project/GNAT-FSF-builds). Fabian then accepted my changes and this compiler is now available in the community index. Porting bareboard runtimes is still to come. If you are interested, join the telegram channel or leave your comments on the forum here.

- If you want install the toolchain, run `alr toolchain --select gnat_xtensa_esp32_elf`

- Beside toolchain you need a `xtensa-dynconfig` plugin:

```shell
git clone https://github.com/jcmvbkbc/xtensa-dynconfig
git -C xtensa-dynconfig clone https://github.com/espressif/xtensa-overlays config
make -C xtensa-dynconfig
export XTENSA_GNU_CONFIG=$PWD/xtensa-dynconfig/xtensa_esp32s3.so

```

- I’ve made a patch to [bb-runtimes](https://github.com/reznikmm/bb-runtimes/tree/esp32) to make it simpler somebody to start working on the run time. If you want to try:

```shell
git clone -b esp32 https://github.com/reznikmm/bb-runtimes/
cd bb-runtimes
./build_rts.py --output=$HOME/.local/share/alire/toolchains/gnat_xtensa_esp32_elf_14.2.1_f8471bd4/xtensa-esp32-elf/lib/gnat --build esp32 --rts-src-descriptor ./gnat_rts_sources/lib/gnat/rts-sources.json

# Optionaly rebuild rts with debug info:

gprbuild -P $HOME/.local/share/alire/toolchains/gnat_xtensa_esp32_elf_14.2.1_f8471bd4/xtensa-esp32-elf/lib/gnat/light-esp32/runtime_build.gpr -XBUILD=Debug

```

- Now you can try to build hello world and get linker errors, because some/many files are missing:

```shell
gprbuild --target=xtensa-esp32-elf --RTS=light-esp32 -P examples/hello-light/hello.gpr

```

- Another repo to take a look is [GitHub - rowsail/AdaXtensa-RTS: Runtime system for Ada on an Xtensa processor](https://github.com/rowsail/AdaXtensa-RTS)

Links:

- Telegram channel: [Telegram: Join Group Chat](https://t.me/+8W6Y75pkslU1ZDgx)
- [Experiments with ESP32-H2](https://forum.ada-lang.io/t/experiments-with-risc-v/930)
- [Ada & FreeRTOS on ESP32 H2](https://forward-in-code.blogspot.com/2024/07/ada-freertos-on-esp32-h2.html)
- [ESP-IDF Ada Binding](https://github.com/jklmnn/esp-idf-ada-bindings)
- [A baremetal, single C header ESP32 SDK](https://github.com/cpq/mdk)
- [HiRTOS on ESP32-C3](https://github.com/jgrivera67/HiRTOS)

---

<div class="post-metadata">

### Author: ![alexispaez](https://forum.ada-lang.io/user_avatar/forum.ada-lang.io/alexispaez/32/920_2.png) [@alexispaez](https://forum.ada-lang.io/u/alexispaez)
#### Post date: [September 19, 2025, 9:23am UTC](https://forum.ada-lang.io/t/ada-for-xtensa-esp32-lx6-lx7-draft/1132/2 "2025-09-19T09:23:19Z")

</div>

Will this work with an ESP32-WROOM-32? I just saw it on sale at AZ-Delivery 🤗

---

<div class="post-metadata">

### Author: ![Irvise](https://forum.ada-lang.io/letter_avatar_proxy/v4/letter/i/7ba0ec/32.png) [@Irvise](https://forum.ada-lang.io/u/Irvise)
#### Post date: [September 19, 2025, 3:31pm UTC](https://forum.ada-lang.io/t/ada-for-xtensa-esp32-lx6-lx7-draft/1132/3 "2025-09-19T15:31:27Z")

</div>

ESPRESSIF does not recommend it for new projects [https://www.espressif.com/sites/default/files/documentation/esp32-wroom-32\_datasheet\_en.pdf](https://www.espressif.com/sites/default/files/documentation/esp32-wroom-32_datasheet_en.pdf) It is a rather old CPU by now. However, it has an Xtensa CPU, so it should work with the toolchain 🙂 It is probably under discount in order to get rid of extra inventory.

Newer CPUs/Boards include the ESP32-C6, C3, S3, etc 🙂

---

<div class="post-metadata">

### Author: ![Max](https://forum.ada-lang.io/user_avatar/forum.ada-lang.io/max/32/21_2.png) [@Max](https://forum.ada-lang.io/u/Max)
#### Post date: [September 19, 2025, 7:59pm UTC](https://forum.ada-lang.io/t/ada-for-xtensa-esp32-lx6-lx7-draft/1132/4 "2025-09-19T19:59:14Z")

</div>

It should work in theory, but right now nobody ports Ada runtime for esp32. We have only compiler.

---

<div class="post-metadata">

### Author: ![alexispaez](https://forum.ada-lang.io/user_avatar/forum.ada-lang.io/alexispaez/32/920_2.png) [@alexispaez](https://forum.ada-lang.io/u/alexispaez)
#### Post date: [September 22, 2025, 8:09am UTC](https://forum.ada-lang.io/t/ada-for-xtensa-esp32-lx6-lx7-draft/1132/5 "2025-09-22T08:09:38Z")

</div>

Please excuse my ignorance (I’m trying to learn 🙃 )…

What does not having an available runtime mean and does it apply to all ESP32 boards?

Does it mean you can’t use any Ada library code and you need to do programming on pure bare metal?

What is required to port an Ada runtime for ESP32? Just wondering if it’s something I could take on, for didactic reasons, or if it’s totally over my head for now 😅

Thanks a lot and best regards,

Alexis.

---

<div class="post-metadata">

### Author: ![Max](https://forum.ada-lang.io/user_avatar/forum.ada-lang.io/max/32/21_2.png) [@Max](https://forum.ada-lang.io/u/Max)
#### Post date: [September 22, 2025, 4:36pm UTC](https://forum.ada-lang.io/t/ada-for-xtensa-esp32-lx6-lx7-draft/1132/6 "2025-09-22T16:36:58Z")

</div>

> [@alexispaez](#):
>
> What does not having an available runtime mean and does it apply to all ESP32 boards?

It mean that our toolchain for ESP32 is incomplete. We have only compiler, but not runtime (for any board). So with the compiler one could starting porting Ada runtime and build it: get `libgnat.a` and a bunch of `*.ali` file from runtime source files. Yje having compiler and runtime anyone could build and link an Ada application.

> [@alexispaez](#):
>
> Does it mean you can’t use any Ada library code and you need to do programming on pure bare metal?

Without runtime you can’t compile any user’s compilation unit (package/subprogram), because it depends on `Standard` package that is part of runtime. During compilation the compiler reads `System` package to find target properties. In turn, runtime comes in several types. `light` runtime is most thin and most easy to port. It provides only basic support, you won’t be able to use tasks, protected object, but you can build an application. `light-tasking` runtime has support of tasks/protected object with some restrictions (See Ravenscar profile). To get full Ada you need full Ada runtime, that is very big and probably requires real OS underneath.

> [@alexispaez](#):
>
> What is required to port an Ada runtime for ESP32? Just wondering if it’s something I could take on, for didactic reasons, or if it’s totally over my head for now 😅

Porting runtime could be an interesting and you could find out mush about how it works. From my point of view it is not hard, at least for `light` runtime. You will need to find out

- compiler flags for your particular chip
- flash layout to create a linker script
- number and names of interrupts to write interrupt vector (in assembly)
- create a starter assembly chunk to initialize stack, clean bss memory section

Some links:

- [GitHub - Fabien-Chouteau/bare\_runtime: Minimal Ada/SPARK run-time for embedded or other restricted targets](https://github.com/Fabien-Chouteau/bare_runtime)
- [5. Predefined GNAT Pro Run-Times — GNAT User's Guide Supplement for Cross Platforms 27.0w documentation](https://docs.adacore.com/gnat_ugx-docs/html/gnat_ugx/gnat_ugx/gnat_runtimes.html)
- [Embedded Systems | ada-lang.io, an Ada community site](https://ada-lang.io/docs/learn/getting-started/embedded)
- [GitHub - AdaCore/startup-gen: A startup code generator for embedded projects](https://github.com/AdaCore/startup-gen)
- [Startup-gen User’s Guide — startup-gen documentation](https://docs.adacore.com/live/wave/startup-gen/html/startup_gen_ug/index.html)

Don’t hesitate to ask questions! 👍

---

<div class="post-metadata">

### Author: ![Irvise](https://forum.ada-lang.io/letter_avatar_proxy/v4/letter/i/7ba0ec/32.png) [@Irvise](https://forum.ada-lang.io/u/Irvise)
#### Post date: [September 22, 2025, 7:39pm UTC](https://forum.ada-lang.io/t/ada-for-xtensa-esp32-lx6-lx7-draft/1132/7 "2025-09-22T19:39:41Z")

</div>

Adding info to what Maxim just linked, the AdaCore blog has quite a few posts about this topic:

> **[Porting the Ada Runtime to a new ARM board](https://blog.adacore.com/porting-the-ada-runtime-to-a-new-arm-board)**
>
> by Jérôme Lambourg – Sep 03, 2018. A step by step tutorial to adapt the ARM runtime to new MCUs/boards.

> **[Ada on FPGAs with PicoRV32](https://blog.adacore.com/ada-on-fpgas-with-picorv32)**
>
> by Fabien Chouteau – Oct 08, 2018. When I bought the TinyFPGA-BX board, I thought it would be an opportunity to play a little bit with FPGA, learn some Verilog or VHDL. But when I discovered that it was possible to have a RISC-V CPU on it, I knew I...

> **[Starting micro-controller Ada drivers in the Alire ecosystem](https://blog.adacore.com/starting-micro-controller-ada-drivers-in-the-alire-ecosystem)**
>
> Starting micro-controller Ada drivers in the Alire ecosystem

> **[Open-Source Ada: From Gateware to Application](https://blog.adacore.com/open-source-ada-from-gateware-to-application)**
>
> by Olivier Henley – Feb 10, 2025. The Neorv32 BIOS project demonstrates how Ada can serve as a powerful alternative to C in open-source embedded development. Using a fully open-source stack—including Neorv32 (a VHDL-based RISC-V softcore), the ULX3S...
