Fix safeboot partition size recognition

This commit is contained in:
Theo Arends 2022-05-05 18:20:25 +02:00
parent 3da760c109
commit db74b2a1a3
1 changed files with 8 additions and 6 deletions

View File

@ -303,9 +303,13 @@ bool EspSingleOtaPartition(void) {
return (1 == esp_ota_get_app_partition_count()); return (1 == esp_ota_get_app_partition_count());
} }
bool EspRunningFactoryPartition(void) { uint32_t EspRunningFactoryPartition(void) {
const esp_partition_t *cur_part = esp_ota_get_running_partition(); const esp_partition_t *cur_part = esp_ota_get_running_partition();
return (cur_part->type == 0 && cur_part->subtype == 0); // return (cur_part->type == 0 && cur_part->subtype == 0);
if (cur_part->type == 0 && cur_part->subtype == 0) {
return cur_part->size;
}
return 0;
} }
void EspPrepRestartToSafeBoot(void) { void EspPrepRestartToSafeBoot(void) {
@ -459,10 +463,8 @@ uint32_t ESP_getChipId(void) {
} }
uint32_t ESP_getFreeSketchSpace(void) { uint32_t ESP_getFreeSketchSpace(void) {
if (EspRunningFactoryPartition()) { uint32_t size = EspRunningFactoryPartition();
return 0xD0000; // SafeBoot (factory) partition size return (size) ? size : ESP.getFreeSketchSpace();
}
return ESP.getFreeSketchSpace();
} }
uint32_t ESP_getSketchSize(void) { uint32_t ESP_getSketchSize(void) {