Skip to content

Commit 958f4b8

Browse files
committed
feat(esp_tee): Support for ESP32-H2 - the esp_tee component
1 parent 0dbce72 commit 958f4b8

23 files changed

+1489
-99
lines changed

components/esp_tee/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ idf_build_get_property(target IDF_TARGET)
66
# headers & sources here are compiled into the app, not the esp_tee binary
77
# (see subproject/ for the esp_tee binary build files)
88

9-
# ESP-TEE is currently supported only on the ESP32-C6 SoC
10-
if(NOT ${target} STREQUAL "esp32c6")
9+
# ESP-TEE is currently supported only on the ESP32-C6 and ESP32-H2 SoCs
10+
if(NOT ${target} STREQUAL "esp32c6" AND NOT ${target} STREQUAL "esp32h2")
1111
return()
1212
endif()
1313

components/esp_tee/Kconfig.projbuild

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
menu "ESP-TEE (Trusted Execution Environment)"
2-
depends on IDF_TARGET_ESP32C6
2+
depends on IDF_TARGET_ESP32C6 || IDF_TARGET_ESP32H2
33

44
config SECURE_ENABLE_TEE
55
bool "Enable the ESP-TEE framework"
6-
depends on IDF_TARGET_ESP32C6
76
select ESP_SYSTEM_MEMPROT_FEATURE_VIA_TEE
87
help
98
This configuration enables the Trusted Execution Environment (TEE) feature.
@@ -75,7 +74,6 @@ menu "ESP-TEE (Trusted Execution Environment)"
7574
Secure storage will be encrypted by a constant key embedded in the TEE firmware
7675

7776
config SECURE_TEE_SEC_STG_MODE_RELEASE
78-
depends on IDF_TARGET_ESP32C6
7977
bool "Release"
8078
help
8179
Secure storage will be encrypted by the data stored in eFuse block
Lines changed: 296 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,296 @@
1+
secure_services:
2+
- family: misc
3+
entries:
4+
- id: 0
5+
type: custom
6+
function: invalid_secure_service
7+
args: 0
8+
# ID: 1-4 (4) - External memory (Flash) protection [SPI0]
9+
- family: flash_protection_spi0
10+
entries:
11+
- id: 1
12+
type: IDF
13+
function: mmu_hal_map_region
14+
args: 6
15+
- id: 2
16+
type: IDF
17+
function: mmu_hal_unmap_region
18+
args: 3
19+
- id: 3
20+
type: IDF
21+
function: mmu_hal_vaddr_to_paddr
22+
args: 4
23+
- id: 4
24+
type: IDF
25+
function: mmu_hal_paddr_to_vaddr
26+
args: 5
27+
# ID: 5-21 (17) - External memory (Flash) protection [SPI1]
28+
- family: flash_protection_spi1
29+
entries:
30+
- id: 5
31+
type: IDF
32+
function: spi_flash_hal_check_status
33+
args: 1
34+
- id: 6
35+
type: IDF
36+
function: spi_flash_hal_common_command
37+
args: 2
38+
- id: 7
39+
type: IDF
40+
function: spi_flash_hal_device_config
41+
args: 1
42+
- id: 8
43+
type: IDF
44+
function: spi_flash_hal_erase_block
45+
args: 2
46+
- id: 9
47+
type: IDF
48+
function: spi_flash_hal_erase_chip
49+
args: 1
50+
- id: 10
51+
type: IDF
52+
function: spi_flash_hal_erase_sector
53+
args: 2
54+
- id: 11
55+
type: IDF
56+
function: spi_flash_hal_program_page
57+
args: 4
58+
- id: 12
59+
type: IDF
60+
function: spi_flash_hal_read
61+
args: 4
62+
- id: 13
63+
type: IDF
64+
function: spi_flash_hal_resume
65+
args: 1
66+
- id: 14
67+
type: IDF
68+
function: spi_flash_hal_set_write_protect
69+
args: 2
70+
- id: 15
71+
type: IDF
72+
function: spi_flash_hal_setup_read_suspend
73+
args: 2
74+
- id: 16
75+
type: IDF
76+
function: spi_flash_hal_supports_direct_read
77+
args: 2
78+
- id: 17
79+
type: IDF
80+
function: spi_flash_hal_supports_direct_write
81+
args: 2
82+
- id: 18
83+
type: IDF
84+
function: spi_flash_hal_suspend
85+
args: 1
86+
- id: 19
87+
type: IDF
88+
function: bootloader_flash_execute_command_common
89+
args: 7
90+
- id: 20
91+
type: IDF
92+
function: memspi_host_flush_cache
93+
args: 3
94+
- id: 21
95+
type: IDF
96+
function: spi_flash_chip_generic_config_host_io_mode
97+
args: 2
98+
# ID: 30-53 (24) - Interrupt Handling
99+
- family: interrupt_handling
100+
entries:
101+
- id: 30
102+
type: IDF
103+
function: esp_rom_route_intr_matrix
104+
args: 3
105+
- id: 31
106+
type: IDF
107+
function: rv_utils_intr_enable
108+
args: 1
109+
- id: 32
110+
type: IDF
111+
function: rv_utils_intr_disable
112+
args: 1
113+
- id: 33
114+
type: IDF
115+
function: rv_utils_intr_set_priority
116+
args: 2
117+
- id: 34
118+
type: IDF
119+
function: rv_utils_intr_set_type
120+
args: 2
121+
- id: 35
122+
type: IDF
123+
function: rv_utils_intr_set_threshold
124+
args: 1
125+
- id: 36
126+
type: IDF
127+
function: rv_utils_intr_edge_ack
128+
args: 1
129+
- id: 37
130+
type: IDF
131+
function: rv_utils_intr_global_enable
132+
args: 0
133+
# ID: 54-85 (32) - HAL
134+
- family: hal
135+
entries:
136+
- id: 54
137+
type: IDF
138+
function: wdt_hal_init
139+
args: 4
140+
- id: 55
141+
type: IDF
142+
function: wdt_hal_deinit
143+
args: 1
144+
# ID: 86-133 (48) - Crypto
145+
- family: crypto
146+
entries:
147+
- id: 86
148+
type: IDF
149+
function: esp_aes_intr_alloc
150+
args: 0
151+
- id: 87
152+
type: IDF
153+
function: esp_aes_crypt_cbc
154+
args: 6
155+
- id: 88
156+
type: IDF
157+
function: esp_aes_crypt_cfb8
158+
args: 6
159+
- id: 89
160+
type: IDF
161+
function: esp_aes_crypt_cfb128
162+
args: 7
163+
- id: 90
164+
type: IDF
165+
function: esp_aes_crypt_ctr
166+
args: 7
167+
- id: 91
168+
type: IDF
169+
function: esp_aes_crypt_ecb
170+
args: 4
171+
- id: 92
172+
type: IDF
173+
function: esp_aes_crypt_ofb
174+
args: 6
175+
- id: 93
176+
type: IDF
177+
function: esp_sha
178+
args: 4
179+
- id: 94
180+
type: IDF
181+
function: esp_sha_block
182+
args: 3
183+
- id: 95
184+
type: IDF
185+
function: esp_sha_dma
186+
args: 6
187+
- id: 96
188+
type: IDF
189+
function: esp_sha_read_digest_state
190+
args: 2
191+
- id: 97
192+
type: IDF
193+
function: esp_sha_write_digest_state
194+
args: 2
195+
- id: 98
196+
type: IDF
197+
function: esp_crypto_sha_enable_periph_clk
198+
args: 1
199+
- id: 99
200+
type: IDF
201+
function: esp_hmac_calculate
202+
args: 4
203+
- id: 100
204+
type: IDF
205+
function: esp_hmac_jtag_enable
206+
args: 2
207+
- id: 101
208+
type: IDF
209+
function: esp_hmac_jtag_disable
210+
args: 0
211+
- id: 102
212+
type: IDF
213+
function: esp_ds_sign
214+
args: 4
215+
- id: 103
216+
type: IDF
217+
function: esp_ds_start_sign
218+
args: 4
219+
- id: 104
220+
type: IDF
221+
function: esp_ds_is_busy
222+
args: 0
223+
- id: 105
224+
type: IDF
225+
function: esp_ds_finish_sign
226+
args: 2
227+
- id: 106
228+
type: IDF
229+
function: esp_ds_encrypt_params
230+
args: 4
231+
- id: 107
232+
type: IDF
233+
function: esp_crypto_mpi_enable_periph_clk
234+
args: 1
235+
- id: 108
236+
type: IDF
237+
function: esp_ecc_point_multiply
238+
args: 4
239+
- id: 109
240+
type: IDF
241+
function: esp_ecc_point_verify
242+
args: 1
243+
- id: 110
244+
type: IDF
245+
function: esp_crypto_ecc_enable_periph_clk
246+
args: 1
247+
# ID: 134-169 (36) - Reserved for future use
248+
- family: attestation
249+
entries:
250+
- id: 170
251+
type: custom
252+
function: esp_tee_att_generate_token
253+
args: 6
254+
# ID: 175-194 (20) - Secure Storage
255+
- family: secure_storage
256+
entries:
257+
- id: 175
258+
type: custom
259+
function: esp_tee_sec_storage_clear_key
260+
args: 1
261+
- id: 176
262+
type: custom
263+
function: esp_tee_sec_storage_gen_key
264+
args: 1
265+
- id: 177
266+
type: custom
267+
function: esp_tee_sec_storage_ecdsa_sign
268+
args: 4
269+
- id: 178
270+
type: custom
271+
function: esp_tee_sec_storage_ecdsa_get_pubkey
272+
args: 2
273+
- id: 179
274+
type: custom
275+
function: esp_tee_sec_storage_aead_encrypt
276+
args: 4
277+
- id: 180
278+
type: custom
279+
function: esp_tee_sec_storage_aead_decrypt
280+
args: 4
281+
# ID: 195-199 (5) - OTA
282+
- family: ota
283+
entries:
284+
- id: 195
285+
type: custom
286+
function: esp_tee_ota_begin
287+
args: 0
288+
- id: 196
289+
type: custom
290+
function: esp_tee_ota_write
291+
args: 3
292+
- id: 197
293+
type: custom
294+
function: esp_tee_ota_end
295+
args: 0
296+
# ID: 200+ - User-defined

components/esp_tee/src/esp_secure_service_wrapper.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -331,6 +331,13 @@ int __wrap_esp_ecc_point_verify(const ecc_point_t *point)
331331
return err;
332332
}
333333

334+
#if SOC_ECDSA_SUPPORTED
335+
void __wrap_esp_crypto_ecc_enable_periph_clk(bool enable)
336+
{
337+
esp_tee_service_call(2, SS_ESP_CRYPTO_ECC_ENABLE_PERIPH_CLK, enable);
338+
}
339+
#endif
340+
334341
/* ---------------------------------------------- MMU HAL ------------------------------------------------- */
335342

336343
void IRAM_ATTR __wrap_mmu_hal_map_region(uint32_t mmu_id, mmu_target_t mem_type, uint32_t vaddr, uint32_t paddr, uint32_t len, uint32_t *out_len)

components/esp_tee/subproject/main/CMakeLists.txt

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,10 @@ list(APPEND srcs "arch/${arch}/esp_tee_vectors.S"
2020
# SoC specific implementation for TEE
2121
list(APPEND srcs "soc/${target}/esp_tee_secure_sys_cfg.c"
2222
"soc/${target}/esp_tee_pmp_pma_prot_cfg.c"
23-
"soc/${target}/esp_tee_apm_prot_cfg.c"
24-
"soc/${target}/esp_tee_apm_intr.c"
25-
"soc/${target}/esp_tee_aes_intr.c")
23+
"soc/${target}/esp_tee_apm_prot_cfg.c")
24+
25+
list(APPEND srcs "soc/common/esp_tee_apm_intr.c"
26+
"soc/common/esp_tee_aes_intr.c")
2627

2728
# Common module implementation for TEE
2829

@@ -35,6 +36,7 @@ list(APPEND srcs "common/brownout.c")
3536

3637
list(APPEND include "include"
3738
"common"
39+
"soc/common/include"
3840
"soc/${target}/include")
3941

4042
# Heap
@@ -52,6 +54,12 @@ list(APPEND srcs "common/syscall_stubs.c")
5254
idf_component_register(SRCS ${srcs}
5355
INCLUDE_DIRS ${include})
5456

57+
# NOTE: The ESP32-H2 ROM does not have sprintf/snprintf implementation,
58+
# thus newlib-nano implementation from the toolchain has been used.
59+
if(CONFIG_IDF_TARGET_ESP32H2)
60+
target_link_libraries(${COMPONENT_LIB} INTERFACE "--specs=nano.specs")
61+
endif()
62+
5563
# TODO: Currently only -Og optimization level works correctly at runtime
5664
set_source_files_properties("core/esp_secure_dispatcher.c" PROPERTIES COMPILE_FLAGS "-Og")
5765

0 commit comments

Comments
 (0)