Browse Source

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.
pull/7110/head
jahr 4 years ago
committed by Damien George
parent
commit
7ca686684e
  1. 25
      ports/rp2/CMakeLists.txt
  2. 6
      ports/rp2/Makefile
  3. 1
      ports/rp2/boards/ADAFRUIT_FEATHER_RP2040/mpconfigboard.cmake
  4. 3
      ports/rp2/boards/ADAFRUIT_FEATHER_RP2040/mpconfigboard.h
  5. 1
      ports/rp2/boards/PICO/mpconfigboard.cmake
  6. 3
      ports/rp2/boards/PICO/mpconfigboard.h
  7. 3
      ports/rp2/mpconfigport.h

25
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}"
)

6
ports/rp2/Makefile

@ -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}

1
ports/rp2/boards/ADAFRUIT_FEATHER_RP2040/mpconfigboard.cmake

@ -0,0 +1 @@
# cmake file for Adafruit Feather RP2040

3
ports/rp2/boards/ADAFRUIT_FEATHER_RP2040/mpconfigboard.h

@ -0,0 +1,3 @@
// Board and hardware specific configuration
#define MICROPY_HW_BOARD_NAME "Adafruit Feather RP2040"
#define MICROPY_HW_FLASH_STORAGE_BYTES (3072 * 1024)

1
ports/rp2/boards/PICO/mpconfigboard.cmake

@ -0,0 +1 @@
# cmake file for Raspberry Pi Pico

3
ports/rp2/boards/PICO/mpconfigboard.h

@ -0,0 +1,3 @@
// Board and hardware specific configuration
#define MICROPY_HW_BOARD_NAME "Raspberry Pi Pico"
#define MICROPY_HW_FLASH_STORAGE_BYTES (1408 * 1024)

3
ports/rp2/mpconfigport.h

@ -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)

Loading…
Cancel
Save