esp32 backend
Added by Sergey Durmanov over 1 year ago
Hello Florian.
Are there any plans to implement an ESP32 backend?
Replies (16)
RE: esp32 backend - Added by Florian Negele over 1 year ago
In case you mean RISC-V, that architecture was in consideration for a while but not at the moment.
RE: esp32 backend - Added by Sergey Durmanov over 1 year ago
I mean Xtensa LX architecture.
https://www.esp32.com/download/file.php?id=10134
RE: esp32 backend - Added by Florian Negele over 1 year ago
I mean Xtensa LX architecture.
No plans at the moment, sorry.
RE: esp32 backend - Added by Florian Negele over 1 year ago
What target did you have in mind? I just saw that there exists a Arduino Nano ESP32 board which would be feasible for development, provided there is useful and free documentation about the architecture. Please note that I could only provide an assembler, a compiler back-end and rudimentary runtime support, I cannot provide support for anything else, in particular programming the microcontroller itself or its peripherals.
RE: esp32 backend - Added by Sergey Durmanov over 1 year ago
I'm interested in xtensa lx7 modules: espressif esp32-S or lilygo t-micro32 mcu).
Here are some open source lilygo boards/devices projects:
https://github.com/Xinyuan-LilyGO
RE: esp32 backend - Added by Florian Negele over 1 year ago
I have found a summary for the Xtensa Instruction Set Architecture (ISA) and it seems to be straight forward to implement. Please note again, that I cannot provide any support for your desired modules should we decide to support this target.
RE: esp32 backend - Added by Sergey Durmanov over 1 year ago
Bskend, assembler and runtime are a good base for starting experiments. I purchased a programmable smartwatch Lilygo T-watch on esp32 (lilygo t-micro32 plus) for experiments. I also have several iot devices (xtensa lx6).
RE: esp32 backend - Added by Florian Negele over 1 year ago
I will look into this but cannot promise anything. Just to keep expectations low: Please note that this project is not optimised for such small targets. The compiler basically uses the same calling convention for all targets. In particular function parameters and local variables are all accessed via the stack and not registers as is usual for devices with such a small memory footprint. This means less dense code and more memory indirections.
RE: esp32 backend - Added by Florian Negele over 1 year ago
We purchased an Arduino Nano ESP32 and will look into how the device can be programmed and if it is an appropriate target.
RE: esp32 backend - Added by Sergey Durmanov over 1 year ago
There is also qemu for esp32. Please note that you need to use the option for esp32 [s2/s3] (xtensa), and not esp32-c3 (risc-v core).
https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-guides/tools/qemu.html
RE: esp32 backend - Added by Florian Negele over 1 year ago
- Code Density Option
- Floating-Point Coprocessor Option with support for single precision
- 32-bit Integer Multiply Option
- 32-bit Integer Divide Option
RE: esp32 backend - Added by Sergey Durmanov over 1 year ago
yes, esp32-s3 core supports these options
RE: esp32 backend - Added by Florian Negele over 1 year ago
In case you are interested in a Oberon compiler for ESP32, I just stumbled accross this project on GitHub.
RE: esp32 backend - Added by Florian Negele over 1 year ago
The newest version adds an Xtensa back-end which was thorougly tested using Qemu but not on real hardware. Good luck!
RE: esp32 backend - Added by Sergey Durmanov over 1 year ago
great news! I'll try it on a real device soon. Is there a small example project with instructions on how and what to do to get a bootable image using ecs?
RE: esp32 backend - Added by Florian Negele over 1 year ago
For bare-metal programming, the ECS driver accepts the name of the architecture as target (ecsd -t xtensa ...
). This generates plain binary images (*.bin
) that contain all code and data and begin with the first executable instruction. The bootloader of the Arduino Nano ESP32 for example copies this image at address 0x1000
and then jumps to this address. Since a plain binary image is not relocatable, you need to tell the linker that the image will be located at that address. You can do that by compiling your code together with an assembly file that contains a fixed code section that typically also initialises the CPU if necessary by setting up the stack pointer for example:
.code _init_cpu
.required
.origin 0x1000
j skip
; literal data space
stack: .qbyte .origin
skip: l32r sp, stack
j padding
; aligned section extent
.align 4
padding:
If you look at the map file (*.map
) generated during linking you will see that this code section is located at address 0x1000
with all other sections following it. The skipped literal data space is required for the l32r
instruction to fill registers with immediate values that cannot be encoded in instructions directly. The padding is necessary for the correct alignment of the directly following code section.
Please note that for bare-metal programming you need to provide most runtime support by yourself. The compiler will for example typically call the _Exit function at the end of the program which is not supposed to return and could thus just loop endlessly or jump back to the start address:
.code _Exit
loop: j loop
For accessing any peripheral devices I can only show you how to access hardware registers using the ECS but cannot support with the actual devices. Good luck!