After PlatformIO update, firmware keeps rebooting

Hello all,

something strange is happening.
I have a firmware for ESP32 which has been properly working for the last months.
Last friday I updated something on the PlatformIO IDE (perhaps the IDE itself or some libraries) and now my ESP32 keeps rebooting.

The log is:

ets Jul 29 2019 12:21:46

rst:0xc (SW_CPU_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
mode:DIO, clock div:2
entry 0x400805e4
ESP_ERROR_CHECK failed: esp_err_t 0x103 (ESP_ERR_INVALID_STATE) at 0x40088464
file: "lib/TimersManager/TimersManager.cpp" line 79
func: void TimersManager::Timer_Frame_Begin()
expression: esp_timer_create(&timer_args, &timer_frame)

abort() was called at PC 0x40088467 on core 0

Backtrace:0x40082fdd:0x3ffe3ab00x40088471:0x3ffe3ad0 0x4008d9cd:0x3ffe3af0 0x40088467:0x3ffe3b70 0x400d1dac:0x3ffe3b90 0x400d1ca1:0x3ffe3bd0 0x400d1cde:0x3ffe3bf0 0x400da27f:0x3ffe3c10 0x4008288d:0x3ffe3c40 0x400791f2:0x3ffe3c90  |<-CORRUPTED

ELF file SHA256: 0000000000000000


The code indicated in the log is the following:

void TimersManager::Timer_Frame_Begin()
    esp_timer_create_args_t timer_args;
    timer_args = {
        .callback = frame_callback,
        .arg = NULL,
        .dispatch_method = ESP_TIMER_TASK

    ESP_ERROR_CHECK(esp_timer_create(&timer_args, &timer_frame));   <--- THIS IS LINE 79
    ESP_ERROR_CHECK(esp_timer_start_periodic(timer_frame, period_frame_us));       

I want to specify that I asked some my colleague to flash the same code from their PC and it’s running.
I also just tried to uninstall and re-install VS Code and PlatformIO without success: it keeps crashing.

Can someone help me?

Thank you

The Arduino-ESP32 framework was updated from 1.0.6 to 2.0.2. Your firmware or libraries that it uses might not be compatible (or Arduino-ESP32 might have a bug).

Try changing the platform = espressif32 to platform = espressif32@3.5.0 in the platformio.ini. Does it still crash?

Great! It worked!

Thank you very much :slight_smile:

BTW, the only way to get a ESP_ERR_INVALID_STATE return value from esp_timer_create() is through the codepath

So I guess “something” does not call

but this is supposed to be called on system startup

Are you executing the TimersManager::Timer_Frame_Begin() in a constructor before the SDK has had a chance to be initialized? This might have been already “illegal” / weird in the 1.0.6 core, but made to abort in 2.0.2. In that case you should restructure the code to not add timers in the constructor but add a init()/ begin() method that you can call in setup() when the system is fully initialized. Maybe then your firmware runs with the 2.0.2 core.