Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 17 additions & 11 deletions Kconfig.zephyr
Original file line number Diff line number Diff line change
Expand Up @@ -85,20 +85,24 @@ config HAS_FLASH_LOAD_OFFSET
This option is selected by targets having a FLASH_LOAD_OFFSET
and FLASH_LOAD_SIZE.

config USE_CODE_PARTITION
bool "link into code-partition"
depends on HAS_FLASH_LOAD_OFFSET
if HAS_FLASH_LOAD_OFFSET

config USE_DT_CODE_PARTITION
bool "Link application into /chosen/zephyr,code-partition from devicetree"
help
When selected application will be linked into chosen code-partition.
When enabled, the application will be linked into the flash partition
selected by the zephyr,code-partition property in /chosen in devicetree.
When this is disabled, the flash load offset and size can be set manually
below.

# Workaround for not being able to have commas in macro arguments
DT_CHOSEN_Z_CODE_PARTITION := zephyr,code-partition

config FLASH_LOAD_OFFSET
hex "Kernel load offset"
default $(dt_chosen_reg_addr_hex,$(DT_CHOSEN_Z_CODE_PARTITION)) if USE_CODE_PARTITION
# Only user-configurable when USE_DT_CODE_PARTITION is disabled
hex "Kernel load offset" if !USE_DT_CODE_PARTITION
default $(dt_chosen_reg_addr_hex,$(DT_CHOSEN_Z_CODE_PARTITION)) if USE_DT_CODE_PARTITION
default 0
depends on HAS_FLASH_LOAD_OFFSET
help
This option specifies the byte offset from the beginning of flash that
the kernel should be loaded into. Changing this value from zero will
Expand All @@ -108,10 +112,10 @@ config FLASH_LOAD_OFFSET
If unsure, leave at the default value 0.

config FLASH_LOAD_SIZE
hex "Kernel load size"
default $(dt_chosen_reg_size_hex,$(DT_CHOSEN_Z_CODE_PARTITION)) if USE_CODE_PARTITION
# Only user-configurable when USE_DT_CODE_PARTITION is disabled
hex "Kernel load size" if !USE_DT_CODE_PARTITION
default $(dt_chosen_reg_size_hex,$(DT_CHOSEN_Z_CODE_PARTITION)) if USE_DT_CODE_PARTITION
default 0
depends on HAS_FLASH_LOAD_OFFSET
help
If non-zero, this option specifies the size, in bytes, of the flash
area that the Zephyr image will be allowed to occupy. If zero, the
Expand All @@ -120,6 +124,8 @@ config FLASH_LOAD_SIZE

If unsure, leave at the default value 0.

endif # HAS_FLASH_LOAD_OFFSET

config TEXT_SECTION_OFFSET
hex
prompt "TEXT section offset" if !BOOTLOADER_MCUBOOT
Expand Down Expand Up @@ -351,7 +357,7 @@ config BOOTLOADER_SRAM_SIZE

config BOOTLOADER_MCUBOOT
bool "MCUboot bootloader support"
select USE_CODE_PARTITION
select USE_DT_CODE_PARTITION
help
This option signifies that the target uses MCUboot as a bootloader,
or in other words that the image is to be chain-loaded by MCUboot.
Expand Down
6 changes: 3 additions & 3 deletions boards/arm/nrf52840_pca10059/Kconfig.defconfig
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ if BOARD_NRF52840_PCA10059
config BOARD
default "nrf52840_pca10059"

if BOARD_HAS_NRF5_BOOTLOADER && !USE_CODE_PARTITION
if BOARD_HAS_NRF5_BOOTLOADER && !USE_DT_CODE_PARTITION

# To let the nRF5 bootloader load an application, the application
# must be linked after Nordic MBR, that is factory-programmed on the board.
Expand All @@ -18,14 +18,14 @@ if BOARD_HAS_NRF5_BOOTLOADER && !USE_CODE_PARTITION
# DTS file, so we manually override FLASH_LOAD_OFFEST to link the application
# correctly, after Nordic MBR.

# When building MCUBoot, MCUBoot itself will select USE_CODE_PARTITION
# When building MCUBoot, MCUBoot itself will select USE_DT_CODE_PARTITION
# which will make it link into the correct partition specified in DTS file,
# so no override is necessary.

config FLASH_LOAD_OFFSET
default 0x1000

endif # BOARD_HAS_NRF5_BOOTLOADER && !USE_CODE_PARTITION
endif # BOARD_HAS_NRF5_BOOTLOADER && !USE_DT_CODE_PARTITION

if ADC

Expand Down
2 changes: 1 addition & 1 deletion soc/riscv/openisa_rv32m1/linker.ld
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

#define VECTOR_SIZE CONFIG_RISCV_RV32M1_VECTOR_SIZE

#ifdef CONFIG_USE_CODE_PARTITION
#ifdef CONFIG_USE_DT_CODE_PARTITION

#ifdef CONFIG_BOOTLOADER_MCUBOOT

Expand Down