Can Arduino CLI customize ESP32 core dumps config with custom parition and download it?

Hi all :waving_hand:

I’ve successfully collected and decoded ESP32 core dumps using PlatformIO, custom partition tables, and esp-coredump. I’m wondering if it’s possible to replicate this setup using Arduino CLI only.

The setup involves:
• Enabling ESP32 core dumps in ELF format to a dedicated flash partition, and
• Using a custom partitions.csv, and
• Triggering a crash with a sketch with PlatformIO
• Retrieving and decoding the core dump using esp-coredump (I ended up installing the entire esptools with ESP-IDF in VS Code)

All details are available here in a GitHub repo:

My Questions:
1. Can I pass custom Kconfig-style flags (like CONFIG_ESP_COREDUMP_...) via Arduino CLI?
2. Can a custom partitions.csv from Arduino CLI be used?
3. Any recommended workflow to retrieve the core dump from flash in an Arduino CLI project? (Maybe the closest: GitHub - earlephilhower/arduino-littlefs-upload: Build and uploads LittleFS filesystems for the Arduino-Pico RP2040, RP2350, ESP8266, and ESP32 cores under Arduino IDE 2.2.1 or higher)

If this isn’t fully supported yet, I would like to understand which pieces are missing and whether there's a way to hook into them (e.g., with custom build scripts or hooks. If they're missing, has anybody asked for such features?

Hi @dankeboy36.

Yes.

The "esp32" boards platform follows the standard convention of providing a set of "extra_flags" properties which the user can use to inject arbitrary arguments into the commands Arduino CLI uses to compile the sketch.

Here you see the empty definitions of the properties, which are used as a fallback when the user does not define the properties:

and here you see the properties referenced in the compilation command patterns:

(note the {compiler.c.extra_flags})

(note the {compiler.cpp.extra_flags})

You can define these properties with arbitrary values by using the --build-property flag of the arduino-cli compile command. For example, if you want to define a global macro named CONFIG_ESP_COREDUMP_ENABLE with the value 1, and another global macro named CONFIG_ESP_COREDUMP_DATA_FORMAT_ELF with the value 1 when compiling C and C++ language files (which includes .ino files), then you would run a command like this:

arduino-cli compile --build-property "compiler.c.extra_flags=-D CONFIG_ESP_COREDUMP_ENABLE=1 -D CONFIG_ESP_COREDUMP_DATA_FORMAT_ELF=1" --build-property "compiler.cpp.extra_flags=-D CONFIG_ESP_COREDUMP_ENABLE=1 -D CONFIG_ESP_COREDUMP_DATA_FORMAT_ELF=1"

If the sketch folder contains a file named partitions.csv, then that file will be used:

If the build folder contains a file named partitions.csv, then that file will be used:

I'm not knowledgeable on this subject. Hopefully one of the other forum helpers will be able to provide some advice. Are you set on using Arduino CLI for this operation? I ask because it seems to me that you should be able to use the esp-coredump tool with the .elf file generated by compiling a sketch using Arduino CLI, using the same procedure as you used with PlatformIO:

https://github.com/kittaakos/esp32-coredump-guide#6-retrieve-and-decode-core-dump

GDB is one of the tool dependencies of the esp32:esp32 platform, and thus is installed by arduino-cli core install esp32:esp32. So you should be able to use that existing installation to fulfill the "esp-gdb" dependency of the esp-coredump tool. The platform tool dependency will be installed by Arduino CLI under <directories.data>/packages/esp32/tools/xtensa-esp-elf-gdb (for the ESP32 microcontrollers that use an Xtensa IP core) and <directories.data>/packages/esp32/tools/riscv32-esp-elf-gdb (for the ESP32 microcontrollers that use a RISC-V IP core).

Thank you! I managed to simplify my toolchain significantly. Here are the updated steps using the Arduino CLI only: esp32-coredump-guide/README.md at 18c1a7074f9b452b48263249c7365b1a6716087d · kittaakos/esp32-coredump-guide · GitHub.

You are welcome. I'm glad that it was possible to accomplish using Arduino CLI. Great news that it resulted in a more simplified workflow!

Regards, Per