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>
pull/14145/head
Jim Mussared 2024-03-21 15:46:41 +11:00 zatwierdzone przez Damien George
rodzic 71044a4186
commit acbdbcd95e
6 zmienionych plików z 45 dodań i 1 usunięć

Wyświetl plik

@ -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

Wyświetl plik

@ -151,6 +151,8 @@ idf_component_register(
${MICROPY_PORT_DIR}
${MICROPY_BOARD_DIR}
${CMAKE_BINARY_DIR}
LDFRAGMENTS
linker.lf
REQUIRES
${IDF_COMPONENTS}
)

Wyświetl plik

@ -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).

Wyświetl plik

@ -0,0 +1 @@
# Empty linker fragment (no workaround required for C3, see main_esp32/linker.lf).

Wyświetl plik

@ -0,0 +1 @@
# Empty linker fragment (no workaround required for S2, see main_esp32/linker.lf).

Wyświetl plik

@ -0,0 +1 @@
# Empty linker fragment (no workaround required for S3, see main_esp32/linker.lf).