Skip to content

Commit 41bf07e

Browse files
committed
refactor(esp_tee): Remove the deprecated TEE secure storage partition subtype
1 parent d116567 commit 41bf07e

File tree

10 files changed

+190
-115
lines changed

10 files changed

+190
-115
lines changed

components/bootloader_support/include/esp_flash_partitions.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ extern "C" {
4141
#define PART_SUBTYPE_PARTITION_TABLE_OTA 0x01
4242

4343
#define PART_SUBTYPE_DATA_TEE_OTA 0x90
44-
#define PART_SUBTYPE_DATA_TEE_SEC_STORAGE 0x91
4544

4645
#define PART_TYPE_END 0xff
4746
#define PART_SUBTYPE_END 0xff

components/bootloader_support/src/bootloader_utility.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -226,9 +226,6 @@ bool bootloader_utility_load_partition_table(bootloader_state_t *bs)
226226
bs->tee_ota_info = partition->pos;
227227
partition_usage = "TEE OTA data";
228228
break;
229-
case PART_SUBTYPE_DATA_TEE_SEC_STORAGE: /* TEE secure storage */
230-
partition_usage = "TEE secure storage";
231-
break;
232229
#endif
233230
default:
234231
partition_usage = "Unknown data";

components/esp_partition/include/esp_partition.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,6 @@ typedef enum {
114114
ESP_PARTITION_SUBTYPE_DATA_LITTLEFS = 0x83, //!< LITTLEFS partition
115115

116116
ESP_PARTITION_SUBTYPE_DATA_TEE_OTA = 0x90, //!< TEE OTA selection partition
117-
ESP_PARTITION_SUBTYPE_DATA_TEE_SEC_STORAGE= 0x91, //!< TEE secure storage partition
118117

119118
#if __has_include("extra_partition_subtypes.inc")
120119
#include "extra_partition_subtypes.inc"

components/esp_tee/include/private/esp_tee_binary.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,10 @@ extern "C" {
3939
#error "CONFIG_SECURE_TEE_INTR_STACK_SIZE must be 16-byte (0x10) aligned"
4040
#endif
4141

42+
/* TEE Secure Storage partition label and NVS namespace */
43+
#define ESP_TEE_SEC_STG_PART_LABEL "secure_storage"
44+
#define ESP_TEE_SEC_STG_NVS_NAMESPACE "tee_sec_stg_ns"
45+
4246
/* NOTE: ESP32-C6 - TEE/REE memory regions */
4347
/* TEE I/DRAM */
4448
#define SOC_S_IRAM_START (SOC_IRAM_LOW)

components/esp_tee/subproject/components/tee_flash_mgr/esp_tee_flash.c

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD
2+
* SPDX-FileCopyrightText: 2024-2025 Espressif Systems (Shanghai) CO LTD
33
*
44
* SPDX-License-Identifier: Apache-2.0
55
*/
@@ -166,7 +166,14 @@ esp_err_t esp_tee_flash_setup_prot_ctx(uint8_t tee_boot_part)
166166
if (type == PART_TYPE_APP) {
167167
needs_protection = (subtype == PART_SUBTYPE_TEE_0 || subtype == PART_SUBTYPE_TEE_1);
168168
} else if (type == PART_TYPE_DATA) {
169-
needs_protection = (subtype == PART_SUBTYPE_DATA_TEE_OTA || subtype == PART_SUBTYPE_DATA_TEE_SEC_STORAGE);
169+
if (subtype == PART_SUBTYPE_DATA_TEE_OTA) {
170+
needs_protection = true;
171+
} else if (subtype == PART_SUBTYPE_DATA_WIFI) {
172+
size_t label_len = strlen(ESP_TEE_SEC_STG_PART_LABEL);
173+
if (memcmp(partition_entry->partition.label, ESP_TEE_SEC_STG_PART_LABEL, label_len) == 0) {
174+
needs_protection = true;
175+
}
176+
}
170177
}
171178

172179
if (needs_protection) {

components/esp_tee/subproject/components/tee_sec_storage/CMakeLists.txt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
idf_build_get_property(esp_tee_build ESP_TEE_BUILD)
22

33
set(srcs)
4-
set(priv_requires efuse mbedtls spi_flash)
4+
set(priv_requires esp_tee)
55

66
if(esp_tee_build)
77
list(APPEND srcs "tee_sec_storage.c")
8-
list(APPEND priv_requires esp_partition log nvs_flash tee_flash_mgr)
8+
list(APPEND priv_requires efuse esp_partition log mbedtls nvs_flash spi_flash tee_flash_mgr)
99
else()
1010
list(APPEND srcs "tee_sec_storage_wrapper.c")
11-
set(priv_requires esp_tee)
1211
endif()
1312

1413
idf_component_register(SRCS ${srcs}

components/esp_tee/subproject/components/tee_sec_storage/tee_sec_storage.c

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,6 @@ typedef struct {
7575

7676
_Static_assert(sizeof(sec_stg_key_t) == 256, "Incorrect sec_stg_key_t size");
7777

78-
#define TEE_SEC_STG_PART_LABEL "tee_nvs"
79-
#define TEE_SEC_STG_NVS_NAMESPACE "tee_sec_stg"
80-
8178
static nvs_handle_t tee_nvs_hdl;
8279

8380
static const char *TAG = "secure_storage";
@@ -217,12 +214,12 @@ esp_err_t esp_tee_sec_storage_init(void)
217214
return err;
218215
}
219216

220-
err = nvs_flash_secure_init_partition(TEE_SEC_STG_PART_LABEL, &cfg);
217+
err = nvs_flash_secure_init_partition(ESP_TEE_SEC_STG_PART_LABEL, &cfg);
221218
if (err != ESP_OK) {
222219
return err;
223220
}
224221

225-
err = nvs_open_from_partition(TEE_SEC_STG_PART_LABEL, TEE_SEC_STG_NVS_NAMESPACE, NVS_READWRITE, &tee_nvs_hdl);
222+
err = nvs_open_from_partition(ESP_TEE_SEC_STG_PART_LABEL, ESP_TEE_SEC_STG_NVS_NAMESPACE, NVS_READWRITE, &tee_nvs_hdl);
226223
if (err != ESP_OK) {
227224
return err;
228225
}

0 commit comments

Comments
 (0)