For guidance I looked at simple_ota_example from ESP-IDF and created a little test that should read the running binary per 8 bytes.
However, I have no idea how I should determine the amount of data to copy and how to check if the data is correct.
I tried to compare the data that is read with the binary by using the CMD command: "certutil -encodehex simple_ota.bin simple_ota.txt" but the data differs greatly.
On top of all that my C skills may be a little rusty, here is what I tried:
Code: Select all
const char* typeNames[] = {"ESP_PARTITION_TYPE_APP", "ESP_PARTITION_TYPE_DATA", "ESP_PARTITION_TYPE_ANY"};
const char* subtypeNames[] = {"ESP_PARTITION_SUBTYPE_APP_FACTORY", "ESP_PARTITION_SUBTYPE_APP_OTA_MIN"};
const esp_partition_t *runnPar = esp_ota_get_running_partition();
printf("Running partition:\n");
printf("address: 0x%lX\n", runnPar->address);
printf("size: %ld\n", runnPar->size); // size of partition, not binary
printf("partition label: %s\n", runnPar->label);
printf("type: %s\n", typeNames[runnPar->type]);
printf("subtype: %s\n", subtypeNames[runnPar->subtype]);
uint8_t byte_amt = 8;
uint8_t *data = (uint8_t *)malloc(sizeof(uint8_t) * byte_amt);
for (size_t i = 0; i < runnPar->size; i+=8)
{
esp_err_t ret = esp_partition_read(runnPar, runnPar->address + i, data, 8);
for (int j = 0; j < byte_amt; j++)
{
printf("%02X ", data[i+j]);
}
printf("\n");
vTaskDelay(10);
}