Skip to content

Commit

Permalink
Merge pull request #4 from Linak/LINAK_v3.3_SecureVersionFix
Browse files Browse the repository at this point in the history
Changed OTA partition load
  • Loading branch information
MartinTJDK authored Sep 29, 2020
2 parents 76d93ca + c8e2897 commit 7a44a40
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions components/bootloader_support/src/bootloader_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -245,13 +245,19 @@ esp_err_t bootloader_common_get_partition_description(const esp_partition_pos_t
return ESP_ERR_INVALID_ARG;
}

const uint8_t *image = bootloader_mmap(partition->offset, partition->size);
// const uint8_t *image = bootloader_mmap(partition->offset, partition->size);
const uint32_t app_desc_offset = sizeof(esp_image_header_t) + sizeof(esp_image_segment_header_t);
const uint32_t mmap_size = app_desc_offset + sizeof(esp_app_desc_t);
const uint8_t *image = bootloader_mmap(partition->offset, mmap_size);

if (image == NULL) {
ESP_LOGE(TAG, "bootloader_mmap(0x%x, 0x%x) failed", partition->offset, partition->size);
// ESP_LOGE(TAG, "bootloader_mmap(0x%x, 0x%x) failed", partition->offset, partition->size);
ESP_LOGE(TAG, "bootloader_mmap(0x%x, 0x%x) failed", partition->offset, mmap_size);
return ESP_FAIL;
}

memcpy(app_desc, image + sizeof(esp_image_header_t) + sizeof(esp_image_segment_header_t), sizeof(esp_app_desc_t));
// memcpy(app_desc, image + sizeof(esp_image_header_t) + sizeof(esp_image_segment_header_t), sizeof(esp_app_desc_t));
memcpy(app_desc, image + app_desc_offset, sizeof(esp_app_desc_t));
bootloader_munmap(image);

if (app_desc->magic_word != ESP_APP_DESC_MAGIC_WORD) {
Expand Down

0 comments on commit 7a44a40

Please sign in to comment.