Skip to content

Commit d89db7e

Browse files
committed
Merge branch 'feature/spi_hal_move_out_iram_v5.1' into 'release/v5.1'
spi: change linker file to move spi hal out from iram (v5.1) See merge request espressif/esp-idf!23448
2 parents c0c9227 + f61e219 commit d89db7e

File tree

7 files changed

+25
-5
lines changed

7 files changed

+25
-5
lines changed

components/driver/Kconfig

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ menu "Driver Configurations"
8686
bool "Place SPI master ISR function into IRAM"
8787
default y
8888
select PERIPH_CTRL_FUNC_IN_IRAM
89+
select HAL_SPI_MASTER_FUNC_IN_IRAM
8990
help
9091
Place the SPI master ISR in to IRAM to avoid possible cache miss.
9192

@@ -109,6 +110,7 @@ menu "Driver Configurations"
109110
bool "Place SPI slave ISR function into IRAM"
110111
default y
111112
select PERIPH_CTRL_FUNC_IN_IRAM
113+
select HAL_SPI_SLAVE_FUNC_IN_IRAM
112114
help
113115
Place the SPI slave ISR in to IRAM to avoid possible cache miss.
114116

components/driver/test_apps/spi/master/sdkconfig.defaults.esp32

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
CONFIG_ESP_DEFAULT_CPU_FREQ_MHZ_240=y
22
CONFIG_XTAL_FREQ_AUTO=y
3-
CONFIG_SPI_FLASH_SHARE_SPI1_BUS=y
43
CONFIG_ESPTOOLPY_FLASHSIZE_4MB=y
5-
4+
CONFIG_SPI_FLASH_SHARE_SPI1_BUS=y
65
CONFIG_PARTITION_TABLE_CUSTOM=y
76
CONFIG_PARTITION_TABLE_CUSTOM_FILENAME="partition_table_esp32_flash.csv"
87
CONFIG_PARTITION_TABLE_FILENAME="partition_table_esp32_flash.csv"

components/hal/Kconfig

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,4 +90,17 @@ menu "Hardware Abstraction Layer (HAL) and Low Level (LL)"
9090
but you will lose the possibility to debug this module, and some new
9191
features will be added and bugs will be fixed in the IDF source
9292
but cannot be synced to ROM.
93+
94+
config HAL_SPI_MASTER_FUNC_IN_IRAM
95+
bool
96+
depends on SPI_MASTER_ISR_IN_IRAM
97+
help
98+
Enable this option to place SPI master hal layer functions into IRAM.
99+
100+
config HAL_SPI_SLAVE_FUNC_IN_IRAM
101+
bool
102+
depends on SPI_SLAVE_ISR_IN_IRAM
103+
help
104+
Enable this option to place SPI slave hal layer functions into IRAM.
105+
93106
endmenu

components/hal/linker.lf

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,10 @@ entries:
88
if IDF_TARGET_ESP32 = n && APP_BUILD_TYPE_PURE_RAM_APP = n:
99
cache_hal (noflash)
1010
if SOC_GPSPI_SUPPORTED = y:
11-
spi_hal_iram (noflash)
12-
spi_slave_hal_iram (noflash)
11+
if HAL_SPI_MASTER_FUNC_IN_IRAM = y:
12+
spi_hal_iram (noflash)
13+
if HAL_SPI_SLAVE_FUNC_IN_IRAM = y:
14+
spi_slave_hal_iram (noflash)
1315
if UART_ISR_IN_IRAM = y || ESP_PANIC_HANDLER_IRAM = y:
1416
uart_hal_iram (noflash)
1517
else:

components/spi_flash/Kconfig

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,8 @@ menu "SPI Flash driver"
101101
config SPI_FLASH_SHARE_SPI1_BUS
102102
bool "Support other devices attached to SPI1 bus"
103103
default n
104-
depends on !IDF_TARGET_ESP32S2
104+
depends on IDF_TARGET_ESP32
105+
select SPI_MASTER_ISR_IN_IRAM
105106
help
106107
Each SPI bus needs a lock for arbitration among devices. This allows multiple
107108
devices on a same bus, but may reduce the speed of esp_flash driver access to the

docs/en/api-guides/performance/ram-usage.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,7 @@ The following options will reduce IRAM usage of some ESP-IDF features:
139139
:esp32: - If the application uses PSRAM and is based on ESP32 rev. 3 (ECO3), setting :ref:`CONFIG_ESP32_REV_MIN` to ``3`` will disable PSRAM bug workarounds, saving ~10kB or more of IRAM.
140140
- Disabling :ref:`CONFIG_ESP_EVENT_POST_FROM_IRAM_ISR` prevents posting ``esp_event`` events from :ref:`iram-safe-interrupt-handlers` but will save some IRAM.
141141
- Disabling :ref:`CONFIG_SPI_MASTER_ISR_IN_IRAM` prevents spi_master interrupts from being serviced while writing to flash, and may otherwise reduce spi_master performance, but will save some IRAM.
142+
- Disabling :ref:`CONFIG_SPI_SLAVE_ISR_IN_IRAM` prevents spi_slave interrupts from being serviced while writing to flash, will save some IRAM.
142143
- Setting :ref:`CONFIG_HAL_DEFAULT_ASSERTION_LEVEL` to disable assertion for HAL component will save some IRAM especially for HAL code who calls `HAL_ASSERT` a lot and resides in IRAM.
143144
- Refer to sdkconfig menu ``Auto-detect flash chips`` and you can disable flash drivers which you don't need to save some IRAM.
144145

docs/en/api-reference/peripherals/spi_master.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -493,6 +493,8 @@ Typical transaction duration for one byte of data are given below.
493493
- Polling Transaction via DMA: {IDF_TARGET_TRANS_TIME_POLL_DMA} µs.
494494
- Polling Transaction via CPU: {IDF_TARGET_TRANS_TIME_POLL_CPU} µs.
495495

496+
Note that these data are tested with :ref:`CONFIG_SPI_MASTER_ISR_IN_IRAM` enabled. SPI transaction related code are placed in the internal memory. If this option is turned off (for example, for internal memory optimization), the transaction duration may be affected.
497+
496498
SPI Clock Frequency
497499
^^^^^^^^^^^^^^^^^^^
498500

0 commit comments

Comments
 (0)