ESP32C3 build starts failing suddenly

I’m building an ESP32C3 project using PlatformIO as an extension in vscode. All has been going well until this morning, when the build started breaking. This is the output I get:

Processing usb (board: esp32-c3-devkitm-1; framework: arduino; platform: espressif32)
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
C:\Users\marc\.platformio\penv\Lib\site-packages\requests\_init_.py:86: RequestsDependencyWarning: Unable to find acceptable character detection dependency (chardet or charset_normalizer).
warnings.warn(
Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: 

PLATFORM: Espressif 32 (53.3.10) > Espressif ESP32-C3-DevKitM-1
HARDWARE: ESP32C3 160MHz, 320KB RAM, 4MB Flash
DEBUG: Current (cmsis-dap) External (cmsis-dap, esp-bridge, esp-builtin, 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)
PACKAGES:

framework-arduinoespressif32 @ 3.1.0

framework-arduinoespressif32-libs @ 5.3.0+sha.083aad99cf

tool-esptoolpy @ 4.8.5

tool-mklittlefs @ 3.2.0

tool-openocd-esp32 @ 2.1100.20220706 (11.0)

tool-riscv32-esp-elf-gdb @ 14.2.0+20240403

tool-xtensa-esp-elf-gdb @ 14.2.0+20240403

toolchain-riscv32-esp @ 13.2.0+20240530
LDF: Library Dependency Finder → 

LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 65 compatible libraries
Scanning dependencies…
Dependency Graph
|-- Syslog @ 2.0.0
|-- I2Cdevlib-AD7746 @ 1.0.0+sha.a988057
|-- DallasTemperature @ 3.11.0
|-- OneWire @ 2.3.8+sha.800f26f
|-- ArduinoJson @ 7.4.3
|-- PubSubClient @ 2.8.0
|-- Max44009 @ 0.6.2
|-- PCF8574 @ 0.4.4
|-- SHT85 @ 0.6.3
|-- typedef
|-- I2Cdevlib-Core @ 1.0.1
|-- ArduinoOTA @ 3.1.0
|-- ldebug
|-- WiFi @ 3.1.0
|-- timer
|-- Preferences @ 3.1.0
|-- Wire @ 3.1.0
Building in debug mode
Compiling .pio\build\usb\src\adc.cpp.o
Compiling .pio\build\usb\src\comm.cpp.o
Compiling .pio\build\usb\src\events.cpp.o
Compiling .pio\build\usb\src\expander.cpp.o
Compiling .pio\build\usb\src\fan.cpp.o
Compiling .pio\build\usb\src\main.cpp.o
Compiling .pio\build\usb\src\mqtt.cpp.o
Compiling .pio\build\usb\src\nvm.cpp.o
Compiling .pio\build\usb\src\rain.cpp.o
Compiling .pio\build\usb\src\remote.cpp.o
Compiling .pio\build\usb\src\sensor.cpp.o
Compiling .pio\build\usb\src\sht.cpp.o
Compiling .pio\build\usb\src\solar.cpp.o
Compiling .pio\build\usb\src\temp.cpp.o
Compiling .pio\build\usb\src\wake.cpp.o
Archiving .pio\build\usb\lib803\libPubSubClient.a
Compiling .pio\build\usb\libfb1\Max44009\Max44009.cpp.o
riscv32-esp-elf-g++: fatal error: cannot execute ‘C:/Users/marc/.platformio/packages/toolchain-riscv32-esp/bin/../lib/gcc/riscv32-esp-elf/13.2.0/../../../../riscv32-esp-elf/bin/as.exe’: CreateProcess: No such file or directory
riscv32-esp-elf-g++: fatal error: cannot execute ‘C:/Users/marc/.platformio/packages/toolchain-riscv32-esp/bin/../lib/gcc/riscv32-esp-elf/13.2.0/../../../../riscv32-esp-elf/bin/as.exe’: CreateProcess: No such file or directory
riscv32-esp-elf-g++: fatal error: cannot execute ‘C:/Users/marc/.platformio/packages/toolchain-riscv32-esp/bin/../lib/gcc/riscv32-esp-elf/13.2.0/../../../../riscv32-esp-elf/bin/as.exe’: CreateProcess: No such file or directory
riscv32-esp-elf-g++: fatal error: cannot execute ‘C:/Users/marc/.platformio/packages/toolchain-riscv32-esp/bin/../lib/gcc/riscv32-esp-elf/13.2.0/../../../../riscv32-esp-elf/bin/as.exe’: CreateProcess: No such file or directory
riscv32-esp-elf-g++: fatal error: cannot execute ‘C:/Users/marc/.platformio/packages/toolchain-riscv32-esp/bin/../lib/gcc/riscv32-esp-elf/13.2.0/../../../../riscv32-esp-elf/bin/as.exe’: CreateProcess: No such file or directory
riscv32-esp-elf-g++: fatal error: cannot execute ‘C:/Users/marc/.platformio/packages/toolchain-riscv32-esp/bin/../lib/gcc/riscv32-esp-elf/13.2.0/../../../../riscv32-esp-elf/bin/as.exe’: CreateProcess: No such file or directory
riscv32-esp-elf-g++: fatal error: cannot execute ‘C:/Users/marc/.platformio/packages/toolchain-riscv32-esp/bin/../lib/gcc/riscv32-esp-elf/13.2.0/../../../../riscv32-esp-elf/bin/as.exe’: CreateProcess: No such file or directory
compilation terminated.
compilation terminated.
compilation terminated.
compilation terminated.
compilation terminated.
compilation terminated.
compilation terminated.
*** [.pio\build\usb\src\solar.cpp.o] Error 1
*** [.pio\build\usb\src\expander.cpp.o] Error 1
*** [.pio\build\usb\src\wake.cpp.o] Error 1
*** [.pio\build\usb\src\nvm.cpp.o] Error 1
*** [.pio\build\usb\src\rain.cpp.o] Error 1
*** [.pio\build\usb\src\sht.cpp.o] Error 1
*** [.pio\build\usb\src\adc.cpp.o] Error 1
In file included from src/comm.cpp:6:
C:/Users/marc/Documents/Platformio/Lib/ldebug/ldebug.h:17:20: note: ‘#pragma message: Debug logging to syslog server is enabled’
17 |    #pragma message “Debug logging to syslog server is enabled”
|                    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
C:/Users/marc/Documents/Platformio/Lib/ldebug/ldebug.h:28:20: note: ‘#pragma message: Debug logging to the serial port is disabled’
28 |    #pragma message “Debug logging to the serial port is disabled”
|                    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from src/mqtt.cpp:9:
C:/Users/marc/Documents/Platformio/Lib/ldebug/ldebug.h:17:20: note: ‘#pragma message: Debug logging to syslog server is enabled’
17 |    #pragma message “Debug logging to syslog server is enabled”
|                    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
C:/Users/marc/Documents/Platformio/Lib/ldebug/ldebug.h:26:20: note: ‘#pragma message: Debug logging to the serial port is enabled’
26 |    #pragma message “Debug logging to the serial port is enabled”
|                    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
riscv32-esp-elf-g++: fatal error: cannot execute ‘C:/Users/marc/.platformio/packages/toolchain-riscv32-esp/bin/../lib/gcc/riscv32-esp-elf/13.2.0/../../../../riscv32-esp-elf/bin/as.exe’: CreateProcess: No such file or directory
compilation terminated.
*** [.pio\build\usb\src\temp.cpp.o] Error 1
riscv32-esp-elf-g++: fatal error: cannot execute ‘C:/Users/marc/.platformio/packages/toolchain-riscv32-esp/bin/../lib/gcc/riscv32-esp-elf/13.2.0/../../../../riscv32-esp-elf/bin/as.exe’: CreateProcess: No such file or directory
compilation terminated.
*** [.pio\build\usb\src\main.cpp.o] Error 1
riscv32-esp-elf-g++: fatal error: cannot execute ‘C:/Users/marc/.platformio/packages/toolchain-riscv32-esp/bin/../lib/gcc/riscv32-esp-elf/13.2.0/../../../../riscv32-esp-elf/bin/as.exe’: CreateProcess: No such file or directory
compilation terminated.
*** [.pio\build\usb\src\mqtt.cpp.o] Error 1
riscv32-esp-elf-g++: fatal error: cannot execute ‘C:/Users/marc/.platformio/packages/toolchain-riscv32-esp/bin/../lib/gcc/riscv32-esp-elf/13.2.0/../../../../riscv32-esp-elf/bin/as.exe’: CreateProcess: No such file or directory
compilation terminated.
*** [.pio\build\usb\src\comm.cpp.o] Error 1
riscv32-esp-elf-g++: fatal error: cannot execute ‘C:/Users/marc/.platformio/packages/toolchain-riscv32-esp/bin/../lib/gcc/riscv32-esp-elf/13.2.0/../../../../riscv32-esp-elf/bin/as.exe’: CreateProcess: No such file or directory
compilation terminated.
*** [.pio\build\usb\src\events.cpp.o] Error 1
riscv32-esp-elf-g++: fatal error: cannot execute ‘C:/Users/marc/.platformio/packages/toolchain-riscv32-esp/bin/../lib/gcc/riscv32-esp-elf/13.2.0/../../../../riscv32-esp-elf/bin/as.exe’: CreateProcess: No such file or directory
compilation terminated.
*** [.pio\build\usb\src\fan.cpp.o] Error 1
riscv32-esp-elf-g++: fatal error: cannot execute ‘C:/Users/marc/.platformio/packages/toolchain-riscv32-esp/bin/../lib/gcc/riscv32-esp-elf/13.2.0/../../../../riscv32-esp-elf/bin/as.exe’: CreateProcess: No such file or directory
compilation terminated.
*** [.pio\build\usb\src\sensor.cpp.o] Error 1
riscv32-esp-elf-g++: fatal error: cannot execute ‘C:/Users/marc/.platformio/packages/toolchain-riscv32-esp/bin/../lib/gcc/riscv32-esp-elf/13.2.0/../../../../riscv32-esp-elf/bin/as.exe’: CreateProcess: No such file or directory
compilation terminated.
*** [.pio\build\usb\src\remote.cpp.o] Error 1
============================================================================================================ [FAILED] Took 16.35 seconds ============================================================================================================

Environment    Status    Duration
-------------  --------  ------------
usb            FAILED    00:00:16.350

As you can see, some files will compile and some won’t. Here is my platformio.ini file:

[env]
board = esp32-c3-devkitm-1
framework = arduino
platform = espressif32
board_build.partitions = partitions.csv   ;huge_app.csv

monitor_speed = 115200
monitor_filters = esp32_exception_decoder
monitor_port = COM33

;build_src_filter = +<main.cpp>
build_type = debug
build_flags =
-D DEBUG
-D CONFIG_ESP_CONSOLE_NONE
-Wno-write-strings
lib_extra_dirs =
C:\Users\marc\Documents\Platformio\Lib
lib_deps =
arcao/Syslog@^2.0.0
milesburton/DallasTemperature@^3.11.0
bblanchon/ArduinoJson@^7.1
knolleary/PubSubClient@^2.8
robtillaart/Max44009@^0.6.1
robtillaart/PCF8574@^0.4.0
; sensirion/Sensirion I2C SHT3x@^1.0.1
robtillaart/SHT85@^0.6.3

[env:usb]
upload_protocol = esptool
upload_port = COM35
upload_resetmethod = nodemcu
upload_speed = 921600

[env:ota]
upload_protocol = espota
upload_port = x.x.x.x
upload_flags = --auth=admin
–port=3232

; extra_scripts = pre:resolveDeps.py
;                 pre:beforeUpload.py

I find it interesting that the path to the missing file has so many “../../../.” elements in it. It must be built from multiple parts, but it still seems odd to me. Also, I don’t have any idea whether that “character detection dependency” warning has anything to do with the compiler problems.

I have deleted the toolchain for riscV32-esp and let PlatformIO reinstall it on the next build, but that did not seem to help. I have another project with a similar platformio.ini file, and it still builds successfully. That made me try creating a fresh project and adding the files from the failed project, but it failed right away with the same compilation failures.

Bad habit: Not pinning the platform version.

Since you have used PIOarduino (https://github.com/pioarduino/platform-espressif32) once, it’s now the latest version of espressif32 rather than the official https://github.com/platformio/platform-espressif32/. Which platform / Arduino core version does your project intend to use? Properly set

platform = espressif32@6.13.0

or

platform = https://github.com/pioarduino/platform-espressif32/archive/refs/tags/53.03.10.zip

The three most common causes I’ve seen:

  • Antivirus prevents execution (disable it temporarily)
  • Path too long (enable Win32 NTFS long paths)
  • local toolchain got corrupted (delete C:\Users\<user>\.platformio\packages and rebuild)

You learn something new every day. I assumed that changing the platform back to just “espressif32” replaced any previous platforms (like pioarduino, which I tried to see if it solved a problem I was having. It didn’t, so I switched back).

I will make it a point to tie down the platform version in the future. I’m curious why the new project process does not do this for us.

Oh, yeah. I forgot to say that the solution was to replace

platform = expressif32

with

platform = espressif@6.13.0

in the platformio.ini file.

Thanks for the help.