summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrobert-hh <robert@hammelrath.com>2023-10-10 09:36:18 +0200
committerDamien George <damien@micropython.org>2023-10-16 23:36:54 +1100
commitf84b4617cb6e15f943ea81efeeafa651a9553445 (patch)
tree60834c62b57e1d7f71e70696bb3a2fea725cca53
parent4074f828dd107cb5eb469b0d7338d3b39d0a99e9 (diff)
rp2/cyw43_configport: Use m_tracked_calloc and m_tracked_free.
When using malloc and free there were out-of-memory situations depending on the arm-none-eabi package version. This commit changes malloc/free to use the MicroPython GC heap instead. Signed-off-by: robert-hh <robert@hammelrath.com> Signed-off-by: Damien George <damien@micropython.org>
-rw-r--r--ports/rp2/boards/RPI_PICO_W/mpconfigboard.cmake3
-rw-r--r--ports/rp2/cyw43_configport.h9
2 files changed, 5 insertions, 7 deletions
diff --git a/ports/rp2/boards/RPI_PICO_W/mpconfigboard.cmake b/ports/rp2/boards/RPI_PICO_W/mpconfigboard.cmake
index 5610c313e..cea6c38d7 100644
--- a/ports/rp2/boards/RPI_PICO_W/mpconfigboard.cmake
+++ b/ports/rp2/boards/RPI_PICO_W/mpconfigboard.cmake
@@ -2,9 +2,6 @@
set(PICO_BOARD "pico_w")
-# The C malloc is needed by cyw43-driver Bluetooth
-set(MICROPY_C_HEAP_SIZE 4096)
-
set(MICROPY_PY_LWIP ON)
set(MICROPY_PY_NETWORK_CYW43 ON)
diff --git a/ports/rp2/cyw43_configport.h b/ports/rp2/cyw43_configport.h
index 929d83537..8f64762df 100644
--- a/ports/rp2/cyw43_configport.h
+++ b/ports/rp2/cyw43_configport.h
@@ -90,13 +90,14 @@
#define cyw43_schedule_internal_poll_dispatch(func) pendsv_schedule_dispatch(PENDSV_DISPATCH_CYW43, func)
-// Bluetooth uses the C heap to load its firmware (provided by pico-sdk).
-// Space is reserved for this, see MICROPY_C_HEAP_SIZE.
+// Bluetooth requires dynamic memory allocation to load its firmware (the allocation
+// call is made from pico-sdk). This allocation is always done at thread-level, not
+// from an IRQ, so is safe to delegate to the MicroPython GC heap.
#ifndef cyw43_malloc
-#define cyw43_malloc malloc
+#define cyw43_malloc(nmemb) m_tracked_calloc(nmemb, 1)
#endif
#ifndef cyw43_free
-#define cyw43_free free
+#define cyw43_free m_tracked_free
#endif
void cyw43_post_poll_hook(void);