esp32: Rework board variant support to require mpconfigvariant file.
This commit reworks board variants on the esp32 port. It's a simple change that moves the board variant configuration from an "if" statement within `mpconfigboard.cmake` into separate files for each variant, with the name of the variant encoded in the filename: `mpconfigvariant_VARIANT.cmake`. Optionally, the base variant can have its own options in `mpconfigvariant.cmake` (this is an optional file, but all other variants of the base must have a corresponding mpconfigvariant file). There are two benefits to this: - The build system now gives an error if the variant that you specified doesn't exist (because the mpconfigvariant file must exist with the variant name you specify). - No more error-prone if-logic needed in the .cmake files. The way to build a variant is unchanged, still via: $ make BOARD_VARIANT=VARIANT Signed-off-by: Damien George <damien@micropython.org>
This commit is contained in:
parent
3af1425be7
commit
43ebbec0c5
|
@ -19,6 +19,13 @@ if(NOT EXISTS ${MICROPY_BOARD_DIR}/mpconfigboard.cmake)
|
|||
message(FATAL_ERROR "Invalid MICROPY_BOARD specified: ${MICROPY_BOARD}")
|
||||
endif()
|
||||
|
||||
# If a board variant is specified, check that it exists.
|
||||
if(MICROPY_BOARD_VARIANT)
|
||||
if(NOT EXISTS ${MICROPY_BOARD_DIR}/mpconfigvariant_${MICROPY_BOARD_VARIANT}.cmake)
|
||||
message(FATAL_ERROR "Invalid MICROPY_BOARD_VARIANT specified: ${MICROPY_BOARD_VARIANT}")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# Define the output sdkconfig so it goes in the build directory.
|
||||
set(SDKCONFIG ${CMAKE_BINARY_DIR}/sdkconfig)
|
||||
|
||||
|
@ -35,6 +42,11 @@ endif()
|
|||
# - SDKCONFIG_DEFAULTS
|
||||
# - IDF_TARGET
|
||||
include(${MICROPY_BOARD_DIR}/mpconfigboard.cmake)
|
||||
if(NOT MICROPY_BOARD_VARIANT)
|
||||
include(${MICROPY_BOARD_DIR}/mpconfigvariant.cmake OPTIONAL)
|
||||
else()
|
||||
include(${MICROPY_BOARD_DIR}/mpconfigvariant_${MICROPY_BOARD_VARIANT}.cmake)
|
||||
endif()
|
||||
|
||||
# Set the frozen manifest file. Note if MICROPY_FROZEN_MANIFEST is set from the cmake
|
||||
# command line, then it will override the default and any manifest set by the board.
|
||||
|
|
|
@ -3,50 +3,3 @@ set(SDKCONFIG_DEFAULTS
|
|||
${SDKCONFIG_IDF_VERSION_SPECIFIC}
|
||||
boards/sdkconfig.ble
|
||||
)
|
||||
|
||||
if(MICROPY_BOARD_VARIANT STREQUAL "D2WD")
|
||||
set(SDKCONFIG_DEFAULTS
|
||||
${SDKCONFIG_DEFAULTS}
|
||||
boards/ESP32_GENERIC/sdkconfig.d2wd
|
||||
)
|
||||
|
||||
list(APPEND MICROPY_DEF_BOARD
|
||||
MICROPY_HW_MCU_NAME="ESP32-D2WD"
|
||||
# Disable some options to reduce firmware size.
|
||||
MICROPY_OPT_COMPUTED_GOTO=0
|
||||
MICROPY_PY_NETWORK_LAN=0
|
||||
)
|
||||
endif()
|
||||
|
||||
if(MICROPY_BOARD_VARIANT STREQUAL "OTA")
|
||||
set(SDKCONFIG_DEFAULTS
|
||||
${SDKCONFIG_DEFAULTS}
|
||||
boards/ESP32_GENERIC/sdkconfig.ota
|
||||
)
|
||||
|
||||
list(APPEND MICROPY_DEF_BOARD
|
||||
MICROPY_HW_BOARD_NAME="Generic ESP32 module with OTA"
|
||||
)
|
||||
endif()
|
||||
|
||||
if(MICROPY_BOARD_VARIANT STREQUAL "SPIRAM")
|
||||
set(SDKCONFIG_DEFAULTS
|
||||
${SDKCONFIG_DEFAULTS}
|
||||
boards/sdkconfig.spiram
|
||||
)
|
||||
|
||||
list(APPEND MICROPY_DEF_BOARD
|
||||
MICROPY_HW_BOARD_NAME="Generic ESP32 module with SPIRAM"
|
||||
)
|
||||
endif()
|
||||
|
||||
if(MICROPY_BOARD_VARIANT STREQUAL "UNICORE")
|
||||
set(SDKCONFIG_DEFAULTS
|
||||
${SDKCONFIG_DEFAULTS}
|
||||
boards/ESP32_GENERIC/sdkconfig.unicore
|
||||
)
|
||||
|
||||
list(APPEND MICROPY_DEF_BOARD
|
||||
MICROPY_HW_MCU_NAME="ESP32-UNICORE"
|
||||
)
|
||||
endif()
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
set(SDKCONFIG_DEFAULTS
|
||||
${SDKCONFIG_DEFAULTS}
|
||||
boards/ESP32_GENERIC/sdkconfig.d2wd
|
||||
)
|
||||
|
||||
list(APPEND MICROPY_DEF_BOARD
|
||||
MICROPY_HW_MCU_NAME="ESP32-D2WD"
|
||||
# Disable some options to reduce firmware size.
|
||||
MICROPY_OPT_COMPUTED_GOTO=0
|
||||
MICROPY_PY_NETWORK_LAN=0
|
||||
)
|
|
@ -0,0 +1,8 @@
|
|||
set(SDKCONFIG_DEFAULTS
|
||||
${SDKCONFIG_DEFAULTS}
|
||||
boards/ESP32_GENERIC/sdkconfig.ota
|
||||
)
|
||||
|
||||
list(APPEND MICROPY_DEF_BOARD
|
||||
MICROPY_HW_BOARD_NAME="Generic ESP32 module with OTA"
|
||||
)
|
|
@ -0,0 +1,8 @@
|
|||
set(SDKCONFIG_DEFAULTS
|
||||
${SDKCONFIG_DEFAULTS}
|
||||
boards/sdkconfig.spiram
|
||||
)
|
||||
|
||||
list(APPEND MICROPY_DEF_BOARD
|
||||
MICROPY_HW_BOARD_NAME="Generic ESP32 module with SPIRAM"
|
||||
)
|
|
@ -0,0 +1,8 @@
|
|||
set(SDKCONFIG_DEFAULTS
|
||||
${SDKCONFIG_DEFAULTS}
|
||||
boards/ESP32_GENERIC/sdkconfig.unicore
|
||||
)
|
||||
|
||||
list(APPEND MICROPY_DEF_BOARD
|
||||
MICROPY_HW_MCU_NAME="ESP32-UNICORE"
|
||||
)
|
|
@ -8,22 +8,3 @@ set(SDKCONFIG_DEFAULTS
|
|||
boards/sdkconfig.spiram_sx
|
||||
boards/ESP32_GENERIC_S3/sdkconfig.board
|
||||
)
|
||||
|
||||
if(MICROPY_BOARD_VARIANT STREQUAL "SPIRAM_OCT")
|
||||
set(SDKCONFIG_DEFAULTS
|
||||
${SDKCONFIG_DEFAULTS}
|
||||
boards/sdkconfig.240mhz
|
||||
boards/sdkconfig.spiram_oct
|
||||
)
|
||||
|
||||
list(APPEND MICROPY_DEF_BOARD
|
||||
MICROPY_HW_BOARD_NAME="Generic ESP32S3 module with Octal-SPIRAM"
|
||||
)
|
||||
endif()
|
||||
|
||||
if(MICROPY_BOARD_VARIANT STREQUAL "FLASH_4M")
|
||||
set(SDKCONFIG_DEFAULTS
|
||||
${SDKCONFIG_DEFAULTS}
|
||||
boards/ESP32_GENERIC_S3/sdkconfig.flash_4m
|
||||
)
|
||||
endif()
|
||||
|
|
|
@ -0,0 +1,4 @@
|
|||
set(SDKCONFIG_DEFAULTS
|
||||
${SDKCONFIG_DEFAULTS}
|
||||
boards/ESP32_GENERIC_S3/sdkconfig.flash_4m
|
||||
)
|
|
@ -0,0 +1,9 @@
|
|||
set(SDKCONFIG_DEFAULTS
|
||||
${SDKCONFIG_DEFAULTS}
|
||||
boards/sdkconfig.240mhz
|
||||
boards/sdkconfig.spiram_oct
|
||||
)
|
||||
|
||||
list(APPEND MICROPY_DEF_BOARD
|
||||
MICROPY_HW_BOARD_NAME="Generic ESP32S3 module with Octal-SPIRAM"
|
||||
)
|
Loading…
Reference in New Issue