diff options
| author | Jim Mussared <jim.mussared@gmail.com> | 2024-03-21 15:46:41 +1100 |
|---|---|---|
| committer | Damien George <damien@micropython.org> | 2024-03-22 12:14:27 +1100 |
| commit | acbdbcd95e6d953b08f0642a844c1808323e0b7c (patch) | |
| tree | f05ae1b959b70a454969b569e343188838948764 | |
| parent | 71044a4186bda22477e7daf98e718c144d22d519 (diff) | |
esp32: Workaround IDF issue placing ISR ringbuf functions in IRAM.
This workaround makes sure that all ringbuf functions that may be called
from an ISR are placed in IRAM. See
https://github.com/espressif/esp-idf/issues/13378
Note that this means that all esp32-og builds get non-ISR ringbuf functions
placed in flash now, whereas previously it was just the spiram variant.
This might be a good thing (e.g. free up some IRAM for native/viper).
Fixes issue #14005.
This work was funded through GitHub Sponsors.
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
| -rw-r--r-- | ports/esp32/boards/sdkconfig.spiram | 2 | ||||
| -rw-r--r-- | ports/esp32/esp32_common.cmake | 2 | ||||
| -rw-r--r-- | ports/esp32/main_esp32/linker.lf | 39 | ||||
| -rw-r--r-- | ports/esp32/main_esp32c3/linker.lf | 1 | ||||
| -rw-r--r-- | ports/esp32/main_esp32s2/linker.lf | 1 | ||||
| -rw-r--r-- | ports/esp32/main_esp32s3/linker.lf | 1 |
6 files changed, 45 insertions, 1 deletions
diff --git a/ports/esp32/boards/sdkconfig.spiram b/ports/esp32/boards/sdkconfig.spiram index f5503d554..35fe3c676 100644 --- a/ports/esp32/boards/sdkconfig.spiram +++ b/ports/esp32/boards/sdkconfig.spiram @@ -13,6 +13,6 @@ CONFIG_SPIRAM_MALLOC_ALWAYSINTERNAL=8192 # to PSRAM bug workarounds. Apply some options to reduce the firmware size. CONFIG_COMPILER_OPTIMIZATION_SIZE=y CONFIG_COMPILER_OPTIMIZATION_CHECKS_SILENT=y -CONFIG_RINGBUF_PLACE_FUNCTIONS_INTO_FLASH=y +# CONFIG_RINGBUF_PLACE_FUNCTIONS_INTO_FLASH=y # Workaround required: see main_esp32/linker.lf CONFIG_FREERTOS_PLACE_FUNCTIONS_INTO_FLASH=y CONFIG_FREERTOS_PLACE_SNAPSHOT_FUNS_INTO_FLASH=y diff --git a/ports/esp32/esp32_common.cmake b/ports/esp32/esp32_common.cmake index a3637870f..89e46f9cf 100644 --- a/ports/esp32/esp32_common.cmake +++ b/ports/esp32/esp32_common.cmake @@ -151,6 +151,8 @@ idf_component_register( ${MICROPY_PORT_DIR} ${MICROPY_BOARD_DIR} ${CMAKE_BINARY_DIR} + LDFRAGMENTS + linker.lf REQUIRES ${IDF_COMPONENTS} ) diff --git a/ports/esp32/main_esp32/linker.lf b/ports/esp32/main_esp32/linker.lf new file mode 100644 index 000000000..e00cd63f5 --- /dev/null +++ b/ports/esp32/main_esp32/linker.lf @@ -0,0 +1,39 @@ +# This fixes components/esp_ringbuf/linker.lf to allow us to put non-ISR ringbuf functions in flash. + +# Requires that both RINGBUF_PLACE_FUNCTIONS_INTO_FLASH and RINGBUF_PLACE_ISR_FUNCTIONS_INTO_FLASH +# are set to "n" (which is the default), otherwise this would result in duplicate section config +# when resolving the linker fragments. + +# The effect of this file is to leave the ISR functions in RAM (which we require), but apply a fixed +# version of RINGBUF_PLACE_FUNCTIONS_INTO_FLASH=y (leaving out prvGetFreeSize and prvGetCurMaxSizeByteBuf) +# See https://github.com/espressif/esp-idf/issues/13378 + +[mapping:esp_ringbuf_fix] +archive: libesp_ringbuf.a +entries: + # This is exactly the list of functions from RINGBUF_PLACE_FUNCTIONS_INTO_FLASH=y, + # but with prvGetFreeSize and prvGetCurMaxSizeByteBuf removed. + ringbuf: prvGetCurMaxSizeNoSplit (default) + ringbuf: prvGetCurMaxSizeAllowSplit (default) + ringbuf: prvInitializeNewRingbuffer (default) + ringbuf: prvReceiveGeneric (default) + ringbuf: vRingbufferDelete (default) + ringbuf: vRingbufferGetInfo (default) + ringbuf: vRingbufferReturnItem (default) + ringbuf: xRingbufferAddToQueueSetRead (default) + ringbuf: xRingbufferCanRead (default) + ringbuf: xRingbufferCreate (default) + ringbuf: xRingbufferCreateStatic (default) + ringbuf: xRingbufferCreateNoSplit (default) + ringbuf: xRingbufferReceive (default) + ringbuf: xRingbufferReceiveSplit (default) + ringbuf: xRingbufferReceiveUpTo (default) + ringbuf: xRingbufferRemoveFromQueueSetRead (default) + ringbuf: xRingbufferSend (default) + ringbuf: xRingbufferSendAcquire (default) + ringbuf: xRingbufferSendComplete (default) + ringbuf: xRingbufferPrintInfo (default) + ringbuf: xRingbufferGetMaxItemSize (default) + ringbuf: xRingbufferGetCurFreeSize (default) + + # Everything else will have the default rule already applied (i.e. noflash_text). diff --git a/ports/esp32/main_esp32c3/linker.lf b/ports/esp32/main_esp32c3/linker.lf new file mode 100644 index 000000000..31c5b4563 --- /dev/null +++ b/ports/esp32/main_esp32c3/linker.lf @@ -0,0 +1 @@ +# Empty linker fragment (no workaround required for C3, see main_esp32/linker.lf). diff --git a/ports/esp32/main_esp32s2/linker.lf b/ports/esp32/main_esp32s2/linker.lf new file mode 100644 index 000000000..3c496fa87 --- /dev/null +++ b/ports/esp32/main_esp32s2/linker.lf @@ -0,0 +1 @@ +# Empty linker fragment (no workaround required for S2, see main_esp32/linker.lf). diff --git a/ports/esp32/main_esp32s3/linker.lf b/ports/esp32/main_esp32s3/linker.lf new file mode 100644 index 000000000..81d27906b --- /dev/null +++ b/ports/esp32/main_esp32s3/linker.lf @@ -0,0 +1 @@ +# Empty linker fragment (no workaround required for S3, see main_esp32/linker.lf). |
