Skip to content

Commit c9a18fd

Browse files
edersondisouzakartben
authored andcommitted
mcuboot: Kconfig options for single app slot RAM loading mode
MCUboot has a configuration for single application slot RAM loading, in which the single loader (or a hook thereof) can load an application from an arbitrary flash location to RAM. Applications that are to be loaded in this way need to specify, in their mcuboot header, the load address in RAM they are meant to be loaded. This patch adds a new Kconfig for this mode. The load address used comes from devicetree chosen property "mcuboot,ram-load-dev", if it exists, and if not, "zephyr,sram". Signed-off-by: Ederson de Souza <[email protected]>
1 parent f358f9f commit c9a18fd

File tree

3 files changed

+31
-1
lines changed

3 files changed

+31
-1
lines changed

cmake/mcuboot.cmake

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,8 @@ function(zephyr_mcuboot_tasks)
9595

9696
# If single slot mode, or if in firmware updater mode and this is the firmware updater image,
9797
# use slot 0 information
98-
if(NOT CONFIG_MCUBOOT_BOOTLOADER_MODE_SINGLE_APP AND (NOT CONFIG_MCUBOOT_BOOTLOADER_MODE_FIRMWARE_UPDATER OR CONFIG_MCUBOOT_APPLICATION_FIRMWARE_UPDATER))
98+
if(NOT CONFIG_MCUBOOT_BOOTLOADER_MODE_SINGLE_APP AND (NOT CONFIG_MCUBOOT_BOOTLOADER_MODE_FIRMWARE_UPDATER OR CONFIG_MCUBOOT_APPLICATION_FIRMWARE_UPDATER)
99+
AND NOT CONFIG_MCUBOOT_BOOTLOADER_MODE_SINGLE_APP_RAM_LOAD)
99100
# Slot 1 size is used instead of slot 0 size
100101
set(slot_size)
101102
dt_nodelabel(slot1_flash NODELABEL "slot1_partition" REQUIRED)
@@ -138,6 +139,15 @@ function(zephyr_mcuboot_tasks)
138139
set(imgtool_args --align 1 --load-addr ${chosen_ram_address} ${imgtool_args})
139140
set(imgtool_args_alt_slot ${imgtool_args} --hex-addr ${slot1_partition_address})
140141
set(imgtool_args ${imgtool_args} --hex-addr ${slot0_partition_address})
142+
elseif(CONFIG_MCUBOOT_BOOTLOADER_MODE_SINGLE_APP_RAM_LOAD)
143+
dt_chosen(ram_load_dev PROPERTY "mcuboot,ram-load-dev")
144+
if(DEFINED ram_load_dev)
145+
dt_reg_addr(load_address PATH ${ram_load_dev})
146+
else()
147+
dt_chosen(chosen_ram PROPERTY "zephyr,sram")
148+
dt_reg_addr(load_address PATH ${chosen_ram})
149+
endif()
150+
set(imgtool_args --align 1 --load-addr ${load_address} ${imgtool_args})
141151
else()
142152
set(imgtool_args --align ${write_block_size} ${imgtool_args})
143153
endif()

doc/build/dts/api/api.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -462,3 +462,8 @@ device.
462462
WS2812 GPIO driver
463463
* - zephyr,touch
464464
- touchscreen controller device node.
465+
* - mcuboot,ram-load-dev
466+
- When a Zephyr application is built to be loaded to RAM by MCUboot, with
467+
:kconfig:option:`CONFIG_MCUBOOT_BOOTLOADER_MODE_SINGLE_APP_RAM_LOAD`,
468+
this property is used to tell MCUboot the load address of the image, which
469+
will be the ``reg`` of the chosen node.

modules/Kconfig.mcuboot

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,21 @@ config MCUBOOT_BOOTLOADER_MODE_FIRMWARE_UPDATER
254254
a dedicated firmware updater application used to update the slot0_partition
255255
application.
256256

257+
config MCUBOOT_BOOTLOADER_MODE_SINGLE_APP_RAM_LOAD
258+
bool "MCUboot has been configured in single app RAM load mode"
259+
select MCUBOOT_BOOTLOADER_MODE_HAS_NO_DOWNGRADE
260+
select MCUBOOT_BOOTLOADER_NO_DOWNGRADE
261+
help
262+
MCUboot can load the image to RAM from an arbitrary location. In this mode,
263+
MCUboot will copy the image to RAM and begin execution from there. The image
264+
must be linked to execute from RAM, the address that it is copied to is
265+
specified using the load-addr argument when running imgtool.
266+
Note that while not used directly, a slot0_partition must be defined in the
267+
DT, as it is used to get information about size of the image to be loaded.
268+
This option automatically selects MCUBOOT_BOOTLOADER_NO_DOWNGRADE as it is
269+
not possible to swap back to older version of the application. In fact, none
270+
of the swap operations are supported in this mode.
271+
257272
endchoice # MCUBOOT_BOOTLOADER_MODE
258273

259274
config MCUBOOT_BOOTLOADER_MODE_HAS_NO_DOWNGRADE

0 commit comments

Comments
 (0)