diff --git a/cmake/mcuboot.cmake b/cmake/mcuboot.cmake index e9cd88e2f9a..d2fcf68e889 100644 --- a/cmake/mcuboot.cmake +++ b/cmake/mcuboot.cmake @@ -95,7 +95,8 @@ function(zephyr_mcuboot_tasks) # If single slot mode, or if in firmware updater mode and this is the firmware updater image, # use slot 0 information - if(NOT CONFIG_MCUBOOT_BOOTLOADER_MODE_SINGLE_APP AND (NOT CONFIG_MCUBOOT_BOOTLOADER_MODE_FIRMWARE_UPDATER OR CONFIG_MCUBOOT_APPLICATION_FIRMWARE_UPDATER)) + if(NOT CONFIG_MCUBOOT_BOOTLOADER_MODE_SINGLE_APP AND (NOT CONFIG_MCUBOOT_BOOTLOADER_MODE_FIRMWARE_UPDATER OR CONFIG_MCUBOOT_APPLICATION_FIRMWARE_UPDATER) + AND NOT CONFIG_MCUBOOT_BOOTLOADER_MODE_SINGLE_APP_RAM_LOAD) # Slot 1 size is used instead of slot 0 size set(slot_size) dt_nodelabel(slot1_flash NODELABEL "slot1_partition" REQUIRED) @@ -138,6 +139,15 @@ function(zephyr_mcuboot_tasks) set(imgtool_args --align 1 --load-addr ${chosen_ram_address} ${imgtool_args}) set(imgtool_args_alt_slot ${imgtool_args} --hex-addr ${slot1_partition_address}) set(imgtool_args ${imgtool_args} --hex-addr ${slot0_partition_address}) + elseif(CONFIG_MCUBOOT_BOOTLOADER_MODE_SINGLE_APP_RAM_LOAD) + dt_chosen(ram_load_dev PROPERTY "mcuboot,ram-load-dev") + if(DEFINED ram_load_dev) + dt_reg_addr(load_address PATH ${ram_load_dev}) + else() + dt_chosen(chosen_ram PROPERTY "zephyr,sram") + dt_reg_addr(load_address PATH ${chosen_ram}) + endif() + set(imgtool_args --align 1 --load-addr ${load_address} ${imgtool_args}) else() set(imgtool_args --align ${write_block_size} ${imgtool_args}) endif() diff --git a/doc/build/dts/api/api.rst b/doc/build/dts/api/api.rst index 5ad68f108ce..c8c3c0563a9 100644 --- a/doc/build/dts/api/api.rst +++ b/doc/build/dts/api/api.rst @@ -462,3 +462,8 @@ device. WS2812 GPIO driver * - zephyr,touch - touchscreen controller device node. + * - mcuboot,ram-load-dev + - When a Zephyr application is built to be loaded to RAM by MCUboot, with + :kconfig:option:`CONFIG_MCUBOOT_BOOTLOADER_MODE_SINGLE_APP_RAM_LOAD`, + this property is used to tell MCUboot the load address of the image, which + will be the ``reg`` of the chosen node. diff --git a/modules/Kconfig.mcuboot b/modules/Kconfig.mcuboot index 73a6346f89b..2c4dbfa930d 100644 --- a/modules/Kconfig.mcuboot +++ b/modules/Kconfig.mcuboot @@ -254,6 +254,21 @@ config MCUBOOT_BOOTLOADER_MODE_FIRMWARE_UPDATER a dedicated firmware updater application used to update the slot0_partition application. +config MCUBOOT_BOOTLOADER_MODE_SINGLE_APP_RAM_LOAD + bool "MCUboot has been configured in single app RAM load mode" + select MCUBOOT_BOOTLOADER_MODE_HAS_NO_DOWNGRADE + select MCUBOOT_BOOTLOADER_NO_DOWNGRADE + help + MCUboot can load the image to RAM from an arbitrary location. In this mode, + MCUboot will copy the image to RAM and begin execution from there. The image + must be linked to execute from RAM, the address that it is copied to is + specified using the load-addr argument when running imgtool. + Note that while not used directly, a slot0_partition must be defined in the + DT, as it is used to get information about size of the image to be loaded. + This option automatically selects MCUBOOT_BOOTLOADER_NO_DOWNGRADE as it is + not possible to swap back to older version of the application. In fact, none + of the swap operations are supported in this mode. + endchoice # MCUBOOT_BOOTLOADER_MODE config MCUBOOT_BOOTLOADER_MODE_HAS_NO_DOWNGRADE