From 82984f05394bc04e5abda365bc734d168c2d69b7 Mon Sep 17 00:00:00 2001 From: Tim Nordell Date: Fri, 12 Apr 2019 15:34:46 -0500 Subject: [PATCH] bootloader: Do not obfuscate RAM if we are not doing image validation No need to take this step if we are not doing image validation. The obfuscation only buys us a tiny bit of "security" anyways since the main parts of flash are memory mapped, too. This saves a little bit of wake-up time when waking up from deep sleep when the BOOTLOADER_SKIP_VALIDATE_IN_DEEP_SLEEP option is set. Signed-off-by: Tim Nordell --- components/bootloader_support/src/esp_image_format.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/components/bootloader_support/src/esp_image_format.c b/components/bootloader_support/src/esp_image_format.c index 95959325d..4bda87af1 100644 --- a/components/bootloader_support/src/esp_image_format.c +++ b/components/bootloader_support/src/esp_image_format.c @@ -225,7 +225,7 @@ static esp_err_t image_load(esp_image_load_mode_t mode, const esp_partition_pos_ } #ifdef BOOTLOADER_BUILD - if (do_load) { // Need to deobfuscate RAM + if (do_load && ram_obfs_value[0] != 0 && ram_obfs_value[1] != 0) { // Need to deobfuscate RAM for (int i = 0; i < data->image.segment_count; i++) { uint32_t load_addr = data->segments[i].load_addr; if (should_load(load_addr)) { @@ -403,6 +403,12 @@ static esp_err_t process_segment_data(intptr_t load_addr, uint32_t data_addr, ui return ESP_FAIL; } + if (checksum == NULL && sha_handle == NULL) { + memcpy((void *)load_addr, data, data_len); + bootloader_munmap(data); + return ESP_OK; + } + #ifdef BOOTLOADER_BUILD // Set up the obfuscation value to use for loading while (ram_obfs_value[0] == 0 || ram_obfs_value[1] == 0) {