From be6526c4532b04565dc579c6fa9c2ee62e85cb32 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sun, 8 Feb 2026 11:19:51 +0000 Subject: [PATCH 1/5] Initial plan From 1f4bf4c8eb941071449403c388e4c0e5de3dc4df Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sun, 8 Feb 2026 11:22:14 +0000 Subject: [PATCH 2/5] Set default config directory and add config file download Co-authored-by: JohnAmadis <17320783+JohnAmadis@users.noreply.github.com> --- CMakeLists.txt | 2 +- README.md | 2 +- modules/CMakeLists.txt | 22 ++++++++++++++++++++++ scripts/romfs.cmake | 2 +- 4 files changed, 25 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ba6740a..653ccf5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -9,7 +9,7 @@ cmake_minimum_required(VERSION 3.10) set(TARGET "STM32F746xG" CACHE STRING "Target microcontroller") set(STARTUP_DMP_FILE "" CACHE FILEPATH "Optional startup.dmp file to embed in ROM") set(USER_DATA_FILE "" CACHE FILEPATH "Optional user_data file to embed in ROM") -set(DMBOOT_CONFIG_DIR "" CACHE PATH "Optional config directory to mount as /configs/ using dmffs") +set(DMBOOT_CONFIG_DIR "${CMAKE_BINARY_DIR}/configs" CACHE PATH "Config directory to mount as /configs/ using dmffs (defaults to build/configs)") option(DMBOOT_EMULATION "Enable Renode emulation mode" OFF) # ====================================================================== diff --git a/README.md b/README.md index 7eb5ed6..9d9f1b4 100644 --- a/README.md +++ b/README.md @@ -45,7 +45,7 @@ cmake --build build **Build Parameters:** - `STARTUP_DMP_FILE` (optional) - Path to a startup package file (`.dmp`) that will be automatically loaded using `Dmod_AddPackageBuffer` at boot - `USER_DATA_FILE` (optional) - Path to a user data file that will be embedded in ROM, with its address and size available via environment variables `USER_DATA_ADDR` and `USER_DATA_SIZE` -- `DMBOOT_CONFIG_DIR` (optional) - Path to a directory that will be converted to a dmffs filesystem image and mounted at `/configs/` at boot time +- `DMBOOT_CONFIG_DIR` (optional, defaults to `build/configs`) - Path to a directory that will be converted to a dmffs filesystem image and mounted at `/configs/` at boot time. By default, configuration files from `modules.dmd` are downloaded to this directory. - `DMBOOT_EMULATION` (optional) - Enable Renode simulation mode instead of hardware mode **Automatic Build-Time Embedding:** diff --git a/modules/CMakeLists.txt b/modules/CMakeLists.txt index 214b5ae..1c97c1e 100644 --- a/modules/CMakeLists.txt +++ b/modules/CMakeLists.txt @@ -26,6 +26,28 @@ if(EXISTS "${DMBOOT_MODULES_DMD}") else() message(WARNING "Modules DMD file not found at ${DMBOOT_MODULES_DMD}. Skipping module download.") endif() + +# ====================================================================== +# Downloading configuration files from DMD +# ====================================================================== +set(DMBOOT_CONFIGS_MARKER_FILE "${DMBOOT_CONFIG_DIR}/.download_complete") +if(EXISTS "${DMBOOT_MODULES_DMD}") + add_custom_command( + OUTPUT "${DMBOOT_CONFIGS_MARKER_FILE}" + COMMAND ${CMAKE_COMMAND} -E make_directory "${DMBOOT_CONFIG_DIR}" + COMMAND ${CMAKE_COMMAND} -E echo "Downloading configuration files to ${DMBOOT_CONFIG_DIR}..." + COMMAND ${DMF_GET} -d "${DMBOOT_MODULES_DMD}" -o "${DMBOOT_CONFIG_DIR}" -t "${DMOD_TOOLS_NAME}" --cpu-family "${DMBOOT_MCU_SERIES}" -y --type config || ${CMAKE_COMMAND} -E echo "No config files found in DMD (this is normal)" + COMMAND ${CMAKE_COMMAND} -E touch "${DMBOOT_CONFIGS_MARKER_FILE}" + DEPENDS "${DMBOOT_MODULES_DMD}" + COMMENT "Downloading configuration files specified in ${DMBOOT_MODULES_DMD} from DMD..." + VERBATIM + ) + add_custom_target(download_configs ALL + DEPENDS "${DMBOOT_CONFIGS_MARKER_FILE}" + ) +else() + message(WARNING "Modules DMD file not found at ${DMBOOT_MODULES_DMD}. Skipping config download.") +endif() # ====================================================================== # Preparing dmp file from modules diff --git a/scripts/romfs.cmake b/scripts/romfs.cmake index 9011b85..38a34f1 100644 --- a/scripts/romfs.cmake +++ b/scripts/romfs.cmake @@ -42,7 +42,7 @@ if(DMBOOT_CONFIG_DIR AND EXISTS "${DMBOOT_CONFIG_DIR}") add_custom_command( OUTPUT "${CONFIG_FS_IMAGE}" COMMAND ${MAKE_DMFFS_COMMAND} -d "${DMBOOT_CONFIG_DIR}" -o "${CONFIG_FS_IMAGE}" - DEPENDS "${DMBOOT_CONFIG_DIR}" + DEPENDS "${DMBOOT_CONFIG_DIR}" download_configs COMMENT "Creating config filesystem image from ${DMBOOT_CONFIG_DIR}" VERBATIM ) From 562aabe4b3ba209a8ab31a6feb9857e7adb798a5 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sun, 8 Feb 2026 11:25:26 +0000 Subject: [PATCH 3/5] Fix config directory creation and dmf-get parameters Co-authored-by: JohnAmadis <17320783+JohnAmadis@users.noreply.github.com> --- CMakeLists.txt | 5 ----- modules/CMakeLists.txt | 4 ++-- scripts/romfs.cmake | 31 ++++++++++++++++++++----------- 3 files changed, 22 insertions(+), 18 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 653ccf5..49abc0d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -79,11 +79,6 @@ endif() include(scripts/romfs.cmake) if(CONFIG_FS_OBJECT) list(APPEND EMBEDDED_OBJECTS "${CONFIG_FS_OBJECT}") - # Add dependency on the filesystem generation - add_custom_command( - OUTPUT "${CONFIG_FS_OBJECT}" - DEPENDS generate_config_fs - ) endif() # Embed modules.dmp if it exists after build diff --git a/modules/CMakeLists.txt b/modules/CMakeLists.txt index 1c97c1e..fb7f6a2 100644 --- a/modules/CMakeLists.txt +++ b/modules/CMakeLists.txt @@ -14,7 +14,7 @@ if(EXISTS "${DMBOOT_MODULES_DMD}") OUTPUT "${DMBOOT_MODULES_MARKER_FILE}" COMMAND ${CMAKE_COMMAND} -E make_directory "${DMBOOT_MODULES_OUT_DIR}" COMMAND ${CMAKE_COMMAND} -E echo "Downloading modules to ${DMBOOT_MODULES_OUT_DIR}..." - COMMAND ${DMF_GET} -d "${DMBOOT_MODULES_DMD}" -o "${DMBOOT_MODULES_OUT_DIR}" -t "${DMOD_TOOLS_NAME}" --cpu-family "${DMBOOT_MCU_SERIES}" -y --type dmf + COMMAND ${DMF_GET} -d "${DMBOOT_MODULES_DMD}" -o "${DMBOOT_MODULES_OUT_DIR}" -t "${DMOD_TOOLS_NAME}" --cpu-family "${DMBOOT_MCU_SERIES}" -y --type dmf || ${CMAKE_COMMAND} -E echo "Warning: Some modules failed to download" COMMAND ${CMAKE_COMMAND} -E touch "${DMBOOT_MODULES_MARKER_FILE}" DEPENDS "${DMBOOT_MODULES_DMD}" COMMENT "Downloading modules specified in ${DMBOOT_MODULES_DMD} from DMD..." @@ -36,7 +36,7 @@ if(EXISTS "${DMBOOT_MODULES_DMD}") OUTPUT "${DMBOOT_CONFIGS_MARKER_FILE}" COMMAND ${CMAKE_COMMAND} -E make_directory "${DMBOOT_CONFIG_DIR}" COMMAND ${CMAKE_COMMAND} -E echo "Downloading configuration files to ${DMBOOT_CONFIG_DIR}..." - COMMAND ${DMF_GET} -d "${DMBOOT_MODULES_DMD}" -o "${DMBOOT_CONFIG_DIR}" -t "${DMOD_TOOLS_NAME}" --cpu-family "${DMBOOT_MCU_SERIES}" -y --type config || ${CMAKE_COMMAND} -E echo "No config files found in DMD (this is normal)" + COMMAND ${DMF_GET} -d "${DMBOOT_MODULES_DMD}" -o "${DMBOOT_CONFIG_DIR}" -t "${DMOD_TOOLS_NAME}" --cpu-family "${DMBOOT_MCU_SERIES}" -y --type dmfc || ${CMAKE_COMMAND} -E echo "No config files found in DMD (this is normal)" COMMAND ${CMAKE_COMMAND} -E touch "${DMBOOT_CONFIGS_MARKER_FILE}" DEPENDS "${DMBOOT_MODULES_DMD}" COMMENT "Downloading configuration files specified in ${DMBOOT_MODULES_DMD} from DMD..." diff --git a/scripts/romfs.cmake b/scripts/romfs.cmake index 38a34f1..2c045e7 100644 --- a/scripts/romfs.cmake +++ b/scripts/romfs.cmake @@ -1,8 +1,10 @@ # This script sets up a ROM filesystem using dmffs and integrates it into the build # It checks for the required tools, creates the ROMFS image, and embeds it into the firmware -# Check if DMBOOT_CONFIG_DIR is set and exists -if(DMBOOT_CONFIG_DIR AND EXISTS "${DMBOOT_CONFIG_DIR}") +# Check if DMBOOT_CONFIG_DIR is set +if(DMBOOT_CONFIG_DIR) + # Create the directory if it doesn't exist + file(MAKE_DIRECTORY "${DMBOOT_CONFIG_DIR}") message(STATUS "Config directory specified: ${DMBOOT_CONFIG_DIR}") # Set output path for the config filesystem image @@ -41,7 +43,7 @@ if(DMBOOT_CONFIG_DIR AND EXISTS "${DMBOOT_CONFIG_DIR}") # Create custom command to generate the config filesystem image add_custom_command( OUTPUT "${CONFIG_FS_IMAGE}" - COMMAND ${MAKE_DMFFS_COMMAND} -d "${DMBOOT_CONFIG_DIR}" -o "${CONFIG_FS_IMAGE}" + COMMAND ${MAKE_DMFFS_COMMAND} "${DMBOOT_CONFIG_DIR}" "${CONFIG_FS_IMAGE}" DEPENDS "${DMBOOT_CONFIG_DIR}" download_configs COMMENT "Creating config filesystem image from ${DMBOOT_CONFIG_DIR}" VERBATIM @@ -52,14 +54,21 @@ if(DMBOOT_CONFIG_DIR AND EXISTS "${DMBOOT_CONFIG_DIR}") DEPENDS "${CONFIG_FS_IMAGE}" ) - # Embed the config filesystem image - embed_binary_file( - INPUT_FILE "${CONFIG_FS_IMAGE}" - SECTION_NAME ".embedded.config_fs" - SYMBOL_PREFIX "__config_fs" - ) - + # Create custom command to embed the config filesystem image (similar to modules.dmp approach) set(CONFIG_FS_OBJECT "${CMAKE_BINARY_DIR}/__config_fs.o") + add_custom_command( + OUTPUT "${CONFIG_FS_OBJECT}" + COMMAND ${CMAKE_OBJCOPY} + --input-target=binary + --output-target=elf32-littlearm + --binary-architecture=arm + --rename-section .data=.embedded.config_fs,alloc,load,readonly,data,contents + "${CONFIG_FS_IMAGE}" + "${CONFIG_FS_OBJECT}" + DEPENDS "${CONFIG_FS_IMAGE}" generate_config_fs + COMMENT "Embedding config filesystem into section .embedded.config_fs" + VERBATIM + ) # Export variables to parent scope set(CONFIG_FS_OBJECT "${CONFIG_FS_OBJECT}" PARENT_SCOPE) @@ -67,5 +76,5 @@ if(DMBOOT_CONFIG_DIR AND EXISTS "${DMBOOT_CONFIG_DIR}") message(STATUS "Config filesystem will be embedded from: ${DMBOOT_CONFIG_DIR}") else() - message(STATUS "No config directory specified (DMBOOT_CONFIG_DIR not set or doesn't exist)") + message(STATUS "No config directory specified (DMBOOT_CONFIG_DIR not set)") endif() \ No newline at end of file From 6a53e3285ef89c2cadf0ce6f70d4b8c215a275b4 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sun, 8 Feb 2026 11:26:51 +0000 Subject: [PATCH 4/5] Address code review feedback Co-authored-by: JohnAmadis <17320783+JohnAmadis@users.noreply.github.com> --- modules/CMakeLists.txt | 2 +- scripts/romfs.cmake | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/CMakeLists.txt b/modules/CMakeLists.txt index fb7f6a2..49ae5aa 100644 --- a/modules/CMakeLists.txt +++ b/modules/CMakeLists.txt @@ -36,7 +36,7 @@ if(EXISTS "${DMBOOT_MODULES_DMD}") OUTPUT "${DMBOOT_CONFIGS_MARKER_FILE}" COMMAND ${CMAKE_COMMAND} -E make_directory "${DMBOOT_CONFIG_DIR}" COMMAND ${CMAKE_COMMAND} -E echo "Downloading configuration files to ${DMBOOT_CONFIG_DIR}..." - COMMAND ${DMF_GET} -d "${DMBOOT_MODULES_DMD}" -o "${DMBOOT_CONFIG_DIR}" -t "${DMOD_TOOLS_NAME}" --cpu-family "${DMBOOT_MCU_SERIES}" -y --type dmfc || ${CMAKE_COMMAND} -E echo "No config files found in DMD (this is normal)" + COMMAND ${DMF_GET} -d "${DMBOOT_MODULES_DMD}" -o "${DMBOOT_CONFIG_DIR}" -t "${DMOD_TOOLS_NAME}" --cpu-family "${DMBOOT_MCU_SERIES}" -y --type dmfc || ${CMAKE_COMMAND} -E echo "Warning: Config file download failed or no config files available" COMMAND ${CMAKE_COMMAND} -E touch "${DMBOOT_CONFIGS_MARKER_FILE}" DEPENDS "${DMBOOT_MODULES_DMD}" COMMENT "Downloading configuration files specified in ${DMBOOT_MODULES_DMD} from DMD..." diff --git a/scripts/romfs.cmake b/scripts/romfs.cmake index 2c045e7..4b2d09a 100644 --- a/scripts/romfs.cmake +++ b/scripts/romfs.cmake @@ -65,7 +65,7 @@ if(DMBOOT_CONFIG_DIR) --rename-section .data=.embedded.config_fs,alloc,load,readonly,data,contents "${CONFIG_FS_IMAGE}" "${CONFIG_FS_OBJECT}" - DEPENDS "${CONFIG_FS_IMAGE}" generate_config_fs + DEPENDS "${CONFIG_FS_IMAGE}" COMMENT "Embedding config filesystem into section .embedded.config_fs" VERBATIM ) From cfb769cabb736cef7da6590b7968737a5a82aa75 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sun, 8 Feb 2026 11:40:45 +0000 Subject: [PATCH 5/5] Make module and config downloads fatal as requested Co-authored-by: JohnAmadis <17320783+JohnAmadis@users.noreply.github.com> --- modules/CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/CMakeLists.txt b/modules/CMakeLists.txt index 49ae5aa..30ef569 100644 --- a/modules/CMakeLists.txt +++ b/modules/CMakeLists.txt @@ -14,7 +14,7 @@ if(EXISTS "${DMBOOT_MODULES_DMD}") OUTPUT "${DMBOOT_MODULES_MARKER_FILE}" COMMAND ${CMAKE_COMMAND} -E make_directory "${DMBOOT_MODULES_OUT_DIR}" COMMAND ${CMAKE_COMMAND} -E echo "Downloading modules to ${DMBOOT_MODULES_OUT_DIR}..." - COMMAND ${DMF_GET} -d "${DMBOOT_MODULES_DMD}" -o "${DMBOOT_MODULES_OUT_DIR}" -t "${DMOD_TOOLS_NAME}" --cpu-family "${DMBOOT_MCU_SERIES}" -y --type dmf || ${CMAKE_COMMAND} -E echo "Warning: Some modules failed to download" + COMMAND ${DMF_GET} -d "${DMBOOT_MODULES_DMD}" -o "${DMBOOT_MODULES_OUT_DIR}" -t "${DMOD_TOOLS_NAME}" --cpu-family "${DMBOOT_MCU_SERIES}" -y --type dmf COMMAND ${CMAKE_COMMAND} -E touch "${DMBOOT_MODULES_MARKER_FILE}" DEPENDS "${DMBOOT_MODULES_DMD}" COMMENT "Downloading modules specified in ${DMBOOT_MODULES_DMD} from DMD..." @@ -36,7 +36,7 @@ if(EXISTS "${DMBOOT_MODULES_DMD}") OUTPUT "${DMBOOT_CONFIGS_MARKER_FILE}" COMMAND ${CMAKE_COMMAND} -E make_directory "${DMBOOT_CONFIG_DIR}" COMMAND ${CMAKE_COMMAND} -E echo "Downloading configuration files to ${DMBOOT_CONFIG_DIR}..." - COMMAND ${DMF_GET} -d "${DMBOOT_MODULES_DMD}" -o "${DMBOOT_CONFIG_DIR}" -t "${DMOD_TOOLS_NAME}" --cpu-family "${DMBOOT_MCU_SERIES}" -y --type dmfc || ${CMAKE_COMMAND} -E echo "Warning: Config file download failed or no config files available" + COMMAND ${DMF_GET} -d "${DMBOOT_MODULES_DMD}" -o "${DMBOOT_CONFIG_DIR}" -t "${DMOD_TOOLS_NAME}" --cpu-family "${DMBOOT_MCU_SERIES}" -y --type dmfc COMMAND ${CMAKE_COMMAND} -E touch "${DMBOOT_CONFIGS_MARKER_FILE}" DEPENDS "${DMBOOT_MODULES_DMD}" COMMENT "Downloading configuration files specified in ${DMBOOT_MODULES_DMD} from DMD..."