Skip to content

Commit 265b0b5

Browse files
CopilotJohnAmadis
andcommitted
Add support for multiple configs and boards (BOARD parameter, per-MCU linker dirs, common/MCU/board dmd files)
Co-authored-by: JohnAmadis <17320783+JohnAmadis@users.noreply.github.com>
1 parent ba8b7f2 commit 265b0b5

16 files changed

Lines changed: 166 additions & 15 deletions

File tree

CMakeLists.txt

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ cmake_minimum_required(VERSION 3.10)
77
# Configuration
88
# ======================================================================
99
set(TARGET "STM32F746xG" CACHE STRING "Target microcontroller")
10+
set(BOARD "" CACHE STRING "Board name (optional). If set, TARGET is derived from configs/board/<BOARD>/board.cmake")
1011
set(STARTUP_DMP_FILE "" CACHE FILEPATH "Optional startup.dmp file to embed in ROM")
1112
set(USER_DATA_FILE "" CACHE FILEPATH "Optional user_data file to embed in ROM")
1213
set(DMBOOT_CONFIG_DIR "${CMAKE_BINARY_DIR}/configs" CACHE PATH "Config directory to mount as /configs/ using dmffs (defaults to build/configs)")
@@ -18,6 +19,12 @@ option(DMBOOT_EMULATION "Enable Renode emulation mode" OFF)
1819
set(DMOD_DIR "${CMAKE_CURRENT_SOURCE_DIR}/lib/dmod")
1920
include(configs/dmod-cfg.cmake)
2021
include(configs/dmvfs-cfg.cmake)
22+
23+
# If BOARD is specified, read TARGET from board.cmake
24+
if(BOARD)
25+
include(configs/board/${BOARD}/board.cmake)
26+
endif()
27+
2128
include(configs/mcu/${TARGET}.cmake)
2229

2330
# Include toolchain configuration before project() to set compilers
@@ -139,7 +146,7 @@ target_link_options(${MODULE_NAME}.elf
139146
PRIVATE
140147
-L${DMOD_DIR}/scripts
141148
-T${CMAKE_CURRENT_SOURCE_DIR}/configs/arch/${DMBOOT_ARCH}/arch.ld
142-
-T${CMAKE_CURRENT_SOURCE_DIR}/configs/mcu/${DMBOOT_MCU_SERIES}/${DMBOOT_MCU_NAME}.ld
149+
-T${CMAKE_CURRENT_SOURCE_DIR}/configs/mcu/${DMBOOT_MCU_SERIES}/${DMBOOT_MCU_NAME}/mcu.ld
143150
-T${CMAKE_CURRENT_SOURCE_DIR}/linker/common.ld
144151
-Wl,-Map=${MODULE_NAME}.map
145152
)
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Board configuration for STM32F746G Discovery
2+
# Sets TARGET for the build system
3+
set(TARGET "STM32F746xG" CACHE STRING "Target microcontroller" FORCE)
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#
2+
# STM32F746G Discovery board flash modules - board-specific modules with configs
3+
#
4+
dmclk board/stm32f746g-disco.ini
5+
dmgpio board/stm32f746g-disco.ini
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#
2+
# STM32F746G Discovery board sdcard modules - board-specific modules for sdcard
3+
#

configs/common/flash.dmd

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#
2+
# Common flash modules - loaded for all targets
3+
#
4+
dmell
5+
dmffs
6+
dmramfs
7+
dmdevfs
8+
ls
9+
mkdir

configs/common/sdcard.dmd

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#
2+
# Common sdcard modules - loaded for all targets
3+
#
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#
2+
# STM32F407G flash modules - MCU-specific modules for flash
3+
#
4+
dmclk
5+
dmgpio
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#
2+
# STM32F407G sdcard modules - MCU-specific modules for sdcard
3+
#
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#
2+
# STM32F746xG flash modules - MCU-specific modules for flash
3+
#
4+
dmclk
5+
dmgpio

0 commit comments

Comments
 (0)