Does Arduino Core support OTA on the ESP32S2?
Posted: Tue Aug 13, 2024 3:58 pm
I have a project on the Wemos ESP32S2 mini V1. It has the USB-C port for programming but I need to do OTA flash programming in the long run. With the configuration I have now, the OTA upload works just fine. It just always fails at the end with
IF I track this error result down in the core firmware, I see it being generated in ./packages/framework-arduinoespressif32/libraries/Update/src/Updater.cpp:
I can't get a look at esp_ota_set_boot_partition() but that was enough to make me start looking at the partition table I'm using. It started off looking like this:
Since that wasn't working, I tried using default.csv but that just failed the same way. Poking around in the .platformio directory I found ./packages/framework-arduino-solo1/variants/department_of_alchemy_minimain_esp32s2/partitions-4MB-tinyuf2.csv:
It's for ESP-IDF but I thought that may not matter when it comes to OTA. I modified my custom partition file to add the uf2 partition:
Of course, that made no difference either. So, my question is, am I looking in the right place to solve this problem?
My platformio.ini looks like this:
I'm using esptool in PlatformIO to do the OTA upload:
esptool.py v4.5.1 - Espressif chips ROM Bootloader Utility
I have some experience with the ESP32 but this is my first project with the S2 and USB boot loader.
- Uploading: [============================================================] 99%
- Uploading: [============================================================] 99%
- Uploading: [============================================================] 100% Done...
- 04:19:52 [INFO]: Waiting for result...
- 04:19:52 [INFO]: Result: Could Not Activate The Firmware
- 04:19:52 [INFO]: Result:
- 04:19:52 [INFO]: Result:
- 04:19:52 [INFO]: Result:
- 04:19:52 [INFO]: Result:
- 04:19:52 [ERROR]: Error response from device
- *** [upload] Error 1
- bool UpdateClass::_verifyEnd() {
- if (_command == U_FLASH) {
- if (!_enablePartition(_partition) || !_partitionIsBootable(_partition)) {
- _abort(UPDATE_ERROR_READ);
- return false;
- }
- if (esp_ota_set_boot_partition(_partition)) {
- _abort(UPDATE_ERROR_ACTIVATE);
- return false;
- }
- _reset();
- return true;
- } else if (_command == U_SPIFFS) {
- _reset();
- return true;
- }
- return false;
- }
- Name, Type, SubType, Offset, Size, Flags
- nvs, data, nvs, 0x9000, 0x5000,
- otadata, data, ota, 0xE000, 0x2000,
- ota_0, 0, ota_0, 0x10000, 0x1F0000,
- ota_1, 0, ota_1, 0x200000, 0x1F0000,
- coredump, data, coredump, 0x3F0000, 0x10000,
- # ESP-IDF Partition Table
- # Name, Type, SubType, Offset, Size, Flags
- # bootloader.bin,, 0x1000, 32K
- # partition table, 0x8000, 4K
- nvs, data, nvs, 0x9000, 20K,
- otadata, data, ota, 0xe000, 8K,
- ota_0, 0, ota_0, 0x10000, 1408K,
- ota_1, 0, ota_1, 0x170000, 1408K,
- uf2, app, factory,0x2d0000, 256K,
- ffat, data, fat, 0x310000, 960K,
- Name, Type, SubType, Offset, Size, Flags
- nvs, data, nvs, 0x9000, 0x5000,
- otadata, data, ota, 0xE000, 0x2000,
- ota_0, 0, ota_0, 0x10000, 0x1D0000,
- ota_1, 0, ota_1, 0x1E0000, 0x1D0000,
- uf2, app, factory, 0x3B0000, 0x40000,
- coredump, data, coredump, 0x3F0000, 0x10000,
My platformio.ini looks like this:
- ; PlatformIO Project Configuration File
- ;
- ; Build options: build flags, source filter
- ; Upload options: custom upload port, speed and extra flags
- ; Library options: dependencies, extra library storages
- ; Advanced options: extra scripting
- ;
- ; Please visit documentation for the other options and examples
- ; https://docs.platformio.org/page/projectconf.html
- [env]
- platform = espressif32
- board = WemosESP32S2miniV1
- framework = arduino
- build_type = debug
- board_build.partitions = ESP32S2mini.csv
- monitor_speed = 115200
- monitor_port = COM27
- monitor_filters = esp32_exception_decoder
- ; upload_protocol = esptool
- ; upload_resetmethod = nodemcu
- ; upload_port = COM4
- ;upload_flags = --after no_reset
- upload_protocol = espota
- upload_port = .....
- upload_flags = --auth=admin
- --port=3232
- build_flags =
- -DBOARD_HAS_PSRAM
- -mfix-esp32-psram-cache-issue
- -Wall
- -DDEBUG
- -std=gnu99
- -Os
- -u,vfprintf
- -DUSER_SETUP_LOADED=1
- -DST7789_DRIVER=1
- -DTFT_RGB_ORDER=TFT_BGR
- -DSPI_FREQUENCY=40000000
- -DTFT_MISO=-1
- -DTFT_MOSI=13
- -DTFT_SCLK=14
- -DTFT_CS=-1
- -DTFT_DC=5
- -DTFT_RST=4
- -DLOAD_GFXFF=1
- lib_extra_dirs =
- C:\Users\marc\Documents\PlatformIO\Lib
- lib_deps =
- bodmer/TFT_eSPI@^2.5.43
- bogde/HX711@^0.7.5
- arcao/Syslog@^2.0.0
- milesburton/DallasTemperature@^3.11.0
- https://github.com/PaulStoffregen/OneWire.git
- knolleary/PubSubClient@^2.8
- bblanchon/ArduinoJson@^7.1.0
- [env:tool]
- build_flags =
- -DTOOL
- -DCLIENT_NAME="\"CH101\""
- -DMY_IP_ADDRESS="....."
- -DNUM_TEMPERATURE_SENSORS=3
- [env:proto]
- build_flags =
- -DPROTO
- -DCLIENT_NAME="\"CH102\""
- -DMY_IP_ADDRESS="....."
- -DNUM_TEMPERATURE_SENSORS=1
esptool.py v4.5.1 - Espressif chips ROM Bootloader Utility
I have some experience with the ESP32 but this is my first project with the S2 and USB boot loader.