Browse Source

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>
pull/12647/head
robert-hh 1 year ago
committed by Damien George
parent
commit
f84b4617cb
  1. 3
      ports/rp2/boards/RPI_PICO_W/mpconfigboard.cmake
  2. 9
      ports/rp2/cyw43_configport.h

3
ports/rp2/boards/RPI_PICO_W/mpconfigboard.cmake

@ -2,9 +2,6 @@
set(PICO_BOARD "pico_w") 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_LWIP ON)
set(MICROPY_PY_NETWORK_CYW43 ON) set(MICROPY_PY_NETWORK_CYW43 ON)

9
ports/rp2/cyw43_configport.h

@ -90,13 +90,14 @@
#define cyw43_schedule_internal_poll_dispatch(func) pendsv_schedule_dispatch(PENDSV_DISPATCH_CYW43, func) #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). // Bluetooth requires dynamic memory allocation to load its firmware (the allocation
// Space is reserved for this, see MICROPY_C_HEAP_SIZE. // 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 #ifndef cyw43_malloc
#define cyw43_malloc malloc #define cyw43_malloc(nmemb) m_tracked_calloc(nmemb, 1)
#endif #endif
#ifndef cyw43_free #ifndef cyw43_free
#define cyw43_free free #define cyw43_free m_tracked_free
#endif #endif
void cyw43_post_poll_hook(void); void cyw43_post_poll_hook(void);

Loading…
Cancel
Save