Auslesen der Partitionstabelle bereits installierter ESP32 vor der Aktivierung von OTA
Von English mit KI übersetzt ·
Wir haben 31 ESP32-WROOM-32-Boards in Kühlaufliegern, die Temperaturen über MQTT an Hermetry melden. Die Firmware stammt von uns und wird mit Arduino core 2.x gebaut. Wir möchten die Firmware-Updates von Hermetry nutzen, statt mit dem Laptop zum Depot zu fahren.Problem: Die ersten 12 Boards wurden von einem Dienstleister geflasht, und niemand hat notiert, welches Partitionsschema er gewählt hat. Unser aktueller Build ist etwa 1,4 MB groß. Falls einige Boards mit einer einzigen großen App-Partition geflasht wurden, hat OTA keinen Platz zum Schreiben, und ich möchte das wissen, bevor ich etwas zuweise und zusehe, wie die Hälfte der Flotte auf Failed geht.Gibt es eine Möglichkeit, die Partitionstabelle eines laufenden Boards auszulesen, ohne es neu zu flashen? Idealerweise aus der Ferne, da die Trailer auf drei Depots verteilt sind.
We have 31 ESP32-WROOM-32 boards in refrigerated trailers reporting temperatures to Hermetry over MQTT. Firmware is ours, built with Arduino core 2.x. We’d like to start using Hermetry’s firmware updates instead of driving to the depot with a laptop.
Problem: the first 12 boards were flashed by a contractor and nobody wrote down which partition scheme he picked. Our current build is about 1.4 MB. If some boards were flashed with a single big app partition, OTA has nowhere to write to and I’d rather know that before I assign anything and watch half the fleet go to Failed.
Is there a way to read the partition table of a running board without reflashing it? Ideally remotely, since the trailers are spread over three depots.
Von English mit KI übersetzt ·
esptool read_flash bei 0x8000?
esptool read_flash at 0x8000?
Von English mit KI übersetzt ·
Dafür wird aber USB benötigt. Die Trailer sind die meiste Woche unterwegs.
That needs USB though. The trailers are out most of the week.
Von English mit KI übersetzt ·
Nicht deine Frage, aber wo du schon dabei bist: Registriere einen Signaturschlüssel und lass „Unsignierte Images zulassen“ in diesem Profil deaktiviert. Unsigniert ist nur für Testgeräte gedacht, und Anhänger auf der Straße sind keine Testgeräte.
Not your question, but while you’re at it: register a signing key and keep „Allow unsigned images“ off on that profile. Unsigned is meant for test devices only, and trailers on the road aren’t test devices.
Von English mit KI übersetzt ·
Genau diese Situation hatten wir mit Zählerplatinen, die ein Dienstleister installiert hat. Sie können die laufende Firmware fragen: Die Partition-API in ESP-IDF funktioniert problemlos über den Arduino-Core. Spielen Sie einen Build auf die Boards auf, die Sie erreichen können (die aus Ihrer eigenen Charge), oder warten Sie, bis die anderen im Depot sind; diese meldet die Tabelle nach dem Verbinden einmal als Client-Attribute:
#include "esp_partition.h"
void reportPartitions() {
String json = "{";
esp_partition_iterator_t it =
esp_partition_find(ESP_PARTITION_TYPE_ANY, ESP_PARTITION_SUBTYPE_ANY, NULL);
bool first = true;
while (it != NULL) {
const esp_partition_t *p = esp_partition_get(it);
if (!first) json += ",";
json += ""part." + String(p->label) + "":"" +
String(p->address, HEX) + "/" + String(p->size) + """;
first = false;
it = esp_partition_next(it);
}
esp_partition_iterator_release(it);
json += "}";
mqtt.publish("v1/attributes", json.c_str());
}
Dann zeigt der Reiter Attributes, Scope Client, pro Board part.app0, part.app1, part.otadata usw. Gewünscht sind zwei App-Slots (ota_0 und ota_1, in den Arduino-Tabellen app0/app1 genannt) plus otadata, jeweils mindestens so groß wie Ihr Image. Sehen Sie nur ein app0 mit 3 MB und kein app1, handelt es sich um das Schema „Huge APP“, dann ist kein OTA möglich.Für Boards, auf die sich kein neuer Build spielen lässt, funktioniert im Depot Emilys Vorgehen:
esptool.py --port /dev/ttyUSB0 read_flash 0x8000 0xc00 pt.bin
python gen_esp32part.py pt.bin
Boards mit falschem Schema brauchen einen einmaligen USB-Reflash mit einer Tabelle mit zwei Slots. Danach funktioniert OTA dauerhaft.
Had this exact situation with meter boards a contractor did. You can ask the running firmware: the partition API in ESP-IDF works fine from the Arduino core. Push one build to the boards you can reach (the ones from your own batch), or wait until the others are at the depot, that reports the table as client attributes once after connecting:
#include "esp_partition.h"
void reportPartitions() {
String json = "{";
esp_partition_iterator_t it =
esp_partition_find(ESP_PARTITION_TYPE_ANY, ESP_PARTITION_SUBTYPE_ANY, NULL);
bool first = true;
while (it != NULL) {
const esp_partition_t *p = esp_partition_get(it);
if (!first) json += ",";
json += ""part." + String(p->label) + "":"" +
String(p->address, HEX) + "/" + String(p->size) + """;
first = false;
it = esp_partition_next(it);
}
esp_partition_iterator_release(it);
json += "}";
mqtt.publish("v1/attributes", json.c_str());
}
Then the Attributes tab, Client scope, shows part.app0, part.app1, part.otadata and so on per board. What you want to see is two app slots (ota_0 and ota_1, called app0/app1 in the Arduino tables) plus otadata, each at least as big as your image. If you see one app0 of 3 MB and no app1, that’s the „Huge APP“ scheme, no OTA possible.
For the boards you can’t get a new build on, emily’s way works at the depot:
esptool.py --port /dev/ttyUSB0 read_flash 0x8000 0xc00 pt.bin
python gen_esp32part.py pt.bin
Boards with the wrong scheme need one USB reflash with a two-slot table. After that OTA works for good.
Von English mit KI übersetzt ·
Erledigt. 9 der 12 Geräte des Auftragnehmers kamen mit einer einzigen 3 MB großen app0 zurück, bei diesen ist OTA also ohne Vor-Ort-Termin nicht möglich. Bei den anderen 3 und bei all unseren Geräten sind app0/app1 jeweils 1,25 MB groß, was für unseren 1,4 MB großen Build knapp ist. Deshalb stelle ich unsere Tabelle auf die minimale SPIFFS-Variante mit 1,9 MB großen Slots um, bevor wir weitermachen. Gut, dass wir zuerst nachgesehen haben.
Done. 9 of the contractor’s 12 came back with a single 3 MB app0, so no OTA on those without a visit. The other 3 and all of ours have app0/app1 at 1.25 MB each, which is tight against our 1.4 MB build, so I’m switching our table to the minimal SPIFFS one with 1.9 MB slots before we go further. Good thing we checked first.
Von English mit KI übersetzt ·
Als diejenige, die die Depotbesuche freigibt: Bitte prüfe das, bevor die nächste Charge geflasht wird.
As the one who signs off on the depot visits: please check this before the next batch gets flashed.
- Du musst angemeldet sein, um auf dieses Thema antworten zu können.
Mitdiskutieren
Melde dich an, um Fragen zu stellen und zu beantworten, hilfreiche Beiträge mit „Gefällt mir“ zu markieren und die Antwort zu kennzeichnen, die dein Problem gelöst hat. Jeder Beitrag bringt Punkte und Stufen.

