Skip to content

OTA fails with ESP32-S2 (ESP.partitionRead) #6093

Closed
@misery

Description

@misery

Board

ESP32-S2 / ESP12k from AI Thinker

Device Description

I'm using a naked ESP12k dev board from AI Thinker.

Hardware Configuration

Nothing connected

Version

v2.0.1

IDE Name

esphome

Operating System

Linux

Flash frequency

40MHz

PSRAM enabled

no

Upload speed

460800

Description

ESP.partitionRead won't read that data that was written with ESP.partitionWrite.

I'm using esphome and the OTA fails (flashing over USB works). So I digged into the code and saw that the binary of esphome is correct. Even the md5 check of the Updater.cpp works and is valid.

The data buf is wrong and the check for the magic byte in line 47 fails. So the whole OTA fails.

    if(!ESP.partitionRead(partition, 0, (uint32_t*)buf, ENCRYPTED_BLOCK_SIZE)) {
        return false;
    }

   if(buf[0] != ESP_IMAGE_HEADER_MAGIC) {
        return false;
    }

https://github.com/espressif/arduino-esp32/blob/2.0.2/libraries/Update/src/Updater.cpp#L43

I can see that in UpdateClass::_verifyHeader the magic byte is correct and also the buffer contains the correct magic byte 0xE9 for ESP.partitionWrite. But if ESP.partitionRead reads it, it contains something like this.

\xfc\xed\xdf\xed\xff\xef\xee\xef\xcc\xfe\xed\xef\xfe\xdf\xfd\xec0

Sketch

Well, no sketch... just an esphome yaml


esp32:
  board: esp32-s2-kaluga-1

esphome:
  name: esp_demo_s2
  platformio_options:
    platform_packages:
      - framework-arduinoespressif32 @ https://github.com/espressif/arduino-esp32.git#2.0.2
    platform:
      - https://github.com/platformio/platform-espressif32.git#feature/arduino-upstream

logger:
  level: DEBUG

ota:

status_led:
  pin: GPIO2

wifi:
  networks:
  - ssid: !secret wifi_ssid
    password: !secret wifi_password

Debug Message

I get Read Failed as errorString. If I skip the magic header check in _partitionIsBootable I get Could Not Activate The Firmware

[D][esp-idf:000]: E (32183) esp_image: image at 0x1d0000 has invalid magic byte (nothing flashed here?)

Other Steps to Reproduce

No response

I have checked existing issues, online documentation and the Troubleshooting Guide

  • I confirm I have checked existing issues, online documentation and Troubleshooting guide.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions