ESP32 OTA Partition Could Not be Found


I am trying to get familiar with OTAs.
Therefore I’ve setup a small project with my ESP32 (DoIT DevKit).

My platformio.ini looks like this:

platform = espressif32
board = esp32doit-devkit-v1
framework = arduino, espidf
monitor_speed = 115200
build_flags = 
    '-D WIFI_PW="MY_PW"'

extends = env:serial
upload_protocol = espota
upload_port =

I’ve successfully connected the ESP32 to my Wifi.
The main.cpp looks like this

#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "driver/gpio.h"
#include "InterruptButton.h"
#include "WiFi.h"
#include "ArduinoOTA.h"
#include "nvs_flash.h"
#include "esp_err.h"

const char *ssid = WIFI_SSID;
const char *password = WIFI_PW;

InterruptButton button(GPIO_NUM_0, 0);

void configure_led()
  gpio_set_direction(GPIO_NUM_2, GPIO_MODE_INPUT_OUTPUT);

void configure_wifi()
  WiFi.begin(ssid, password);

  while (WiFi.waitForConnectResult() != WL_CONNECTED)
    Serial.println("Connection Failed! Rebooting...");
  printf("Connected to WiFi: %s\n", WiFi.localIP().toString().c_str());

void callback()
  uint8_t state = gpio_get_level(GPIO_NUM_2);
  printf("Toggeling LED: %i\n", state);
  gpio_set_level(GPIO_NUM_2, !state);

  // printf("Async blink");
  // gpio_set_level(GPIO_NUM_2, 1);
  // vTaskDelay(1000 / portTICK_PERIOD_MS);
  // gpio_set_level(GPIO_NUM_2, 0);

extern "C" void app_main()
  button.bind(Event_KeyDown, &callback);


  while (1)
    vTaskDelay(5 / portTICK_PERIOD_MS);

When flashing via USB, the project is working. It outputs the IP after initialization and pressing the button, turns the LED on and off.
When flashing via espota, I see the following message:

17:26:51 [DEBUG]: Options: {'esp_ip': '', 'host_ip': '', 'esp_port': 3232, 'host_port': 17226, 'auth': '', 'image': '.pio/build/ota/firmware.bin', 'spiffs': False, 'debug': True, 'progress': True, 'timeout': 10}
17:26:51 [INFO]: Starting on
17:26:51 [INFO]: Upload size: 751120
Sending invitation to 
17:26:52 [INFO]: Waiting for device...
17:27:02 [ERROR]: No response from device
*** [upload] Error 1

In addition, there is a very last message printed on the serial monitor:

[ 29961][E][ArduinoOTA.cpp:252] _runUpdate(): Begin ERROR: Partition Could Not be Found

I am confused by the message. Would I have to create a separate partition on something like this?
I haven’t changed anything through the menuconfig.

Can anyone imagine, what’s wrong here?
Thanks in advance!

Please inspect the documentation carefully. The default partition table in ESP-IDF is partitions_singleapp.csv . Use the menuconfig to select a more appropriate partition table, such as partitions_two_ota.csv.

Thanks for your help.
Changing the partition table solved the problem.

That said, I tried changing the partition table in the menuconfig in the first place.
I made the change for both environments serial and ota and flashed the firmware through serial. That actually didn’t solve the problem.
It seems that the menuconfig configuration has been ignored.

I added this line to my platformio.ini

board_build.partitions = partitions_two_ota.csv

After that change, it worked.
Can you imagine, why this is necessary?

Both PIO + Cmake(ESP-IDF) need to know about the partition table then.