Skip to content

Commit

Permalink
Firmware: Add cppmem module.
Browse files Browse the repository at this point in the history
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
  • Loading branch information
Gadgetoid committed Mar 28, 2023
1 parent 1f62955 commit 62deec7
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
4 changes: 4 additions & 0 deletions firmware/PIMORONI_BADGER2040/micropython.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ target_compile_definitions(usermod_wakeup INTERFACE
-DWAKEUP_PIN_VALUE=0b10000000000000010000000000
)

# Note: cppmem is *required* for C++ code to function on MicroPython
# it redirects `malloc` and `free` calls to MicroPython's heap
include(cppmem/micropython)

# LEDs & Matrices
include(plasma/micropython)

Expand Down
6 changes: 5 additions & 1 deletion firmware/PIMORONI_BADGER2040W/micropython.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ target_compile_definitions(usermod_wakeup INTERFACE
-DWAKEUP_PIN_VALUE=0b10000000000010000000000
)

# Note: cppmem is *required* for C++ code to function on MicroPython
# it redirects `malloc` and `free` calls to MicroPython's heap
include(cppmem/micropython)

# LEDs & Matrices
include(plasma/micropython)

Expand All @@ -49,5 +53,5 @@ include(servo/micropython)
include(encoder/micropython)
include(motor/micropython)

# version.py and pimoroni.py
# version.py, pimoroni.py and boot.py
include(modules_py/modules_py)

0 comments on commit 62deec7

Please sign in to comment.