Skip to content

Commit 62deec7

Browse files
committed
Firmware: Add cppmem module.
This module redirects `malloc` and `free` calls to MicroPython's heap, allowing C++ code and MicroPython's "greedy heap" to coexist. See: micropython/micropython#11116
1 parent 1f62955 commit 62deec7

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

firmware/PIMORONI_BADGER2040/micropython.cmake

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,10 @@ target_compile_definitions(usermod_wakeup INTERFACE
3939
-DWAKEUP_PIN_VALUE=0b10000000000000010000000000
4040
)
4141

42+
# Note: cppmem is *required* for C++ code to function on MicroPython
43+
# it redirects `malloc` and `free` calls to MicroPython's heap
44+
include(cppmem/micropython)
45+
4246
# LEDs & Matrices
4347
include(plasma/micropython)
4448

firmware/PIMORONI_BADGER2040W/micropython.cmake

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,10 @@ target_compile_definitions(usermod_wakeup INTERFACE
4040
-DWAKEUP_PIN_VALUE=0b10000000000010000000000
4141
)
4242

43+
# Note: cppmem is *required* for C++ code to function on MicroPython
44+
# it redirects `malloc` and `free` calls to MicroPython's heap
45+
include(cppmem/micropython)
46+
4347
# LEDs & Matrices
4448
include(plasma/micropython)
4549

@@ -49,5 +53,5 @@ include(servo/micropython)
4953
include(encoder/micropython)
5054
include(motor/micropython)
5155

52-
# version.py and pimoroni.py
56+
# version.py, pimoroni.py and boot.py
5357
include(modules_py/modules_py)

0 commit comments

Comments
 (0)