diff --git a/components/bootloader/CMakeLists.txt b/components/bootloader/CMakeLists.txt index 388d82a48a..43a5be382d 100644 --- a/components/bootloader/CMakeLists.txt +++ b/components/bootloader/CMakeLists.txt @@ -13,9 +13,9 @@ if(NOT CONFIG_SECURE_BOOT) endif() esptool_py_custom_target(bootloader-flash bootloader "bootloader") -esptool_py_flash_target_image(bootloader-flash bootloader "0x1000" "${BOOTLOADER_BUILD_DIR}/bootloader.bin") +esptool_py_flash_target_image(bootloader-flash bootloader ${CONFIG_BOOTLOADER_OFFSET_IN_FLASH} "${BOOTLOADER_BUILD_DIR}/bootloader.bin") # Also attach an image to the project flash target if(NOT CONFIG_SECURE_BOOT) - esptool_py_flash_target_image(flash bootloader "0x1000" "${BOOTLOADER_BUILD_DIR}/bootloader.bin") + esptool_py_flash_target_image(flash bootloader ${CONFIG_BOOTLOADER_OFFSET_IN_FLASH} "${BOOTLOADER_BUILD_DIR}/bootloader.bin") endif() \ No newline at end of file diff --git a/components/bootloader/Kconfig.projbuild b/components/bootloader/Kconfig.projbuild index b0dc4881bb..ab92d74ae1 100644 --- a/components/bootloader/Kconfig.projbuild +++ b/components/bootloader/Kconfig.projbuild @@ -1,5 +1,14 @@ menu "Bootloader config" + config BOOTLOADER_OFFSET_IN_FLASH + hex + default 0x1000 if IDF_TARGET_ESP32 || IDF_TARGET_ESP32S2 + default 0x0 + help + Offset address that 2nd bootloader will be flashed to. + The value is determined by the ROM bootloader. + It's not configurable in ESP-IDF. + choice BOOTLOADER_COMPILER_OPTIMIZATION prompt "Bootloader optimization Level" default BOOTLOADER_COMPILER_OPTIMIZATION_SIZE diff --git a/components/bootloader/project_include.cmake b/components/bootloader/project_include.cmake index 8d34f70f32..42e0fe480c 100644 --- a/components/bootloader/project_include.cmake +++ b/components/bootloader/project_include.cmake @@ -1,4 +1,4 @@ -set(BOOTLOADER_OFFSET 0x1000) +set(BOOTLOADER_OFFSET CONFIG_BOOTLOADER_OFFSET_IN_FLASH) # Do not generate flash file when building bootloader if(BOOTLOADER_BUILD OR NOT CONFIG_APP_BUILD_BOOTLOADER) diff --git a/components/bootloader_support/include/esp_flash_partitions.h b/components/bootloader_support/include/esp_flash_partitions.h index 004bbeb236..1fc9d4f6c1 100644 --- a/components/bootloader_support/include/esp_flash_partitions.h +++ b/components/bootloader_support/include/esp_flash_partitions.h @@ -44,7 +44,7 @@ extern "C" { /* Pre-partition table fixed flash offsets */ #define ESP_BOOTLOADER_DIGEST_OFFSET 0x0 -#define ESP_BOOTLOADER_OFFSET 0x1000 /* Offset of bootloader image. Has matching value in bootloader KConfig.projbuild file. */ +#define ESP_BOOTLOADER_OFFSET CONFIG_BOOTLOADER_OFFSET_IN_FLASH /* Offset of bootloader image. Has matching value in bootloader KConfig.projbuild file. */ #define ESP_PARTITION_TABLE_OFFSET CONFIG_PARTITION_TABLE_OFFSET /* Offset of partition table. Backwards-compatible name.*/ #define ESP_PARTITION_TABLE_MAX_LEN 0xC00 /* Maximum length of partition table data */