Skip to content

Commit 8886097

Browse files
committed
Merge branch 'patch/ets_delay_us' into 'master'
fix(esp_tee): Patch the `esp_rom_delay_us` API to use U-mode cycle CSR See merge request espressif/esp-idf!40105
2 parents f071b54 + 6d996a0 commit 8886097

File tree

13 files changed

+74
-13
lines changed

13 files changed

+74
-13
lines changed

components/esp_rom/CMakeLists.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -388,6 +388,12 @@ else() # Regular app build
388388
endif()
389389
endif()
390390

391+
if(CONFIG_ESP_ROM_DELAY_US_PATCH AND
392+
(CONFIG_ESP32C5_REV_MIN_FULL LESS_EQUAL 100 OR CONFIG_ESP32C61_REV_MIN_FULL LESS_EQUAL 100))
393+
# Force the linker to include esp_rom_sys.c for ets_ops_set_rom_patches constructor
394+
target_link_libraries(${COMPONENT_LIB} PRIVATE "-u ets_ops_set_rom_patches")
395+
endif()
396+
391397
if(CONFIG_IDF_TARGET_ARCH_XTENSA)
392398
target_link_libraries(${COMPONENT_LIB} INTERFACE "-Wl,--wrap=longjmp")
393399
endif()

components/esp_rom/esp32c5/Kconfig.soc_caps.in

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,3 +118,7 @@ config ESP_ROM_CLIC_INT_THRESH_PATCH
118118
config ESP_ROM_HAS_SUBOPTIMAL_NEWLIB_ON_MISALIGNED_MEMORY
119119
bool
120120
default y
121+
122+
config ESP_ROM_DELAY_US_PATCH
123+
bool
124+
default y

components/esp_rom/esp32c5/esp_rom_caps.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,3 +35,4 @@
3535
#define ESP_ROM_HAS_OUTPUT_PUTC_FUNC (1) // ROM has esp_rom_output_putc (or ets_write_char_uart)
3636
#define ESP_ROM_CLIC_INT_THRESH_PATCH (1) // ROM version of esprv_intc_int_set_threshold incorrectly assumes lowest MINTTHRESH is 0x1F, should be 0xF
3737
#define ESP_ROM_HAS_SUBOPTIMAL_NEWLIB_ON_MISALIGNED_MEMORY (1) // ROM mem/str functions are not optimized well for misaligned memory access.
38+
#define ESP_ROM_DELAY_US_PATCH (1) // ROM ets_delay_us needs patch for U-mode operation

components/esp_rom/esp32c5/include/esp32c5/rom/ets_sys.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,9 @@ struct ETSEventTag {
6464
typedef void (*ETSTask)(ETSEvent *e); /**< Type of the Task processor*/
6565
typedef void (* ets_idle_cb_t)(void *arg); /**< Type of the system idle callback*/
6666

67-
68-
69-
67+
typedef struct ets_ops {
68+
void (*ets_delay_us)(uint32_t us);
69+
} ets_ops;
7070

7171
/**
7272
* @}

components/esp_rom/esp32c5/ld/esp32c5.rom.ld

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ ets_install_putc2 = 0x4000002c;
2727
ets_install_uart_printf = 0x40000030;
2828
ets_install_usb_printf = 0x40000034;
2929
ets_get_printf_channel = 0x40000038;
30-
ets_delay_us = 0x4000003c;
30+
PROVIDE ( ets_delay_us = 0x4000003c );
3131
ets_get_cpu_frequency = 0x40000040;
3232
ets_update_cpu_frequency = 0x40000044;
3333
ets_install_lock = 0x40000048;

components/esp_rom/esp32c5/ld/esp32c5.rom.pp.ld

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ hal_tsf_clear_soc_wakeup_request = 0x40000c60;
5252
hal_get_tsf_time = 0x40000c64;
5353
hal_get_sta_tsf = 0x40000c68;
5454
ic_get_trc = 0x40000c74;
55-
ic_mac_deinit = 0x40000c78;
55+
/* ic_mac_deinit = 0x40000c78; */
5656
/* ic_mac_init = 0x40000c7c; */
5757
ic_interface_enabled = 0x40000c80;
5858
is_lmac_idle = 0x40000c84;
@@ -75,7 +75,7 @@ lmacRxDone = 0x40000cc4;
7575
lmacSetTxFrame = 0x40000cc8;
7676
lmacTxDone = 0x40000ccc;
7777
/*lmacTxFrame = 0x40000cd0;*/
78-
lmacDisableTransmit = 0x40000cd4;
78+
/* lmacDisableTransmit = 0x40000cd4; */
7979
lmacDiscardFrameExchangeSequence = 0x40000cd8;
8080
lmacProcessCollision = 0x40000cdc;
8181
lmacProcessAckTimeout = 0x40000ce0;

components/esp_rom/esp32c61/Kconfig.soc_caps.in

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,3 +114,7 @@ config ESP_ROM_HAS_OUTPUT_PUTC_FUNC
114114
config ESP_ROM_HAS_SUBOPTIMAL_NEWLIB_ON_MISALIGNED_MEMORY
115115
bool
116116
default y
117+
118+
config ESP_ROM_DELAY_US_PATCH
119+
bool
120+
default y

components/esp_rom/esp32c61/esp_rom_caps.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,3 +34,4 @@
3434
#define ESP_ROM_USB_OTG_NUM (-1) // No USB_OTG CDC in the ROM, set -1 for Kconfig usage.
3535
#define ESP_ROM_HAS_OUTPUT_PUTC_FUNC (1) // ROM has esp_rom_output_putc (or ets_write_char_uart)
3636
#define ESP_ROM_HAS_SUBOPTIMAL_NEWLIB_ON_MISALIGNED_MEMORY (1) // ROM mem/str functions are not optimized well for misaligned memory access.
37+
#define ESP_ROM_DELAY_US_PATCH (1) // ROM ets_delay_us needs patch for U-mode operation

components/esp_rom/esp32c61/include/esp32c61/rom/ets_sys.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,9 @@ struct ETSEventTag {
6464
typedef void (*ETSTask)(ETSEvent *e); /**< Type of the Task processor*/
6565
typedef void (* ets_idle_cb_t)(void *arg); /**< Type of the system idle callback*/
6666

67-
68-
69-
67+
typedef struct ets_ops {
68+
void (*ets_delay_us)(uint32_t us);
69+
} ets_ops;
7070

7171
/**
7272
* @}

components/esp_rom/esp32c61/ld/esp32c61.rom.ld

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ ets_install_putc2 = 0x4000002c;
2323
ets_install_uart_printf = 0x40000030;
2424
ets_install_usb_printf = 0x40000034;
2525
ets_get_printf_channel = 0x40000038;
26-
ets_delay_us = 0x4000003c;
26+
PROVIDE ( ets_delay_us = 0x4000003c );
2727
ets_get_cpu_frequency = 0x40000040;
2828
ets_update_cpu_frequency = 0x40000044;
2929
ets_install_lock = 0x40000048;

0 commit comments

Comments
 (0)