Skip to content

Commit c6a9598

Browse files
boot/zephyr: Add CONFIG_SINGLE_APPLICATION_SLOT_RAM_LOAD
This option basically enables MCUBOOT_RAM_LOAD in a single slot configuration, meaning the image on slot0 will be loaded into RAM. Signed-off-by: Ederson de Souza <[email protected]>
1 parent f727d55 commit c6a9598

File tree

3 files changed

+33
-17
lines changed

3 files changed

+33
-17
lines changed

boot/zephyr/CMakeLists.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ zephyr_library_sources(
127127
)
128128
endif()
129129

130-
if(CONFIG_SINGLE_APPLICATION_SLOT)
130+
if(CONFIG_SINGLE_APPLICATION_SLOT OR CONFIG_SINGLE_APPLICATION_SLOT_RAM_LOAD)
131131
zephyr_library_sources(
132132
${BOOT_DIR}/zephyr/single_loader.c
133133
)
@@ -147,7 +147,7 @@ zephyr_library_sources(
147147
)
148148
endif()
149149

150-
if(CONFIG_BOOT_RAM_LOAD)
150+
if(CONFIG_BOOT_RAM_LOAD OR CONFIG_SINGLE_APPLICATION_SLOT_RAM_LOAD)
151151
zephyr_library_sources(
152152
${BOOT_DIR}/bootutil/src/ram_load.c
153153
)
@@ -400,7 +400,7 @@ if(CONFIG_BOOT_MAX_IMG_SECTORS_AUTO)
400400
math(EXPR slot_min_sectors "${slot0_size} / ${erase_size_slot0}")
401401
endif()
402402

403-
if(NOT CONFIG_SINGLE_APPLICATION_SLOT)
403+
if(NOT CONFIG_SINGLE_APPLICATION_SLOT AND NOT CONFIG_SINGLE_APPLICATION_SLOT_RAM_LOAD)
404404
dt_nodelabel(slot1_flash NODELABEL "slot1_partition")
405405
dt_prop(slot1_size PATH "${slot1_flash}" PROPERTY "reg" INDEX 1)
406406
dt_get_parent(slot1_flash)

boot/zephyr/Kconfig

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -271,19 +271,6 @@ config BOOT_FIRMWARE_LOADER
271271

272272
endchoice
273273

274-
# Workaround for not being able to have commas in macro arguments
275-
DT_CHOSEN_Z_SRAM := zephyr,sram
276-
277-
if BOOT_RAM_LOAD
278-
config BOOT_IMAGE_EXECUTABLE_RAM_START
279-
hex "Boot image executable ram start"
280-
default $(dt_chosen_reg_addr_hex,$(DT_CHOSEN_Z_SRAM))
281-
282-
config BOOT_IMAGE_EXECUTABLE_RAM_SIZE
283-
int "Boot image executable base size"
284-
default $(dt_chosen_reg_size_int,$(DT_CHOSEN_Z_SRAM),0)
285-
endif
286-
287274
config BOOT_DIRECT_XIP_REVERT
288275
bool "Enable the revert mechanism in direct-xip mode"
289276
depends on BOOT_DIRECT_XIP
@@ -320,6 +307,27 @@ config BOOT_SWAP_SAVE_ENCTLV
320307

321308
endif # !SINGLE_APPLICATION_SLOT
322309

310+
config SINGLE_APPLICATION_SLOT_RAM_LOAD
311+
bool "RAM load for single application slot"
312+
help
313+
If y, the image is loaded to RAM and executed from there. For this reason,
314+
the image has to be linked to be executed from RAM. The address that the
315+
image is copied to is specified using the load-addr argument to the
316+
imgtool.py script which writes it to the image header.
317+
318+
# Workaround for not being able to have commas in macro arguments
319+
DT_CHOSEN_Z_SRAM := zephyr,sram
320+
321+
if BOOT_RAM_LOAD || SINGLE_APPLICATION_SLOT_RAM_LOAD
322+
config BOOT_IMAGE_EXECUTABLE_RAM_START
323+
hex "Boot image executable ram start"
324+
default $(dt_chosen_reg_addr_hex,$(DT_CHOSEN_Z_SRAM))
325+
326+
config BOOT_IMAGE_EXECUTABLE_RAM_SIZE
327+
int "Boot image executable base size"
328+
default $(dt_chosen_reg_size_int,$(DT_CHOSEN_Z_SRAM),0)
329+
endif
330+
323331
config BOOT_ENCRYPTION_SUPPORT
324332
bool
325333
help
@@ -622,7 +630,7 @@ config BOOT_INTR_VEC_RELOC
622630
config UPDATEABLE_IMAGE_NUMBER
623631
int "Number of updateable images"
624632
default 1
625-
range 1 1 if SINGLE_APPLICATION_SLOT
633+
range 1 1 if SINGLE_APPLICATION_SLOT || SINGLE_APPLICATION_SLOT_RAM_LOAD
626634
help
627635
Enables support of multi image update.
628636

boot/zephyr/include/mcuboot_config/mcuboot_config.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,14 @@
108108

109109
#endif /* CONFIG_SINGLE_APPLICATION_SLOT */
110110

111+
#ifdef CONFIG_SINGLE_APPLICATION_SLOT_RAM_LOAD
112+
#define MCUBOOT_RAM_LOAD 1
113+
#define MCUBOOT_IMAGE_NUMBER 1
114+
#define MCUBOOT_SINGLE_APPLICATION_SLOT_RAM_LOAD 1
115+
#define IMAGE_EXECUTABLE_RAM_START CONFIG_BOOT_IMAGE_EXECUTABLE_RAM_START
116+
#define IMAGE_EXECUTABLE_RAM_SIZE CONFIG_BOOT_IMAGE_EXECUTABLE_RAM_SIZE
117+
#endif
118+
111119
#ifdef CONFIG_LOG
112120
#define MCUBOOT_HAVE_LOGGING 1
113121
#endif

0 commit comments

Comments
 (0)