ESP32 OTA Partition Could Not be Found

Hi,

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:

[env:serial]
platform = espressif32
board = esp32doit-devkit-v1
framework = arduino, espidf
monitor_speed = 115200
build_flags = 
    '-D WIFI_SSID="MY_SSID"'
    '-D WIFI_PW="MY_PW"'

[env:ota]
extends = env:serial
upload_protocol = espota
upload_port = 10.0.237.54

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_reset_pin(GPIO_NUM_2);
  gpio_set_direction(GPIO_NUM_2, GPIO_MODE_INPUT_OUTPUT);
}

void configure_wifi()
{
  WiFi.mode(WIFI_MODE_STA);
  WiFi.begin(ssid, password);

  while (WiFi.waitForConnectResult() != WL_CONNECTED)
  {
    Serial.println("Connection Failed! Rebooting...");
    delay(5000);
    ESP.restart();
  }
  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()
{
  nvs_flash_init();
  configure_wifi();
  configure_led();
  button.bind(Event_KeyDown, &callback);

  ArduinoOTA.begin();

  while (1)
  {
    vTaskDelay(5 / portTICK_PERIOD_MS);
    ArduinoOTA.handle();
  }
}

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': '10.0.237.54', 'host_ip': '0.0.0.0', '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 0.0.0.0:17226
17:26:51 [INFO]: Upload size: 751120
Sending invitation to 10.0.237.54 
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.