Commit 7ca68668 authored by jahr's avatar jahr Committed by Damien George

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.
parent 1be74b94
......@@ -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}"
)
......
......@@ -2,11 +2,13 @@
#
# This is a simple wrapper around cmake
BUILD = build
BOARD ?= PICO
BUILD ?= build-$(BOARD)
$(VERBOSE)MAKESILENT = -s
CMAKE_ARGS =
CMAKE_ARGS = -DMICROPY_BOARD=$(BOARD)
ifdef USER_C_MODULES
CMAKE_ARGS += -DUSER_C_MODULES=${USER_C_MODULES}
......
// Board and hardware specific configuration
#define MICROPY_HW_BOARD_NAME "Adafruit Feather RP2040"
#define MICROPY_HW_FLASH_STORAGE_BYTES (3072 * 1024)
# cmake file for Raspberry Pi Pico
// Board and hardware specific configuration
#define MICROPY_HW_BOARD_NAME "Raspberry Pi Pico"
#define MICROPY_HW_FLASH_STORAGE_BYTES (1408 * 1024)
......@@ -31,8 +31,9 @@
#include "hardware/sync.h"
#include "pico/binary_info.h"
#include "mpconfigboard.h"
// Board and hardware specific configuration
#define MICROPY_HW_BOARD_NAME "Raspberry Pi Pico"
#define MICROPY_HW_MCU_NAME "RP2040"
#define MICROPY_HW_ENABLE_UART_REPL (0) // useful if there is no USB
#define MICROPY_HW_ENABLE_USBDEV (1)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment