Skip to content

Commit

Permalink
boot/zephyr: Add CONFIG_SINGLE_APPLICATION_SLOT_RAM_LOAD
Browse files Browse the repository at this point in the history
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]>
Signed-off-by: Tom Burdick <[email protected]>
  • Loading branch information
edersondisouza authored and nvlsianpu committed Oct 25, 2024
1 parent 5c67fb9 commit 249a71d
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 18 deletions.
8 changes: 4 additions & 4 deletions boot/zephyr/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ zephyr_library_sources(
)
endif()

if(CONFIG_SINGLE_APPLICATION_SLOT)
if(CONFIG_SINGLE_APPLICATION_SLOT OR CONFIG_SINGLE_APPLICATION_SLOT_RAM_LOAD)
zephyr_library_sources(
${BOOT_DIR}/zephyr/single_loader.c
)
Expand All @@ -143,7 +143,7 @@ zephyr_library_sources(
)
endif()

if(CONFIG_BOOT_RAM_LOAD)
if(CONFIG_BOOT_RAM_LOAD OR CONFIG_SINGLE_APPLICATION_SLOT_RAM_LOAD)
zephyr_library_sources(
${BOOT_DIR}/bootutil/src/ram_load.c
)
Expand Down Expand Up @@ -398,7 +398,7 @@ if(CONFIG_BOOT_SWAP_USING_MOVE)
endif()
endif()

if(NOT CONFIG_SINGLE_APPLICATION_SLOT)
if(NOT CONFIG_SINGLE_APPLICATION_SLOT AND NOT CONFIG_SINGLE_APPLICATION_SLOT_RAM_LOAD)
dt_nodelabel(slot1_flash NODELABEL "slot1_partition")
dt_prop(slot1_size PATH "${slot1_flash}" PROPERTY "reg" INDEX 1)
dt_get_parent(slot1_flash)
Expand Down Expand Up @@ -426,7 +426,7 @@ if(CONFIG_BOOT_MAX_IMG_SECTORS_AUTO)
math(EXPR slot_min_sectors "${slot0_size} / ${erase_size_slot0}")
endif()

if(NOT CONFIG_SINGLE_APPLICATION_SLOT)
if(NOT CONFIG_SINGLE_APPLICATION_SLOT AND NOT CONFIG_SINGLE_APPLICATION_SLOT_RAM_LOAD)
if(NOT DEFINED slot1_size)
message(WARNING "Unable to determine size of slot1 partition, cannot calculate minimum sector usage")
elseif(NOT DEFINED erase_size_slot1)
Expand Down
36 changes: 22 additions & 14 deletions boot/zephyr/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -326,19 +326,6 @@ config BOOT_FIRMWARE_LOADER

endchoice

# Workaround for not being able to have commas in macro arguments
DT_CHOSEN_Z_SRAM := zephyr,sram

if BOOT_RAM_LOAD
config BOOT_IMAGE_EXECUTABLE_RAM_START
hex "Boot image executable ram start"
default $(dt_chosen_reg_addr_hex,$(DT_CHOSEN_Z_SRAM))

config BOOT_IMAGE_EXECUTABLE_RAM_SIZE
int "Boot image executable base size"
default $(dt_chosen_reg_size_int,$(DT_CHOSEN_Z_SRAM),0)
endif

config BOOT_DIRECT_XIP_REVERT
bool "Enable the revert mechanism in direct-xip mode"
depends on BOOT_DIRECT_XIP
Expand Down Expand Up @@ -375,6 +362,27 @@ config BOOT_SWAP_SAVE_ENCTLV

endif # !SINGLE_APPLICATION_SLOT

config SINGLE_APPLICATION_SLOT_RAM_LOAD
bool "RAM load for single application slot"
help
If y, the image is loaded to RAM and executed from there. For this reason,
the image has to be linked to be executed from RAM. The address that the
image is copied to is specified using the load-addr argument to the
imgtool.py script which writes it to the image header.

# Workaround for not being able to have commas in macro arguments
DT_CHOSEN_Z_SRAM := zephyr,sram

if BOOT_RAM_LOAD || SINGLE_APPLICATION_SLOT_RAM_LOAD
config BOOT_IMAGE_EXECUTABLE_RAM_START
hex "Boot image executable ram start"
default $(dt_chosen_reg_addr_hex,$(DT_CHOSEN_Z_SRAM))

config BOOT_IMAGE_EXECUTABLE_RAM_SIZE
int "Boot image executable base size"
default $(dt_chosen_reg_size_int,$(DT_CHOSEN_Z_SRAM),0)
endif

config BOOT_ENCRYPTION_SUPPORT
bool
help
Expand Down Expand Up @@ -683,7 +691,7 @@ config BOOT_INTR_VEC_RELOC
config UPDATEABLE_IMAGE_NUMBER
int "Number of updateable images"
default 1
range 1 1 if SINGLE_APPLICATION_SLOT
range 1 1 if SINGLE_APPLICATION_SLOT || SINGLE_APPLICATION_SLOT_RAM_LOAD
help
Enables support of multi image update.

Expand Down
8 changes: 8 additions & 0 deletions boot/zephyr/include/mcuboot_config/mcuboot_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,14 @@

#endif /* CONFIG_SINGLE_APPLICATION_SLOT */

#ifdef CONFIG_SINGLE_APPLICATION_SLOT_RAM_LOAD
#define MCUBOOT_RAM_LOAD 1
#define MCUBOOT_IMAGE_NUMBER 1
#define MCUBOOT_SINGLE_APPLICATION_SLOT_RAM_LOAD 1
#define IMAGE_EXECUTABLE_RAM_START CONFIG_BOOT_IMAGE_EXECUTABLE_RAM_START
#define IMAGE_EXECUTABLE_RAM_SIZE CONFIG_BOOT_IMAGE_EXECUTABLE_RAM_SIZE
#endif

#ifdef CONFIG_LOG
#define MCUBOOT_HAVE_LOGGING 1
#endif
Expand Down

0 comments on commit 249a71d

Please sign in to comment.