Craig,

Thanks for discovering this. It is nasty.

Error 258 is 0x102 and that is ESP_ERR_INVALID_ARG (not ESP_ERR_NOT_SUPPORTED).

I find it esp_ota_begin (components/app_update/esp_ota_ops.c):

    if (!is_ota_partition(partition)) {
        return ESP_ERR_INVALID_ARG;
    }

and that is:

static bool is_ota_partition(const esp_partition_t *p)
{
    return (p != NULL
            && p->type == ESP_PARTITION_TYPE_APP
            && p->subtype >= ESP_PARTITION_SUBTYPE_APP_OTA_0
            && p->subtype < ESP_PARTITION_SUBTYPE_APP_OTA_MAX);
}

It seems we can’t target the factory partition with those ota operations. I guess the problem is the whole ota rollback thing (where if it can’t boot into an ota partition, it falls back to the previous one).

It is not too onerous to workaround, though. We can simply change to use esp_partition_erase_range and esp_partition_write when targeting the factory. I will try to implement it that way tonight.

Regards, Mark.

On 25 Feb 2026, at 7:34 AM, Craig Leres <leres@xse.com> wrote:

On 2/24/26 04:40, Mark Webb-Johnson via OvmsDev wrote:
OK, I have just committed this. The two new commands are:
 * ota partitions list
 * ota partitions upgrade [-noconfirm]
Rollback is via:
 * wget http://api.openvehicles.com/firmware/ota/v3.1/main/
   partitions.bin <http://api.openvehicles.com/firmware/ota/v3.1/main/
   partitions.bin>
 * esptool.py -p <path-to-usb> write_flash 0x8000 partitions.bin General approach to manual upgrade:
1. Upgrade to firmware supporting this feature (3.3.005-711-g4feca695
   or later)
2. Copy running ota firmware to factory
3. Set to boot from flash and reboot
4. Use ‘ota partitions upgrade’ to upgrade
5. Reboot
Items still to be addressed:
 * Documentation (including rollback procedure).
 * Modify partitions.csv to use this new format (when ready for
   production).
 * Web interface (in particular concept of factory vs ota), if
   necessary (haven’t checked this).
 * OTA flash builds. We will need a way to support 6MB builds for those
   that can use them. I suggest to change GetOVMSProduct() to return
   v3.5 for these modules that are running this new 6MB capable
   partition table. Then on server we can build a production release
   final 4MB firmware including this support, and then use v3.5 tree to
   build future 6MB only builds. The ‘ota flash’ system would
   automatically support that and give people time to upgrade (as well
   as new users with 4MB partition modules for many months).
 * Investigate any simple way to make this a simple one-command
   (current ota->factory, boot factory, reboot, partitions upgrade,
   reboot).
For the moment, please try this out and let me know if you find any problems. We can then decide on the items still to be addressed.

I took a run at this with my dev module:

   OVMS# ota
   Hardware:          OVMS WIFI BLE BT cores=2 rev=ESP32/3; MODEM SIM7600
   Firmware:          3.3.005-711-g4feca695-dirty/ota_1/main (build idf v3.3.4-854-g9063c8662 Feb 24 2026 15:08:43)
   Partition type:    v3-f12 (factory, ota1, ota2)
   Partition table:   0x8000
   Running partition: ota_1
   Boot partition:    ota_1
   Factory image:     3.3.005-20-g60be058e
   OTA_O image:       3.3.005-700-g0a804e40-dirty
   OTA_1 image:       3.3.005-711-g4feca695-dirty
   OVMS# ota copy ota_1 factory
   OTA copy ota_1 (08454144) -> factory (00010000) size 4194304
   Error: ESP32 error #258 starting OTA operation
   OVMS#

I couldn't find 258 so I internet searched it and learned that it is ESP_ERR_NOT_SUPPORTED (from components/esp32/include/esp_err.h, might be worth displaying in hex given that's how it's defined).

I checked and my esp-idf is up to date.

Craig

sea 12 % pwd
/home/sea/u0/leres/esp/esp-idf
sea 13 % git log | head
commit 9063c8662ca5d67b5490c1503bd4377b380feed3
Author: Michael Balzer <balzer@expeedo.de>
Date:   Tue Jan 27 17:34:34 2026 +0100

   Fix mutex priority inheritance bug in spi_flash component:
     backport of esp-idf commit aea2fe08162e1ba86ad0189178c1f1cf29238bbd,
     see https://github.com/espressif/esp-idf/issues/5116
     and https://github.com/espressif/esp-idf/issues/7580

commit 75bdad1e05dbbfe2ef79e8398749ff6aaa7deb92
sea 17 % pwd
/home/sea/u0/leres/src/OVMS.V3
sea 18 % git log | head
commit 4feca695d922f26b5f3864fe43c6855b8f223675
Author: Mark Webb-Johnson <mark@webb-johnson.net>
Date:   Tue Feb 24 20:21:30 2026 +0800

   Support for ota 0+1 partition table format, and 6MB firmware

commit 1241912b48628e89947e1600f86365b4b174c6c8
Merge: 92f93554 141bad50
Author: Michael Balzer <dexter@dexters-web.de>
Date:   Sun Feb 22 15:57:13 2026 +0100