Skip to content

Commit 561c7c4

Browse files
committed
Merge branch 'fix/flash_log_clearer' into 'master'
fix(spi_flash): Make GD chip to be linked as default, also optimization the log information See merge request espressif/esp-idf!39165
2 parents e9d7adf + a1c6d2a commit 561c7c4

29 files changed

+163
-110
lines changed

components/esp_tee/subproject/main/core/esp_secure_services_iram.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,11 @@ uint32_t _ss_spi_flash_hal_check_status(spi_flash_host_inst_t *host)
212212

213213
esp_err_t _ss_spi_flash_hal_common_command(spi_flash_host_inst_t *host, spi_flash_trans_t *trans)
214214
{
215+
bool paddr_chk = esp_tee_flash_check_paddr_in_tee_region(trans->address);
216+
if (paddr_chk) {
217+
ESP_LOGD(TAG, "[%s] Illegal flash access at 0x%08x", __func__, trans->address);
218+
return ESP_FAIL;
219+
}
215220
return spi_flash_hal_common_command(host, trans);
216221
}
217222

components/esp_tee/test_apps/tee_test_fw/main/test_esp_tee_flash_prot.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -125,13 +125,13 @@ static void test_esp_partition_api_w(const esp_partition_t *part)
125125
TEST_ASSERT_NOT_NULL(part);
126126
uint8_t buf_w[128];
127127
memset(buf_w, 0xA5, sizeof(buf_w));
128-
TEST_ESP_OK(esp_partition_write(part, 0x00, buf_w, sizeof(buf_w)));
128+
TEST_ESP_ERR(ESP_FAIL, esp_partition_write(part, 0x00, buf_w, sizeof(buf_w)));
129129
}
130130

131131
static void test_esp_partition_api_e(const esp_partition_t *part)
132132
{
133133
TEST_ASSERT_NOT_NULL(part);
134-
TEST_ESP_OK(esp_partition_erase_range(part, 0x00, SPI_FLASH_SEC_SIZE));
134+
TEST_ESP_ERR(ESP_FAIL, esp_partition_erase_range(part, 0x00, SPI_FLASH_SEC_SIZE));
135135
}
136136

137137
static void test_esp_partition_api(void)
@@ -229,12 +229,12 @@ static void test_esp_flash_api_w(uint32_t paddr)
229229
{
230230
uint8_t buf_w[128];
231231
memset(buf_w, 0xA5, sizeof(buf_w));
232-
TEST_ESP_OK(esp_flash_write(NULL, buf_w, paddr, sizeof(buf_w)));
232+
TEST_ESP_ERR(ESP_FAIL, esp_flash_write(NULL, buf_w, paddr, sizeof(buf_w)));
233233
}
234234

235235
static void test_esp_flash_api_e(uint32_t paddr)
236236
{
237-
TEST_ESP_OK(esp_flash_erase_region(NULL, paddr, SPI_FLASH_SEC_SIZE));
237+
TEST_ESP_ERR(ESP_FAIL, esp_flash_erase_region(NULL, paddr, SPI_FLASH_SEC_SIZE));
238238
}
239239

240240
static void test_esp_flash_api(void)

components/esp_tee/test_apps/tee_test_fw/pytest_esp_tee_ut.py

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# SPDX-FileCopyrightText: 2024-2025 Espressif Systems (Shanghai) CO LTD
22
# SPDX-License-Identifier: Apache-2.0
3+
import re
34
from enum import Enum
45
from typing import Dict
56
from typing import Tuple
@@ -20,7 +21,7 @@
2021

2122
CONFIG_OTA = [
2223
# 'config, target, skip_autoflash, markers',
23-
('ota', target, 'y', (pytest.mark.generic,))
24+
('ota', target, 'y', (pytest.mark.host_test,))
2425
for target in SUPPORTED_TARGETS
2526
]
2627

@@ -198,8 +199,18 @@ def expect_panic_rsn(dut: IdfDut, expected_rsn: str) -> None:
198199

199200
def run_multiple_stages(dut: IdfDut, test_case_num: int, stages: int, api: TeeFlashAccessApi) -> None:
200201
expected_ops = {
201-
TeeFlashAccessApi.ESP_PARTITION: ['read', 'program_page', 'program_page', 'erase_sector'],
202-
TeeFlashAccessApi.ESP_FLASH: ['program_page', 'read', 'erase_sector', 'program_page'],
202+
TeeFlashAccessApi.ESP_PARTITION: [
203+
'read',
204+
'program_page|common_command',
205+
'program_page|common_command',
206+
'erase_sector|common_command',
207+
],
208+
TeeFlashAccessApi.ESP_FLASH: [
209+
'program_page|common_command',
210+
'read',
211+
'erase_sector|common_command',
212+
'program_page|common_command',
213+
],
203214
}
204215

205216
flash_enc_enabled = dut.app.sdkconfig.get('SECURE_FLASH_ENC_ENABLED', True)
@@ -225,7 +236,7 @@ def run_multiple_stages(dut: IdfDut, test_case_num: int, stages: int, api: TeeFl
225236
r'\[_ss_spi_flash_hal_(\w+)\] Illegal flash access at \s*(0x[0-9a-fA-F]+)', timeout=10
226237
)
227238
actual_op = match.group(1).decode()
228-
if actual_op != curr_op:
239+
if not re.fullmatch(curr_op, actual_op):
229240
raise RuntimeError(f'Unexpected flash operation: {actual_op} (expected: {curr_op})')
230241
elif api == TeeFlashAccessApi.ESP_ROM_SPIFLASH:
231242
expect_panic_rsn(dut, 'APM - Authority exception')

components/spi_flash/Kconfig

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -374,7 +374,7 @@ menu "SPI Flash driver"
374374

375375
config SPI_FLASH_SUPPORT_ISSI_CHIP
376376
bool "ISSI"
377-
default y if SPI_FLASH_VENDOR_ISSI_SUPPORTED
377+
default y if SPI_FLASH_VENDOR_ISSI_SUPPORT_ENABLED
378378
default n
379379
help
380380
Enable this to support auto detection of ISSI chips if chip vendor not directly
@@ -383,7 +383,7 @@ menu "SPI Flash driver"
383383

384384
config SPI_FLASH_SUPPORT_MXIC_CHIP
385385
bool "MXIC"
386-
default y if SPI_FLASH_VENDOR_MXIC_SUPPORTED
386+
default y if SPI_FLASH_VENDOR_MXIC_SUPPORT_ENABLED
387387
default n
388388
help
389389
Enable this to support auto detection of MXIC chips if chip vendor not directly
@@ -392,7 +392,7 @@ menu "SPI Flash driver"
392392

393393
config SPI_FLASH_SUPPORT_GD_CHIP
394394
bool "GigaDevice"
395-
default y if SPI_FLASH_VENDOR_GD_SUPPORTED
395+
default y if SPI_FLASH_VENDOR_GD_SUPPORT_ENABLED
396396
default n
397397
help
398398
Enable this to support auto detection of GD (GigaDevice) chips if chip vendor not
@@ -406,7 +406,7 @@ menu "SPI Flash driver"
406406

407407
config SPI_FLASH_SUPPORT_WINBOND_CHIP
408408
bool "Winbond"
409-
default y if SPI_FLASH_VENDOR_WINBOND_SUPPORTED
409+
default y if SPI_FLASH_VENDOR_WINBOND_SUPPORT_ENABLED
410410
default n
411411
help
412412
Enable this to support auto detection of Winbond chips if chip vendor not directly
@@ -416,7 +416,7 @@ menu "SPI Flash driver"
416416
config SPI_FLASH_SUPPORT_BOYA_CHIP
417417
bool "BOYA"
418418
# ESP32 doesn't usually use this chip, default n to save iram.
419-
default y if SPI_FLASH_VENDOR_BOYA_SUPPORTED
419+
default y if SPI_FLASH_VENDOR_BOYA_SUPPORT_ENABLED
420420
default n
421421
help
422422
Enable this to support auto detection of BOYA chips if chip vendor not directly
@@ -426,7 +426,7 @@ menu "SPI Flash driver"
426426
config SPI_FLASH_SUPPORT_TH_CHIP
427427
bool "TH"
428428
# ESP32 doesn't usually use this chip, default n to save iram.
429-
default y if SPI_FLASH_VENDOR_TH_SUPPORTED
429+
default y if SPI_FLASH_VENDOR_TH_SUPPORT_ENABLED
430430
default n
431431
help
432432
Enable this to support auto detection of TH chips if chip vendor not directly

components/spi_flash/esp32/Kconfig.soc_caps.in

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,22 @@
33
# using gen_soc_caps_kconfig.py, do not edit manually
44
#####################################################
55

6-
config SPI_FLASH_VENDOR_XMC_SUPPORTED
6+
config SPI_FLASH_VENDOR_XMC_SUPPORT_ENABLED
77
bool
88
default y
99

10-
config SPI_FLASH_VENDOR_GD_SUPPORTED
10+
config SPI_FLASH_VENDOR_GD_SUPPORT_ENABLED
1111
bool
1212
default y
1313

14-
config SPI_FLASH_VENDOR_ISSI_SUPPORTED
14+
config SPI_FLASH_VENDOR_ISSI_SUPPORT_ENABLED
1515
bool
1616
default y
1717

18-
config SPI_FLASH_VENDOR_MXIC_SUPPORTED
18+
config SPI_FLASH_VENDOR_MXIC_SUPPORT_ENABLED
1919
bool
2020
default y
2121

22-
config SPI_FLASH_VENDOR_WINBOND_SUPPORTED
22+
config SPI_FLASH_VENDOR_WINBOND_SUPPORT_ENABLED
2323
bool
2424
default y
Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,29 @@
11
/*
2-
* SPDX-FileCopyrightText: 2023 Espressif Systems (Shanghai) CO LTD
2+
* SPDX-FileCopyrightText: 2023-2025 Espressif Systems (Shanghai) CO LTD
33
*
44
* SPDX-License-Identifier: Apache-2.0
55
*/
66

77
/**
8-
* This file records the flash vendor that we offically supported.
8+
* This file records the flash vendor that we officially supported.
99
* we have many chip-specific files, like ``spi_flash_chip_gd.c``,
1010
* which means that this file is used for GD flash chips.
1111
*
12-
* The following definations illustrate what flash vendor is officially
12+
* The following definitions illustrate what flash vendor is officially
1313
* supported by ESP chips. If a flash vendor is officially supported, the chip
1414
* specific file will be linked by default, vice versa. You can also adjust this
1515
* manually in Kconfig options.
1616
*
1717
* For example:
18-
* Following `SPI_FLASH_VENDOR_ISSI_SUPPORTED` is (1), which means file `spi_flash_chip_issi.c`
18+
* Following `SPI_FLASH_VENDOR_ISSI_SUPPORT_ENABLED` is (1), which means file `spi_flash_chip_issi.c`
1919
* will be linked.
2020
*
2121
*/
2222

2323
#pragma once
2424

25-
#define SPI_FLASH_VENDOR_XMC_SUPPORTED (1)
26-
#define SPI_FLASH_VENDOR_GD_SUPPORTED (1)
27-
#define SPI_FLASH_VENDOR_ISSI_SUPPORTED (1)
28-
#define SPI_FLASH_VENDOR_MXIC_SUPPORTED (1)
29-
#define SPI_FLASH_VENDOR_WINBOND_SUPPORTED (1)
25+
#define SPI_FLASH_VENDOR_XMC_SUPPORT_ENABLED (1)
26+
#define SPI_FLASH_VENDOR_GD_SUPPORT_ENABLED (1)
27+
#define SPI_FLASH_VENDOR_ISSI_SUPPORT_ENABLED (1)
28+
#define SPI_FLASH_VENDOR_MXIC_SUPPORT_ENABLED (1)
29+
#define SPI_FLASH_VENDOR_WINBOND_SUPPORT_ENABLED (1)

components/spi_flash/esp32c2/Kconfig.soc_caps.in

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,30 +3,30 @@
33
# using gen_soc_caps_kconfig.py, do not edit manually
44
#####################################################
55

6-
config SPI_FLASH_VENDOR_XMC_SUPPORTED
6+
config SPI_FLASH_VENDOR_XMC_SUPPORT_ENABLED
77
bool
88
default y
99

10-
config SPI_FLASH_VENDOR_GD_SUPPORTED
10+
config SPI_FLASH_VENDOR_GD_SUPPORT_ENABLED
1111
bool
1212
default y
1313

14-
config SPI_FLASH_VENDOR_ISSI_SUPPORTED
14+
config SPI_FLASH_VENDOR_ISSI_SUPPORT_ENABLED
1515
bool
1616
default y
1717

18-
config SPI_FLASH_VENDOR_MXIC_SUPPORTED
18+
config SPI_FLASH_VENDOR_MXIC_SUPPORT_ENABLED
1919
bool
2020
default y
2121

22-
config SPI_FLASH_VENDOR_WINBOND_SUPPORTED
22+
config SPI_FLASH_VENDOR_WINBOND_SUPPORT_ENABLED
2323
bool
2424
default y
2525

26-
config SPI_FLASH_VENDOR_BOYA_SUPPORTED
26+
config SPI_FLASH_VENDOR_BOYA_SUPPORT_ENABLED
2727
bool
2828
default y
2929

30-
config SPI_FLASH_VENDOR_TH_SUPPORTED
30+
config SPI_FLASH_VENDOR_TH_SUPPORT_ENABLED
3131
bool
3232
default y
Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
/*
2-
* SPDX-FileCopyrightText: 2023 Espressif Systems (Shanghai) CO LTD
2+
* SPDX-FileCopyrightText: 2023-2025 Espressif Systems (Shanghai) CO LTD
33
*
44
* SPDX-License-Identifier: Apache-2.0
55
*/
66
#pragma once
77

8-
#define SPI_FLASH_VENDOR_XMC_SUPPORTED (1)
9-
#define SPI_FLASH_VENDOR_GD_SUPPORTED (1)
10-
#define SPI_FLASH_VENDOR_ISSI_SUPPORTED (1)
11-
#define SPI_FLASH_VENDOR_MXIC_SUPPORTED (1)
12-
#define SPI_FLASH_VENDOR_WINBOND_SUPPORTED (1)
13-
#define SPI_FLASH_VENDOR_BOYA_SUPPORTED (1)
14-
#define SPI_FLASH_VENDOR_TH_SUPPORTED (1)
8+
#define SPI_FLASH_VENDOR_XMC_SUPPORT_ENABLED (1)
9+
#define SPI_FLASH_VENDOR_GD_SUPPORT_ENABLED (1)
10+
#define SPI_FLASH_VENDOR_ISSI_SUPPORT_ENABLED (1)
11+
#define SPI_FLASH_VENDOR_MXIC_SUPPORT_ENABLED (1)
12+
#define SPI_FLASH_VENDOR_WINBOND_SUPPORT_ENABLED (1)
13+
#define SPI_FLASH_VENDOR_BOYA_SUPPORT_ENABLED (1)
14+
#define SPI_FLASH_VENDOR_TH_SUPPORT_ENABLED (1)

components/spi_flash/esp32c3/Kconfig.soc_caps.in

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,30 +3,30 @@
33
# using gen_soc_caps_kconfig.py, do not edit manually
44
#####################################################
55

6-
config SPI_FLASH_VENDOR_XMC_SUPPORTED
6+
config SPI_FLASH_VENDOR_XMC_SUPPORT_ENABLED
77
bool
88
default y
99

10-
config SPI_FLASH_VENDOR_GD_SUPPORTED
10+
config SPI_FLASH_VENDOR_GD_SUPPORT_ENABLED
1111
bool
1212
default y
1313

14-
config SPI_FLASH_VENDOR_ISSI_SUPPORTED
14+
config SPI_FLASH_VENDOR_ISSI_SUPPORT_ENABLED
1515
bool
1616
default y
1717

18-
config SPI_FLASH_VENDOR_MXIC_SUPPORTED
18+
config SPI_FLASH_VENDOR_MXIC_SUPPORT_ENABLED
1919
bool
2020
default y
2121

22-
config SPI_FLASH_VENDOR_WINBOND_SUPPORTED
22+
config SPI_FLASH_VENDOR_WINBOND_SUPPORT_ENABLED
2323
bool
2424
default y
2525

26-
config SPI_FLASH_VENDOR_BOYA_SUPPORTED
26+
config SPI_FLASH_VENDOR_BOYA_SUPPORT_ENABLED
2727
bool
2828
default y
2929

30-
config SPI_FLASH_VENDOR_TH_SUPPORTED
30+
config SPI_FLASH_VENDOR_TH_SUPPORT_ENABLED
3131
bool
3232
default y
Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
/*
2-
* SPDX-FileCopyrightText: 2023 Espressif Systems (Shanghai) CO LTD
2+
* SPDX-FileCopyrightText: 2023-2025 Espressif Systems (Shanghai) CO LTD
33
*
44
* SPDX-License-Identifier: Apache-2.0
55
*/
66
#pragma once
77

8-
#define SPI_FLASH_VENDOR_XMC_SUPPORTED (1)
9-
#define SPI_FLASH_VENDOR_GD_SUPPORTED (1)
10-
#define SPI_FLASH_VENDOR_ISSI_SUPPORTED (1)
11-
#define SPI_FLASH_VENDOR_MXIC_SUPPORTED (1)
12-
#define SPI_FLASH_VENDOR_WINBOND_SUPPORTED (1)
13-
#define SPI_FLASH_VENDOR_BOYA_SUPPORTED (1)
14-
#define SPI_FLASH_VENDOR_TH_SUPPORTED (1)
8+
#define SPI_FLASH_VENDOR_XMC_SUPPORT_ENABLED (1)
9+
#define SPI_FLASH_VENDOR_GD_SUPPORT_ENABLED (1)
10+
#define SPI_FLASH_VENDOR_ISSI_SUPPORT_ENABLED (1)
11+
#define SPI_FLASH_VENDOR_MXIC_SUPPORT_ENABLED (1)
12+
#define SPI_FLASH_VENDOR_WINBOND_SUPPORT_ENABLED (1)
13+
#define SPI_FLASH_VENDOR_BOYA_SUPPORT_ENABLED (1)
14+
#define SPI_FLASH_VENDOR_TH_SUPPORT_ENABLED (1)

0 commit comments

Comments
 (0)