From c2b1d3a9d2dfc680081d84ed05941c3a2a125dfc Mon Sep 17 00:00:00 2001 From: Ivan Grokhotkov Date: Wed, 4 Mar 2020 15:46:03 +0100 Subject: [PATCH] bootloader_support: don't check signature when JTAG is attached If an insecure configuration is enabled (no hardware secure boot, just software signature check), skip the signature check in bootloader if JTAG debugger is attached. This allows the debugger to set breakpoints in Flash before the application runs. Closes https://github.com/espressif/esp-idf/issues/4734 Closes https://github.com/espressif/esp-idf/issues/4878 --- .../bootloader_support/src/esp_image_format.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/components/bootloader_support/src/esp_image_format.c b/components/bootloader_support/src/esp_image_format.c index 77085e04c6..023cbc5a4b 100644 --- a/components/bootloader_support/src/esp_image_format.c +++ b/components/bootloader_support/src/esp_image_format.c @@ -196,8 +196,17 @@ static esp_err_t image_load(esp_image_load_mode_t mode, const esp_partition_pos_ if (!is_bootloader) { #ifdef SECURE_BOOT_CHECK_SIGNATURE // secure boot images have a signature appended - err = verify_secure_boot_signature(sha_handle, data); -#else +#if defined(BOOTLOADER_BUILD) && !defined(CONFIG_SECURE_BOOT) + // If secure boot is not enabled in hardware, then + // skip the signature check in bootloader when the debugger is attached. + // This is done to allow for breakpoints in Flash. + if (!esp_cpu_in_ocd_debug_mode()) { +#else // CONFIG_SECURE_BOOT + if (true) { +#endif // end checking for JTAG + err = verify_secure_boot_signature(sha_handle, data); + } +#else // SECURE_BOOT_CHECK_SIGNATURE // No secure boot, but SHA-256 can be appended for basic corruption detection if (sha_handle != NULL && !esp_cpu_in_ocd_debug_mode()) { err = verify_simple_hash(sha_handle, data);