Skip to content

Commit b5ee028

Browse files
committed
Merge branch 'feat/bootloader_nvs_read_encrypted' into 'master'
Support reading encrypted NVS partitions by the bootloader Closes IDF-11791 See merge request espressif/esp-idf!35466
2 parents 48c400d + 62df101 commit b5ee028

File tree

61 files changed

+1731
-132
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+1731
-132
lines changed

components/bootloader/subproject/main/ld/esp32c2/bootloader.ld

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ bootloader_usable_dram_end = 0x3fcdcb70;
2727
bootloader_stack_overhead = 0x2000; /* For safety margin between bootloader data section and startup stacks */
2828
bootloader_dram_seg_len = 0x5000;
2929
bootloader_iram_loader_seg_len = 0x7000;
30-
bootloader_iram_seg_len = 0x2000;
30+
bootloader_iram_seg_len = 0x2800;
3131

3232
/* Start of the lower region is determined by region size and the end of the higher region */
3333
bootloader_dram_seg_end = bootloader_usable_dram_end - bootloader_stack_overhead;

components/bootloader/subproject/main/ld/esp32c3/bootloader.ld

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ bootloader_usable_dram_end = 0x3fcdc710;
2727
bootloader_stack_overhead = 0x2000; /* For safety margin between bootloader data section and startup stacks */
2828
bootloader_dram_seg_len = 0x5000;
2929
bootloader_iram_loader_seg_len = 0x7000;
30-
bootloader_iram_seg_len = 0x2000;
30+
bootloader_iram_seg_len = 0x2800;
3131

3232
/* Start of the lower region is determined by region size and the end of the higher region */
3333
bootloader_dram_seg_end = bootloader_usable_dram_end - bootloader_stack_overhead;

components/bootloader/subproject/main/ld/esp32c5/bootloader.ld

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ bootloader_usable_dram_end = 0x4085c9a0;
2424
bootloader_stack_overhead = 0x2000; /* For safety margin between bootloader data section and startup stacks */
2525
bootloader_dram_seg_len = 0x5000;
2626
bootloader_iram_loader_seg_len = 0x7000;
27-
bootloader_iram_seg_len = 0x2200;
27+
bootloader_iram_seg_len = 0x2A00;
2828

2929
/* Start of the lower region is determined by region size and the end of the higher region */
3030
bootloader_dram_seg_end = bootloader_usable_dram_end - bootloader_stack_overhead;

components/bootloader/subproject/main/ld/esp32c6/bootloader.ld

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ bootloader_usable_dram_end = 0x4087c610;
2424
bootloader_stack_overhead = 0x2000; /* For safety margin between bootloader data section and startup stacks */
2525
bootloader_dram_seg_len = 0x5000;
2626
bootloader_iram_loader_seg_len = 0x7000;
27-
bootloader_iram_seg_len = 0x2500;
27+
bootloader_iram_seg_len = 0x2D00;
2828

2929
/* Start of the lower region is determined by region size and the end of the higher region */
3030
bootloader_dram_seg_end = bootloader_usable_dram_end - bootloader_stack_overhead;

components/bootloader/subproject/main/ld/esp32c61/bootloader.ld

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ bootloader_usable_dram_end = 0x4084ca70;
2424
bootloader_stack_overhead = 0x2000; /* For safety margin between bootloader data section and startup stacks */
2525
bootloader_dram_seg_len = 0x5000;
2626
bootloader_iram_loader_seg_len = 0x7000;
27-
bootloader_iram_seg_len = 0x2500;
27+
bootloader_iram_seg_len = 0x2D00;
2828

2929
/* Start of the lower region is determined by region size and the end of the higher region */
3030
bootloader_dram_seg_end = bootloader_usable_dram_end - bootloader_stack_overhead;

components/bootloader/subproject/main/ld/esp32h2/bootloader.ld

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ bootloader_usable_dram_end = 0x4084cfd0;
2525
bootloader_stack_overhead = 0x2000; /* For safety margin between bootloader data section and startup stacks */
2626
bootloader_dram_seg_len = 0x5000;
2727
bootloader_iram_loader_seg_len = 0x7000;
28-
bootloader_iram_seg_len = 0x2500;
28+
bootloader_iram_seg_len = 0x2D00;
2929

3030
/* Start of the lower region is determined by region size and the end of the higher region */
3131
bootloader_dram_seg_end = bootloader_usable_dram_end - bootloader_stack_overhead;

components/bootloader/subproject/main/ld/esp32h21/bootloader.ld

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ bootloader_usable_dram_end = 0x40849a78;
2525
bootloader_stack_overhead = 0x2000; /* For safety margin between bootloader data section and startup stacks */
2626
bootloader_dram_seg_len = 0x5000;
2727
bootloader_iram_loader_seg_len = 0x7000;
28-
bootloader_iram_seg_len = 0x2500;
28+
bootloader_iram_seg_len = 0x2D00;
2929

3030
/* Start of the lower region is determined by region size and the end of the higher region */
3131
bootloader_dram_seg_end = bootloader_usable_dram_end - bootloader_stack_overhead;

components/bootloader/subproject/main/ld/esp32p4/bootloader.ld

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ bootloader_usable_dram_end = 0x4ff3abd0;
2626
bootloader_stack_overhead = 0x2000; /* For safety margin between bootloader data section and startup stacks */
2727
bootloader_dram_seg_len = 0x5000;
2828
bootloader_iram_loader_seg_len = 0x7000;
29-
bootloader_iram_seg_len = 0x2000;
29+
bootloader_iram_seg_len = 0x2D00;
3030

3131
/* Start of the lower region is determined by region size and the end of the higher region */
3232
bootloader_dram_seg_end = bootloader_usable_dram_end - bootloader_stack_overhead;

components/esp_partition/partition_bootloader.c

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD
2+
* SPDX-FileCopyrightText: 2015-2025 Espressif Systems (Shanghai) CO LTD
33
*
44
* SPDX-License-Identifier: Apache-2.0
55
*
@@ -46,9 +46,9 @@ const esp_partition_t* esp_partition_find_first(esp_partition_type_t type, esp_p
4646

4747
// if everything matches, populate the internal_partition
4848
if (partition->type == type
49-
&& partition->subtype == subtype
50-
&& strncmp((char*) partition->label, label, sizeof(partition->label) - 1) == 0) {
51-
49+
&& partition->subtype == subtype
50+
&& (!label || (label && (strncmp((char*) partition->label, label, sizeof(partition->label) - 1) == 0)))
51+
) {
5252
ESP_LOGV(TAG, "Matched", partition->type, partition->subtype, partition->label);
5353
internal_partition.flash_chip = NULL; //esp_flash_default_chip;
5454
internal_partition.type = partition->type;
@@ -74,6 +74,18 @@ const esp_partition_t* esp_partition_find_first(esp_partition_type_t type, esp_p
7474
esp_err_t esp_partition_read(const esp_partition_t *partition,
7575
size_t src_offset, void *dst, size_t size)
7676
{
77+
assert(partition != NULL);
78+
if (src_offset > partition->size) {
79+
return ESP_ERR_INVALID_ARG;
80+
}
81+
if (size > partition->size - src_offset) {
82+
return ESP_ERR_INVALID_SIZE;
83+
}
84+
85+
if (!partition->encrypted) {
86+
return bootloader_flash_read(partition->address + src_offset, dst, size, false);
87+
}
88+
7789
const void *buf;
7890

7991
// log call to mmap

components/esp_rom/CMakeLists.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,13 @@ if(BOOTLOADER_BUILD)
156156
endif()
157157
endif()
158158

159+
if(CONFIG_MBEDTLS_USE_CRYPTO_ROM_IMPL_BOOTLOADER)
160+
rom_linker_script("mbedtls")
161+
# For ESP32C2(ECO4), mbedTLS in ROM has been updated to v3.6.0-LTS
162+
if(CONFIG_ESP32C2_REV_MIN_FULL GREATER_EQUAL 200)
163+
rom_linker_script("mbedtls.eco4")
164+
endif()
165+
endif()
159166

160167
else() # Regular app build
161168
if(target STREQUAL "esp32")

0 commit comments

Comments
 (0)