IDE flashing does not work, CLI works

Hi, PIO noob alert. I’m trying to learn PIO with a small board and example (though I have decades of experience in embedded systems – old school, if you will, trying to get up to speed).

I have a problem where I am flashing by hand and things work, though I am not sure why when I flash the board through the IDE it fails every time.

Through the command line I got to the point that it worked perfectly somehow.

The goal is: I would like to get it to work from the IDE so that it is captured properly in the program. I just do not know enough about PIO/frameworks/platforms, etc.

The board is an ESP-C3-32S-Kit and I made a small blink example to get things to work (in RISC-V). For a long time it would not build. Through a lot of researching, trying, etc., i made it compile and flash. The ini file is shown below.

[env:esp32dev]
platform = espressif32
framework = arduino, espidf
build_flags =
    -D CONFIG_BLINK_GPIO=2
    -D ARDUINO_RUNNING_CORE=0
    -D CORE_DEBUG_LEVEL=5
monitor_speed = 115200
board = esp32-c3-devkitm-1
board_build.mcu = esp32c3
board_build.f_cpu = 160000000L
board_build.flash_size = 2MB
board_build.flash_mode = dio
board_build.partitions = partitions_2mb.csv

It would not work when flashing from the IDE arrow button, though the actual flashing appears to work without errors, however it just fails when the board attempts to run the code. It crashes after the bootloader, etc. In a clean copy of the project, I found that the partitions.bin created is different than what I found around and I placed in the project. I got this through research:

# Name,   Type, SubType, Offset,   Size
nvs,      data, nvs,     0x9000,   0x4000
otadata,  data, ota,     0xd000,   0x2000
app0,     app,  ota_0,   0x10000,  0x160000
app1,     app,  ota_1,   0x170000, 0x160000
eeprom,   data, 0x99,    0x2d0000, 0x1000
spiffs,   data, spiffs,  0x2d1000, 0x2F000

However, when I decoded the partitions.bin that worked via gen_esp32part.py (not sure how it was generated), I got this:

# ESP-IDF Partition Table
# Name, Type, SubType, Offset, Size, Flags
nvs,data,nvs,0x9000,24K,
phy_init,data,phy,0xf000,4K,
factory,app,factory,0x10000,1M,

I am not sure how I ended up with that file, as there was a LOT of trial and error while researching.

In the end, flashing from the IDE always fails and from the terminal it works. Here is the command that works (from the .pio/build/esp32dev/ folder):

esptool.py --chip esp32c3 --port /dev/tty.usbserial-110 --baud 460800  write_flash --flash_size 2MB   0x0 bootloader.bin   0x8000 partitions.bin   0x10000 firmware.bin 

When I do the flashing from the IDE, I see this:

Processing esp32dev (platform: espressif32; framework: arduino, espidf; board: esp32-c3-devkitm-1)
-------------------------------------------------------------------------------------------------------------------------------------------
Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/espressif32/esp32-c3-devkitm-1.html
PLATFORM: Espressif 32 (6.10.0) > 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.20017.241212+sha.dcc1105b 
 - framework-espidf @ 3.40407.240606 (4.4.7) 
 - tool-cmake @ 3.16.4 
 - tool-esptoolpy @ 1.40501.0 (4.5.1) 
 - tool-mkfatfs @ 2.0.1 
 - tool-mklittlefs @ 1.203.210628 (2.3) 
 - tool-mkspiffs @ 2.230.0 (2.30) 
 - tool-ninja @ 1.9.0 
 - toolchain-esp32ulp @ 1.23800.240113 (2.38.0) 
 - toolchain-riscv32-esp @ 8.4.0+2021r2-patch5
Warning! Arduino framework as an ESP-IDF component doesn't handle the `variant` field! The default `esp32` variant will be used.
Reading CMake configuration...
Warning! Flash memory size mismatch detected. Expected 4MB, found 2MB!
Please select a proper value in your `sdkconfig.defaults` or via the `menuconfig` target!
LDF: Library Dependency Finder -> https://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 33 compatible libraries
Scanning dependencies...
No dependencies
Building in release mode
Retrieving maximum program size .pio/build/esp32dev/firmware.elf
Checking size .pio/build/esp32dev/firmware.elf
Advanced Memory Usage is available via "PlatformIO Home > Project Inspect"
RAM:   [          ]   2.2% (used 7096 bytes from 327680 bytes)
Flash: [==        ]  21.1% (used 221376 bytes from 1048576 bytes)
Configuring upload protocol...
AVAILABLE: cmsis-dap, esp-bridge, esp-builtin, esp-prog, espota, esptool, iot-bus-jtag, jlink, minimodule, olimex-arm-usb-ocd, olimex-arm-usb-ocd-h, olimex-arm-usb-tiny-h, olimex-jtag-tiny, tumpa
CURRENT: upload_protocol = esptool
Looking for upload port...
Auto-detected: /dev/cu.usbserial-110
Uploading .pio/build/esp32dev/firmware.bin
esptool.py v4.5.1
Serial port /dev/cu.usbserial-110
Connecting....
Chip is ESP32-C3 (revision v0.3)
Features: WiFi, BLE
Crystal is 40MHz
MAC: 7c:df:a1:b6:a3:9c
Uploading stub...
Running stub...
Stub running...
Changing baud rate to 460800
Changed.
Configuring flash size...
Flash will be erased from 0x00000000 to 0x00004fff...
Flash will be erased from 0x00008000 to 0x00008fff...
Flash will be erased from 0x00010000 to 0x00046fff...
Compressed 20096 bytes to 12256...
Writing at 0x00000000... (100 %)
Wrote 20096 bytes (12256 compressed) at 0x00000000 in 0.7 seconds (effective 216.4 kbit/s)...
Hash of data verified.
Compressed 3072 bytes to 103...
Writing at 0x00008000... (100 %)
Wrote 3072 bytes (103 compressed) at 0x00008000 in 0.1 seconds (effective 385.3 kbit/s)...
Hash of data verified.
Compressed 223648 bytes to 115416...
Writing at 0x00010000... (12 %)
Writing at 0x0001b459... (25 %)
Writing at 0x00021ea1... (37 %)
Writing at 0x0002998e... (50 %)
Writing at 0x00030196... (62 %)
Writing at 0x00038426... (75 %)
Writing at 0x0003f35f... (87 %)
Writing at 0x0004633e... (100 %)
Wrote 223648 bytes (115416 compressed) at 0x00010000 in 4.0 seconds (effective 452.2 kbit/s)...
Hash of data verified.

Leaving...
Hard resetting via RTS pin...

I do not know why that does not work. It does look like there is a warning about detecting a 2M flash while expecting a 2MB flash (which I believe the board has).

Now, I´m bumbling around and do not know what I’m doing exacly, but somehow (somewhat directed guesswork) ended up making it work, but I am not sure how or why it works while the IDE does not.

So, to recap: is there anything that can be done to coerce the IDE to do what it has been done in the CLI flashing? i.w. so that the project and IDE captures things into doing the proper thing every time?

Thanks in advance!

HARDWARE: ESP32C3 160MHz, 320KB RAM, 4MB Flash
...
Please select a proper value in your `sdkconfig.defaults` or via the `menuconfig` target!

Did you setup things in the sdkconfig correctly? (I’m not familiar with sdkconfig / menuconfig)

Add this to your platformio.ini and check if the FLASH size is listed correctly when uploading

board_upload.maximum_size = 2097152

No, unfortunately, I never used the pio command, out of precaution (I kind of wanted to use only the UI; Also I’m not sure where it is, it’s not on my PATH and did not look further; I’m on a Mac and I did not look around for it).

Thanks for the suggestion. That did not work.

What I did try today is flashing with the UI to break things, then re-flashing only parts.

==> I found that only flashing the bootloader.bin is enough to make it work.

Here is the output of doing it via the UI:

Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/espressif32/esp32-c3-devkitm-1.html
PLATFORM: Espressif 32 (6.10.0) > Espressif ESP32-C3-DevKitM-1
HARDWARE: ESP32C3 160MHz, 320KB RAM, 2MB 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.20017.241212+sha.dcc1105b 
 - framework-espidf @ 3.40407.240606 (4.4.7) 
 - tool-cmake @ 3.16.4 
 - tool-esptoolpy @ 1.40501.0 (4.5.1) 
 - tool-mkfatfs @ 2.0.1 
 - tool-mklittlefs @ 1.203.210628 (2.3) 
 - tool-mkspiffs @ 2.230.0 (2.30) 
 - tool-ninja @ 1.9.0 
 - toolchain-esp32ulp @ 1.23800.240113 (2.38.0) 
 - toolchain-riscv32-esp @ 8.4.0+2021r2-patch5
Warning! Arduino framework as an ESP-IDF component doesn't handle the `variant` field! The default `esp32` variant will be used.
Reading CMake configuration...
Warning! Flash memory size mismatch detected. Expected 4MB, found 2MB!
Please select a proper value in your `sdkconfig.defaults` or via the `menuconfig` target!
LDF: Library Dependency Finder -> https://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 33 compatible libraries
Scanning dependencies...
No dependencies
Building in release mode
Retrieving maximum program size .pio/build/esp32dev/firmware.elf
Checking size .pio/build/esp32dev/firmware.elf
Advanced Memory Usage is available via "PlatformIO Home > Project Inspect"
RAM:   [          ]   2.2% (used 7096 bytes from 327680 bytes)
Flash: [==        ]  21.1% (used 221376 bytes from 1048576 bytes)
Configuring upload protocol...
AVAILABLE: cmsis-dap, esp-bridge, esp-builtin, esp-prog, espota, esptool, iot-bus-jtag, jlink, minimodule, olimex-arm-usb-ocd, olimex-arm-usb-ocd-h, olimex-arm-usb-tiny-h, olimex-jtag-tiny, tumpa
CURRENT: upload_protocol = esptool
Looking for upload port...
Auto-detected: /dev/cu.usbserial-110
Uploading .pio/build/esp32dev/firmware.bin
esptool.py v4.5.1
Serial port /dev/cu.usbserial-110
Connecting....
Chip is ESP32-C3 (revision v0.3)
Features: WiFi, BLE
Crystal is 40MHz
MAC: 7c:df:a1:b6:a3:9c
Uploading stub...
Running stub...
Stub running...
Changing baud rate to 460800
Changed.
Configuring flash size...
Flash will be erased from 0x00000000 to 0x00004fff...
Flash will be erased from 0x00008000 to 0x00008fff...
Flash will be erased from 0x00010000 to 0x00046fff...
Compressed 20096 bytes to 12258...
Writing at 0x00000000... (100 %)
Wrote 20096 bytes (12258 compressed) at 0x00000000 in 0.7 seconds (effective 215.8 kbit/s)...
Hash of data verified.
Compressed 3072 bytes to 103...
Writing at 0x00008000... (100 %)
Wrote 3072 bytes (103 compressed) at 0x00008000 in 0.1 seconds (effective 396.7 kbit/s)...
Hash of data verified.
Compressed 223648 bytes to 115415...
Writing at 0x00010000... (12 %)
Writing at 0x0001b459... (25 %)
Writing at 0x00021ea1... (37 %)
Writing at 0x0002998d... (50 %)
Writing at 0x0003018f... (62 %)
Writing at 0x00038426... (75 %)
Writing at 0x0003f35e... (87 %)
Writing at 0x0004633e... (100 %)
Wrote 223648 bytes (115415 compressed) at 0x00010000 in 4.0 seconds (effective 451.9 kbit/s)...
Hash of data verified.

Leaving...
Hard resetting via RTS pin...

That breaks the working state of the board.

This command is enought to bring it back:

build$ esptool.py --chip esp32c3 --port /dev/tty.usbserial-110 --baud 460800  write_flash --flash_size 2MB 0 esp32dev/bootloader.bin 
esptool.py v4.8.1
Serial port /dev/tty.usbserial-110
Connecting....
Chip is ESP32-C3 (QFN32) (revision v0.3)
Features: WiFi, BLE
Crystal is 40MHz
MAC: 7c:df:a1:b6:a3:9c
Uploading stub...
Running stub...
Stub running...
Changing baud rate to 460800
Changed.
Configuring flash size...
Flash will be erased from 0x00000000 to 0x00004fff...
Flash params set to 0x021f
SHA digest in image updated
Compressed 20096 bytes to 12260...
Wrote 20096 bytes (12260 compressed) at 0x00000000 in 0.7 seconds (effective 215.7 kbit/s)...
Hash of data verified.

Leaving...
Hard resetting via RTS pin...

Now, to complete the information, let me share what the serial monitor shows after flashing from the UI (i.e. not working):

---- Opened the serial port /dev/tty.usbserial-110 ----
ESP-ROM:esp32c3-api1-20210207
Build:Feb  7 2021
rst:0x1 (POWERON),boot:0xc (SPI_FAST_FLASH_BOOT)
SPIWP:0xee
mode:DIO, clock div:1
load:0x3fcd5810,len:0x1684
load:0x403cc710,len:0x934
load:0x403ce710,len:0x2e74
entry 0x403cc710
I (30) boot: ESP-IDF 4.4.7 2nd stage bootloader
I (30) boot: compile time 10:37:14
I (30) boot: chip revision: v0.3
I (32) boot.esp32c3: SPI Speed      : 80MHz
I (37) boot.esp32c3: SPI Mode       : DIO
I (42) boot.esp32c3: SPI Flash Size : 4MB
I (46) boot: Enabling RNG early entropy source...
I (52) boot: Partition Table:
I (55) boot: ## Label            Usage          Type ST Offset   Length
I (63) boot:  0 nvs              WiFi data        01 02 00009000 00006000
I (70) boot:  1 phy_init         RF data          01 01 0000f000 00001000
I (77) boot:  2 factory          factory app      00 00 00010000 00100000
I (85) boot: End of partition table
I (89) esp_image: segment 0: paddr=00010020 vaddr=3c020020 size=0ab48h ( 43848) map
I (105) esp_image: segment 1: paddr=0001ab70 vaddr=3fc8c200 size=00be8h (  3048) load
I (106) esp_image: segment 2: paddr=0001b760 vaddr=40380000 size=048b8h ( 18616) load
I (118) esp_image: segment 3: paddr=00020020 vaddr=42000020 size=1f168h (127336) map
I (143) esp_image: segment 4: paddr=0003f190 vaddr=403848b8 size=077e0h ( 30688) load
I (153) boot: Loaded app from partition at offset 0x10000
I (153) boot: Disabling RNG early entropy source...
I (164) cpu_start: Unicore app
I (164) cpu_start: Pro cpu up.
I (173) cpu_start: Pro cpu start user code
I (173) cpu_start: cpu freq: 160000000
I (173) cpu_start: Application information:
I (176) cpu_start: Project name:     vec-flashrom-fw
I (181) cpu_start: App version:      1
I (186) cpu_start: Compile time:     May 29 2025 10:36:52
I (192) cpu_start: ELF file SHA256:  7b77de9c69b8e048...
I (198) cpu_start: ESP-IDF:          4.4.7
I (203) cpu_start: Min chip rev:     v0.3
I (207) cpu_start: Max chip rev:     v1.99 
I (212) cpu_start: Chip rev:         v0.3
I (217) heap_init: Initializing. RAM available for dynamic allocation:
I (224) heap_init: At 3FC8DDC0 len 0004E950 (314 KiB): DRAM
I (230) heap_init: At 3FCDC710 len 00002950 (10 KiB): STACK/DRAM
I (237) heap_init: At 50000020 len 00001FE0 (7 KiB): RTCRAM
I (244) spi_flash: detected chip: generic
I (248) spi_flash: flash io: dio
E (252) spi_flash: Detected size(2048k) smaller than the size in the binary image header(4096k). Probe failed.

assert failed: do_core_init startup.c:328 (flash_ret == ESP_OK)
Core  0 register dump:
MEPC    : 0x40380bae  RA      : 0x403854b2  SP      : 0x3fcde190  GP      : 0x3fc8ca00  
TP      : 0x00000000  T0      : 0x37363534  T1      : 0x7271706f  T2      : 0x33323130  
S0/FP   : 0x00000088  S1      : 0x00000001  A0      : 0x3fcde1cc  A1      : 0x3fc8c791  
A2      : 0x00000001  A3      : 0x00000029  A4      : 0x00000001  A5      : 0x3fc8e000  
A6      : 0x7a797877  A7      : 0x76757473  S2      : 0x00000009  S3      : 0x3fcde2df  
S4      : 0x3fc8c790  S5      : 0x00020020  S6      : 0x00000000  S7      : 0x3fcd6000  
S8      : 0x3c020020  S9      : 0x00010020  S10     : 0x00000005  S11     : 0x3fcde3c0  
T3      : 0x6e6d6c6b  T4      : 0x6a696867  T5      : 0x66656463  T6      : 0x62613938  
MSTATUS : 0x00001881  MTVEC   : 0x40380001  MCAUSE  : 0x00000007  MTVAL   : 0x00000000  
MHARTID : 0x00000000  

Stack memory:
3fcde190: 0x3c025b40 0x00000079 0x3c022818 0x4038ad34 0x3fc8c878 0x3c022818 0x3fc8c85c 0x3c02287b
...

Hopefully that helps? :slight_smile:

That’s not about PIO this is about seting up ESP-IDF framework correctly.

Just to be sure, do you really intend to create an “Arduino as ESP-IDF Component” project (with all it’s consequences)? Or do you only want to create a “normal” Arduino project?

I found how to properly run the menuconfig (pio run -t menuconfig) and ran it. I went to the flash size setting and it was already at 2MB.

In addition I went through most options and there wasn’t anything that seemed obviously off for me, keeping in mind that I am new to all this, especially pio menuconfig and the role of the default.

I did add this to the sdkconfig.defaults (though it is in sdkconfig.esp32dev) and it did not seem to help.

CONFIG_ESPTOOLPY_FLASHSIZE="2MB"

Specifically, this message was still showing when flashing via the UI:

Warning! Flash memory size mismatch detected. Expected 4MB, found 2MB!
Please select a proper value in your `sdkconfig.defaults` or via the `menuconfig` target!

I did not state my ultimate goal at the beginning because it’s a little out of context. At the moment I just wanted a base to get going with that would work reliably and then go from there.

The ultimate goal is a bit far fetched at the moment: I want a prototype environment similar to the hardware I will eventually have. I’m part of a team that is taping out a chip that has a component to control it that is MCU-like. It’s a RISC-V PULP-like block in the chip. I will have to develop software for it, which will be inside an external flash. I have a skeleton of what will be the software and wanted to start prototyping it in a similar hardware platform (I have developed a simple-ish qemu emulator for some parts of this MCU block). In anticipation of possible chip defects, I may have to “come into the chip” via an SPI-ethernet device that talk to this MCU block. I wanted to be able to prototype things: 1) a minimal OS (I found FreeRTOS and that seems to work well and have small footprint for what we need and allow for multiple drivers), 2) a modern development environment (PIO), 3) and eventually, I hope, a decent debugging environment for this code (with some yet to be determined probe).

At the moment, I see that what’s generated is a little fat, however, I have SOME basic blink going that also has serial monitoring working, and that’s a great start.

Hopefully that makes sense, though I just wanted a base that it’s as UI friendly as possible, as I will hope to share this with others in the team that may not know about PIO, VS code, etc.

Ok, since you’re not interested in the Espressif specific stuff (ESP-IDF) we should keep things as simple as possible and switch over to the Arduino framework and try to bring up the board running correctly. The underlying ESP-IDF and FreeRTOS functions are still available to you.

Unfortunately that’s a “strange” board with just 2 MB (just my opinion)

Change your platformio.ini to

[env:esp32-c3-devkitm-1]
platform = espressif32
board = esp32-c3-devkitm-1
framework = arduino
monitor_speed = 115200
board_upload.maximum_size = 2097152
board_build.flash_size = 2MB
board_build.flash_mode = dio
board_build.partitions = partitions_2mb.csv

And try a very basic sketch:

#include <Arduino.h>

void setup() {
    Serial.begin(115200);
}

void loop() {
    Serial.println("Hello World");
    delay(1000);
}

Edit:

  • Close VS-Code
  • Delete the .pio folder (inside the project folder)
  • Restart VS-Code

Hi, thanks for your help. I started a new, clean, project, with what you suggest. It fails in much the same way: GUI build+flash does not work, CLI flashing just the bootloader.bin works and serial works.

When it fails, this is what’s on the terminal:

 *  Executing task: platformio run --target upload 

Processing esp32-c3-devkitm-1 (platform: espressif32; board: esp32-c3-devkitm-1; framework: arduino)
------------------------------------------------------------------------------------------------------------------------------------------------
Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/espressif32/esp32-c3-devkitm-1.html
PLATFORM: Espressif 32 (6.10.0) > Espressif ESP32-C3-DevKitM-1
HARDWARE: ESP32C3 160MHz, 320KB RAM, 2MB 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.20017.241212+sha.dcc1105b 
 - tool-esptoolpy @ 1.40501.0 (4.5.1) 
 - tool-mkfatfs @ 2.0.1 
 - tool-mklittlefs @ 1.203.210628 (2.3) 
 - tool-mkspiffs @ 2.230.0 (2.30) 
 - toolchain-riscv32-esp @ 8.4.0+2021r2-patch5
LDF: Library Dependency Finder -> https://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 33 compatible libraries
Scanning dependencies...
No dependencies
Building in release mode
Retrieving maximum program size .pio/build/esp32-c3-devkitm-1/firmware.elf
Checking size .pio/build/esp32-c3-devkitm-1/firmware.elf
Advanced Memory Usage is available via "PlatformIO Home > Project Inspect"
RAM:   [          ]   4.2% (used 13748 bytes from 327680 bytes)
Flash: [==        ]  23.6% (used 247468 bytes from 1048576 bytes)
Configuring upload protocol...
AVAILABLE: cmsis-dap, esp-bridge, esp-builtin, esp-prog, espota, esptool, iot-bus-jtag, jlink, minimodule, olimex-arm-usb-ocd, olimex-arm-usb-ocd-h, olimex-arm-usb-tiny-h, olimex-jtag-tiny, tumpa
CURRENT: upload_protocol = esptool
Looking for upload port...
Auto-detected: /dev/cu.usbserial-110
Uploading .pio/build/esp32-c3-devkitm-1/firmware.bin
esptool.py v4.5.1
Serial port /dev/cu.usbserial-110
Connecting....
Chip is ESP32-C3 (revision v0.3)
Features: WiFi, BLE
Crystal is 40MHz
MAC: 7c:df:a1:b6:a3:9c
Uploading stub...
Running stub...
Stub running...
Changing baud rate to 460800
Changed.
Configuring flash size...
Flash will be erased from 0x00000000 to 0x00003fff...
Flash will be erased from 0x00008000 to 0x00008fff...
Flash will be erased from 0x0000e000 to 0x0000ffff...
Flash will be erased from 0x00010000 to 0x0004ffff...
Compressed 12464 bytes to 9065...
Writing at 0x00000000... (100 %)
Wrote 12464 bytes (9065 compressed) at 0x00000000 in 0.6 seconds (effective 176.4 kbit/s)...
Hash of data verified.
Compressed 3072 bytes to 103...
Writing at 0x00008000... (100 %)
Wrote 3072 bytes (103 compressed) at 0x00008000 in 0.1 seconds (effective 261.6 kbit/s)...
Hash of data verified.
Compressed 8192 bytes to 47...
Writing at 0x0000e000... (100 %)
Wrote 8192 bytes (47 compressed) at 0x0000e000 in 0.2 seconds (effective 427.6 kbit/s)...
Hash of data verified.
Compressed 258864 bytes to 143469...
Writing at 0x00010000... (11 %)
Writing at 0x0001b28e... (22 %)
Writing at 0x00022d16... (33 %)
Writing at 0x00029904... (44 %)
Writing at 0x0002f99a... (55 %)
Writing at 0x00035b32... (66 %)
Writing at 0x0003be08... (77 %)
Writing at 0x00044570... (88 %)
Writing at 0x0004a4f0... (100 %)
Wrote 258864 bytes (143469 compressed) at 0x00010000 in 4.5 seconds (effective 458.5 kbit/s)...
Hash of data verified.

Leaving...
Hard resetting via RTS pin...
========================================================= [SUCCESS] Took 8.55 seconds =========================================================
 *  Terminal will be reused by tasks, press any key to close it. 

and this is what’s coming out of the serial:

---- Opened the serial port /dev/tty.usbserial-110 ----
ESP-ROM:esp32c3-api1-20210207
Build:Feb  7 2021
rst:0x1 (POWERON),boot:0xc (SPI_FAST_FLASH_BOOT)
SPIWP:0xee
mode:DIO, clock div:1
load:0x3fcd5810,len:0x38c
load:0x403cc710,len:0x6a0
load:0x403ce710,len:0x2624
entry 0x403cc710
E (81) spi_flash: Detected size(2048k) smaller than the size in the binary image header(4096k). Probe failed.

assert failed: do_core_init startup.c:328 (flash_ret == ESP_OK)
Core  0 register dump:
MEPC    : 0x40381c5c  RA      : 0x40384d96  SP      : 0x3fcde190  GP      : 0x3fc8ba00  
TP      : 0x00000000  T0      : 0x37363534  T1      : 0x7271706f  T2      : 0x33323130  
S0/FP   : 0x3fcde2ff  S1      : 0x00000088  A0      : 0x3fcde1f4  A1      : 0x3fc8c785  
A2      : 0x00000001  A3      : 0x00000029  A4      : 0x00000001  A5      : 0x3fc8e000  
A6      : 0x7a797877  A7      : 0x76757473  S2      : 0x3fcde1e8  S3      : 0x00000001  
S4      : 0x3fcde1e8  S5      : 0x4200b862  S6      : 0x42000020  S7      : 0x3c030020  
S8      : 0x00010020  S9      : 0x00000000  S10     : 0x00000000  S11     : 0x00000000  
T3      : 0x6e6d6c6b  T4      : 0x6a696867  T5      : 0x66656463  T6      : 0x62613938  
MSTATUS : 0x00001801  MTVEC   : 0x40380001  MCAUSE  : 0x00000007  MTVAL   : 0x00000000  
MHARTID : 0x00000000  

Stack memory:
3fcde190: 0x34303936 0x00001004 0x3c032b4c 0x40389d9a 0x3fcdc710 0x3fcdf060 0xb33fffff 0x3fc8c784
3fcde1b0: 0x00000000 0x0000006d 0x0000000a 0x00383233 0x400481b0 0x3fc8c86c 0x3c032b4c 0x3fc8c850
3fcde1d0: 0x3c032baf 0x3fc8c87c 0x3fcde1bc 0x3fc8c880 0x3c032c04 0x3fc8c784 0x00000000 0x00000000
3fcde1f0: 0x36000000 0x65737361 0x66207472 0x656c6961 0x64203a64 0x6f635f6f 0x695f6572 0x2074696e
3fcde210: 0x72617473 0x2e707574 0x32333a63 0x66282038 0x6873616c 0x7465725f 0x203d3d20 0x5f505345
3fcde230: 0x00294b4f 0x00000000 0x40381892 0x3fc8de10 0x3fcdf5c0 0x3fc8b6ac 0x00000104 0x40048722
3fcde250: 0x00000054 0x00000000 0x00000003 0x00000000 0x3fc8b680 0x00000000 0x3fc8b6ac 0x3fcde284
3fcde270: 0x00000000 0x00000000 0x005e6015 0x420073ec 0x42000020 0x00000051 0x3c032130 0x00000800
3fcde290: 0x00001000 0x000003e8 0x00000000 0x03ffffff 0x42000020 0x00000000 0x00000000 0x00000001
3fcde2b0: 0x00000000 0x00000001 0x00000000 0x00000000 0x00000000 0x00000000 0x40381892 0x3fc8de10
3fcde2d0: 0x3c033000 0x3c033000 0x3fce0000 0x4200b862 0x00000001 0x000001e0 0x00000101 0x4200fdce
3fcde2f0: 0x00000001 0x00000000 0x40381892 0x00020020 0x0000003e 0x00000001 0x00000000 0x40381a82
3fcde310: 0xc2d81148 0x3ff1c14c 0x00000000 0x00000007 0x00ffffff 0x3fcd0101 0x00000000 0x7fffffff
3fcde330: 0xffff0000 0x00035177 0x00035197 0x403cf5e8 0x00010000 0x00100000 0x00000000 0x3fcdf000
3fcde350: 0x00003080 0x3ff1c14c 0x0000ffff 0xffffffff 0xffffffff 0x3fcde4b0 0xffffffff 0x403cf9a8
3fcde370: 0xc7a22105 0x00010000 0x00100000 0x00010000 0x2f0205e9 0x40381892 0x000000ee 0x00000005
3fcde390: 0x00ffff00 0x01000000 0x3c030020 0x0000d3b0 0x3fc8b200 0x00001cb4 0x40380000 0x00000f84
3fcde3b0: 0x42000020 0x00025178 0x40380f84 0x0000a160 0x00000000 0x00000000 0x00000000 0x00000000
3fcde3d0: 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000
3fcde3f0: 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000
3fcde410: 0x00000000 0x00000000 0x00010020 0x0001d3d8 0x0001f094 0x00020020 0x000451a0 0x00000000
3fcde430: 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000
3fcde450: 0x00000000 0x00000000 0x0003f330 0xc2d81148 0x584d832a 0xc311af06 0x3c407cf2 0x978b759b
3fcde470: 0x74ffa21d 0x920cb240 0xfb93d21a 0x00000000 0x400481b0 0x00000010 0x0000000a 0x3fce0000
3fcde490: 0x00000000 0x0000004b 0x00003090 0x403cc770 0x10fccc6e 0x01aef9ef 0x00000000 0xffffffff
3fcde4b0: 0x00000000 0x00000000 0x00010000 0x00100000 0x00000000 0x00000000 0x00000000 0x00000000
3fcde4d0: 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000
3fcde4f0: 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000
3fcde510: 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000
3fcde530: 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000
3fcde550: 0x600c5200 0x600c5200 0x00000000 0x4004a296 0xe606a5fe 0x83f7e2d1 0x3fcde668 0x00000000
3fcde570: 0xffffff63 0x00000000 0x00010000 0x2f0203e9 0x403cc710 0x403ce710 0x00002624 0x000000ee



ELF file SHA256: 5f13e727108fa3b2

E (480) esp_core_dump_flash: Core dump flash config is corrupted! CRC=0x7bd5c66f instead of 0x0
Rebooting...
ESP-ROM:esp32c3-api1-20210207
Build:Feb  7 2021
rst:0x3 (RTC_SW_SYS_RST),boot:0xc (SPI_FAST_FLASH_BOOT)
....
(repeat)

When it works, with this flash command,

build$ esptool.py --chip esp32c3 --port /dev/tty.usbserial-110 --baud 460800  write_flash --flash_size 2MB 0 esp32-c3-devkitm-1/bootloader.bin  
esptool.py v4.8.1
Serial port /dev/tty.usbserial-110
Connecting....
Chip is ESP32-C3 (QFN32) (revision v0.3)
Features: WiFi, BLE
Crystal is 40MHz
MAC: 7c:df:a1:b6:a3:9c
Uploading stub...
Running stub...
Stub running...
Changing baud rate to 460800
Changed.
Configuring flash size...
Flash will be erased from 0x00000000 to 0x00003fff...
Flash params set to 0x021f
SHA digest in image updated
Compressed 12464 bytes to 9065...
Wrote 12464 bytes (9065 compressed) at 0x00000000 in 0.6 seconds (effective 176.3 kbit/s)...
Hash of data verified.

Leaving...
Hard resetting via RTS pin...

… this is what comes out from the serials when it works:

---- Opened the serial port /dev/tty.usbserial-110 ----
ESP-ROM:esp32c3-api1-20210207
Build:Feb  7 2021
rst:0x1 (POWERON),boot:0xc (SPI_FAST_FLASH_BOOT)
SPIWP:0xee
mode:DIO, clock div:1
load:0x3fcd5810,len:0x38c
load:0x403cc710,len:0x6a0
load:0x403ce710,len:0x2624
entry 0x403cc710
E (82) esp_core_dump_flash: No core dump partit)�Hello World
Hello World
Hello World
Hello World
Hello World
Hello World
---- Closed the serial port /dev/tty.usbserial-110 ----

Ah, i think here is the issue…It must be board_upload.flash_size not board_build.flash_size.

Please change the platformio.ini to

[env:esp32-c3-devkitm-1]
platform = espressif32
board = esp32-c3-devkitm-1
framework = arduino
monitor_speed = 115200
board_upload.maximum_size = 2097152
board_upload.flash_size = 2MB
board_build.flash_mode = dio
board_build.partitions = partitions_2mb.csv

Aha! We got to be working from the UI!! Thank you!!

  1. How did you obtain that board_upload.flash_size? I think it’s inside the upload section of a .json file for the board (I have read it somewhere for other boards), but unsure where this file is in my case.

  2. I tried looking for the minimal setup that works. I tried removing the partitions_2mb.csv and that is necessary (there is a reboot hang after the bootloader). However, this next two lines do appear to not be necessary: board_upload.maximum_size = 2097152 and board_build.flash_mode = dio
    ==> Will it be ok to remove these two to get to a minimal setup?

  3. That said, back to the top goal.
    Because my (partially existing) code is in C and at some point I will need to possibly use drivers for SPI-ethernet, I figure I need parallel tasks and FreeRTOS.
    That is why I explored the possibility of having ESP-IDF, because I saw it was bringing FreeRTOS.
    If you don’t mind me asking, could you point me towards the simplest way to achieve potentially sophisticated drivers for SPI flash, SPI-ethernet, SPI-OLED? Is FreeRTOS advisable?
    ==> If so, how do I go about it? ==> If not, what would you advice?

Thanks again!!

  1. You’re using the esp32-c3-devkitm-1 board which leads to this settings:

Since your board has only 2 MB these settings must be modified to 2 MB

  1. I think this is the minimal setup. The default.csv (which will be used automatically) is for 4 MB boards. Alternatively you can create your own custom board manifest esp-c3-32s-kit.json with the 2mb settings in there. SImply take the esp32-c3-devkitm-1 as a reference and modify the values.

  2. In an Espressif32 Arduino sketch, the underlying ESP-IDF and FreeRTOS functions are available to you. Simply call xTaskCreate(...) to create a new task. But remember, Espressif is using a modified FreeRTOS, not a vanilla one. But switching back to a pure ESP-IDF project should also now possible.

1 Like

Thanks for your answers!

BTW, anything to worry about from this line?

Making sure it will not rear at some point later … (e.g. when I try to set up debugging) …

The core dump partition is a 64 kb sized partition which takes a stack trace when a crash happens. It is not mandatory, but helps with troubleshooting after a crash.

Since your partition table lacks such a partition, you’ll get the warning.