summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ports/esp32/boards/sdkconfig.spiram2
-rw-r--r--ports/esp32/esp32_common.cmake2
-rw-r--r--ports/esp32/main_esp32/linker.lf39
-rw-r--r--ports/esp32/main_esp32c3/linker.lf1
-rw-r--r--ports/esp32/main_esp32s2/linker.lf1
-rw-r--r--ports/esp32/main_esp32s3/linker.lf1
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).