Unable to upload images on Shelly PM mini gen3, Unexpected response from ESP: 0x04

I’ve got two new Shelly PM mini gen 3’s flashed to esphome, but running into issues flashing new “prod” images. The devices are not bricked.

I’ve followed these steps in a “temp” environment:

So, the “temp” environment is based on Read/Write bootloader, partition table and any partition via OTA by angelnu · Pull Request #5535 · esphome/esphome · GitHub

After this I’m using my regular “prod” esphome environment (latest version) to create and upload a new image.
However, this gives me this error:
ERROR Error auth: Unexpected response from ESP: 0x04

The log output on Shelly shows:

16:20:25	[W]	[ota:380]	Failed to read 1 bytes of data, errno: 104
16:20:25	[E]	[ota:282]	Reading command failed!
16:20:25	[W]	[ota:411]	Failed to write 1 bytes of data, errno: 104

Now… When I go to the “temp” environment and compile the bigger config (from prod), then it does upload successfully.

I’ve played around with clearing the OTA password, safe_boot and using OTA version 1 etc. Nothing allowed the prod image to be uploaded.

The only difference between “temp” and “prod” config is “unprotected_writes: True” under ota: as required for the initial flashing and the addition of " - platform: esphome" under ota as per thew new structure.

The weird thing is that my other Shelly PM mini gen3’s are working just fine. It’s just these 2 newer ones.

This ain’t a massive thing as I can make changes, but it would be nice to be able to upgrade esphome. Now they’re stuck on 2024.1.0-dev :slight_smile:

Hope anyone has some clues. Happy to provide any further details if required of course!

News flash, it works!

Turns out compiling and flashing using an esphome version <= 2024.5.1 did the trick!

docker run --rm -v "${PWD}":/config -it ghcr.io/esphome/esphome:2024.5.1 run config.yaml
Config.yaml I used does have “version: 1” under ota:

After this I am able to flash the latest and greatest. No idea why it didn’t work initially…
Just sharing in case anyone runs into this as well.