aboutsummaryrefslogtreecommitdiff
path: root/ports/rp2/CMakeLists.txt
diff options
context:
space:
mode:
authorjahr2021-04-05 22:57:18 +0200
committerDamien George2021-04-12 21:40:32 +1000
commit7ca686684ea5bffb45764bc3782f54133855a3c9 (patch)
tree4412b7613eb1dfe3cc416fb867954fca927e68a2 /ports/rp2/CMakeLists.txt
parent1be74b94b6f3263b8e360a0a012ae87301539f91 (diff)
rp2: Add support for building different board configurations.
This change allows to build firmware for different rp2-based boards, following how it is done in other ports like stm32 and esp32. So far only the original Pico and Adafruit Feather RP2040 are added. Board names should match (sans case) those in pico-sdk/src/boards/include/boards/. Usage: Pico firmware can be build either using make as previously (it is the default board) or by `make BOARD=PICO`. Feather is built by `make BOARD=ADAFRUIT_FEATHER_RP2040`. Only the board name and flash drive size is set, pin definition is taken from the appropriate pico-sdk board definition. Firmware is saved in the directory build-BOARD_NAME.
Diffstat (limited to 'ports/rp2/CMakeLists.txt')
-rw-r--r--ports/rp2/CMakeLists.txt25
1 files changed, 25 insertions, 0 deletions
diff --git a/ports/rp2/CMakeLists.txt b/ports/rp2/CMakeLists.txt
index 100a83409..bd3eb7438 100644
--- a/ports/rp2/CMakeLists.txt
+++ b/ports/rp2/CMakeLists.txt
@@ -17,6 +17,30 @@ endif()
# Use the local tinyusb instead of the one in pico-sdk
set(PICO_TINYUSB_PATH ${MICROPY_DIR}/lib/tinyusb)
+# Set the location of this port's directory.
+set(MICROPY_PORT_DIR ${CMAKE_SOURCE_DIR})
+
+# Set the board if it's not already set.
+if(NOT MICROPY_BOARD)
+ set(MICROPY_BOARD PICO)
+endif()
+
+# Set the PICO_BOARD if it's not already set.
+if(NOT PICO_BOARD)
+ string(TOLOWER ${MICROPY_BOARD} PICO_BOARD)
+endif()
+
+# Set the board directory and check that it exists.
+if(NOT MICROPY_BOARD_DIR)
+ set(MICROPY_BOARD_DIR ${MICROPY_PORT_DIR}/boards/${MICROPY_BOARD})
+endif()
+if(NOT EXISTS ${MICROPY_BOARD_DIR}/mpconfigboard.cmake)
+ message(FATAL_ERROR "Invalid MICROPY_BOARD specified: ${MICROPY_BOARD}")
+endif()
+
+# Include board config
+include(${MICROPY_BOARD_DIR}/mpconfigboard.cmake)
+
# Include component cmake fragments
include(${MICROPY_DIR}/py/py.cmake)
include(${MICROPY_DIR}/extmod/extmod.cmake)
@@ -150,6 +174,7 @@ target_link_libraries(${MICROPY_TARGET} usermod)
target_include_directories(${MICROPY_TARGET} PRIVATE
${MICROPY_INC_CORE}
${MICROPY_INC_USERMOD}
+ ${MICROPY_BOARD_DIR}
"${PROJECT_SOURCE_DIR}"
"${CMAKE_BINARY_DIR}"
)