Build failed on new ESP32 project - xtensa g++ compiler not found #3713

Using VSCode / Platform IO IDE installed on Raspberry PI4.

Created a new projet “Test”

plaformio.ini ;
platform = espressif32
board = esp32dev
framework = arduino

when I build the project I’ve an errror for xtensa g++ not found.
Also I got an error for <Arduino.h> missing stdbool.h include file (not in include path)

vscode and platformio IDE reinstalled.
Running on Raspberry PI4 - Linux raspberrypi 6.1.21-v8+
debian version 11.6

PlatformIO IDE 3.1.1
VSCode V1.76.0

.vscode and .platformio removed → not solving issue.

  • Exécution de la tâche dans le dossier Test : platformio run

Processing esp32dev (platform: espressif32; board: esp32dev; framework: arduino)

Verbose mode can be enabled via -v, --verbose option
CONFIGURATION: Redirecting...
PLATFORM: Espressif 32 (6.1.0) > Espressif ESP32 Dev Module
HARDWARE: ESP32 240MHz, 320KB RAM, 4MB Flash
DEBUG: Current (cmsis-dap) External (cmsis-dap, esp-bridge, esp-prog, iot-bus-jtag, jlink, minimodule, olimex-arm-usb-ocd, olimex-arm-usb-ocd-h, olimex-arm-usb-tiny-h, olimex-jtag-tiny, tumpa)

  • framework-arduinoespressif32 @ 3.20007.0 (2.0.7)
  • tool-esptoolpy @ 1.40500.0 (4.5.0)
  • toolchain-xtensa-esp32 @ 8.4.0+2021r2-patch5
    LDF: Library Dependency Finder → Library Dependency Finder (LDF) — PlatformIO latest documentation
    LDF Modes: Finder ~ chain, Compatibility ~ soft
    Found 33 compatible libraries
    Scanning dependencies…
    No dependencies
    Building in release mode
    Compiling .pio/build/esp32dev/src/main.cpp.o
    sh: 1: xtensa-esp32-elf-g++: not found
    Building .pio/build/esp32dev/bootloader.bin
    Generating partitions .pio/build/esp32dev/partitions.bin v4.5
    Creating esp32 image…
    Merged 1 ELF section
    Successfully created esp32 image.
    Compiling .pio/build/esp32dev/FrameworkArduino/Esp.cpp.o
    *** [.pio/build/esp32dev/src/main.cpp.o] Error 127
    sh: 1: xtensa-esp32-elf-g++: not found

Some additionnal comments ;

pi@raspberrypi:~ $ uname -a
Linux raspberrypi 6.1.21-v8+ #1642 SMP PREEMPT Mon Apr 3 17:24:16 BST 2023 aarch64 GNU/Linux
pi@raspberrypi:~ $ find /home/pi/.platformio -name “xtensa-esp32-elf-g++” -print
pi@raspberrypi:~ $ file /home/pi/.platformio/packages/toolchain-xtensa-esp32/bin/xtensa-esp32-elf-g++
/home/pi/.platformio/packages/toolchain-xtensa-esp32/bin/xtensa-esp32-elf-g++: ELF 64-bit LSB executable, ARM aarch64, version 1 (SYSV), dynamically linked, interpreter /lib/, for GNU/Linux 3.7.0, BuildID[sha1]=abfed9e5893019faebfd4748833b6357f5cfe614, stripped
pi@raspberrypi:~ $ /home/pi/.platformio/packages/toolchain-xtensa-esp32/bin/xtensa-esp32-elf-g++
bash: /home/pi/.platformio/packages/toolchain-xtensa-esp32/bin/xtensa-esp32-elf-g++: Aucun fichier ou dossier de ce type

→ Maybe is that G++ is ELF64bit with interpreter /lib/,
And is missing…
pi@raspberrypi:~ $ ll /lib/ld-linux*
lrwxrwxrwx 1 root root 30 18 oct. 2022 /lib/ → arm-linux-gnueabihf/
lrwxrwxrwx 1 root root 24 30 oct. 2021 /lib/ → /lib/

Are you running a 32-bit Raspbian on a 64-bit capable Raspberry Pi?

I think Yes… After a apt-get update && apt-get upgrade

I’m looking to boot a 32 bit kernel
may I can also upgrade to 64bit Raspbian… and reconfigure my server

What’s the output of pio system info?

pi@raspberrypi:~ $ .platformio/penv/bin/pio system info
--------------------------  ---------------------------------------
PlatformIO Core             6.1.7
Python                      3.9.2-final.0
System Type                 linux_aarch64
Platform                    Linux-6.1.21-v8+-aarch64-with-glibc2.31
File System Encoding        utf-8
Locale Encoding             UTF-8
PlatformIO Core Directory   /home/pi/.platformio
PlatformIO Core Executable  platformio
Python Executable           /home/pi/.platformio/penv/bin/python
Global Libraries            0
Development Platforms       2
Tools & Toolchains          7

Identifying a 64bit arch…

So uname -a says aarch64. The platform returned by Python says aarch64. PlatformIO thinks you’re on aarch64. But… you’re not running a 64-bit kernel.

I’m not sure whether PlatformIO is doing something wrong here or whether the state of your system is screwy.

In any case, things should be resolved if you get a clean 64-bit (preferred) raspbian image installed on the Pi.

If you think PlatformIO should detect this case and give you the ARMv7l (32-bit) binaries, file a bug in Issues · platformio/platformio-core · GitHub.

Tks a lot for this.
It’s more clear for me.

I’ve created an issue and it is closed now → post pb here…
Maybe too long to wait this to solve aarch64 kernel on Raspbian 32bit.

I’m looking a workaround to boot a 32 bit kernel.

And for long time reinstall a Raspbian OS 64Bit on my Pi4. I’ve an old Pi3 that can run my current config and renstall my config.

See here. issue “After updating 32 bit Raspi OS Pi 4 is on 64bit kernel”

Workaround is

The switch to running a 64-bit kernel by default on Pi 4 is intentional.
We believe it gives a better experience with few drawbacks.
As you've found, you can revert to the 32-bit kernel by adding `arm_64bit=0` to config.txt.

See for more details.

And also some comments

A 64-bit OS requires a 64-bit kernel.
A 32-bit OS can use a 32-bit or 64-bit kernel.

So add line “arm_64bit=0” at the end of /boot/config.txt in section pi4

# Run as fast as firmware / board allows


And reboot.
Reinstallation of PlatformIO will work fine after.