Skip to content
This repository was archived by the owner on Dec 26, 2023. It is now read-only.

Commit 3f33207

Browse files
petejohansoncarlescufi
authored andcommitted
build: uf2: Flexible UF2 offset selection.
UF2 offset configurable to be either flash base reg + offset, or simply the flash bare reg if the offset is configured to be ignored. Signed-off-by: Peter Johanson <[email protected]>
1 parent 3266e82 commit 3f33207

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

CMakeLists.txt

+16-1
Original file line numberDiff line numberDiff line change
@@ -1454,12 +1454,27 @@ if(CONFIG_BUILD_OUTPUT_BIN)
14541454
endif()
14551455

14561456
if(CONFIG_BUILD_OUTPUT_BIN AND CONFIG_BUILD_OUTPUT_UF2)
1457+
if(CONFIG_BUILD_OUTPUT_UF2_USE_FLASH_BASE)
1458+
set(flash_addr "${CONFIG_FLASH_BASE_ADDRESS}")
1459+
else()
1460+
set(flash_addr "${CONFIG_FLASH_LOAD_OFFSET}")
1461+
endif()
1462+
1463+
if(CONFIG_BUILD_OUTPUT_UF2_USE_FLASH_OFFSET)
1464+
# Note, the `+ 0` in formula below avoids errors in cases where a Kconfig
1465+
# variable is undefined and thus expands to nothing.
1466+
math(EXPR flash_addr
1467+
"${flash_addr} + ${CONFIG_FLASH_LOAD_OFFSET} + 0"
1468+
OUTPUT_FORMAT HEXADECIMAL
1469+
)
1470+
endif()
1471+
14571472
list(APPEND
14581473
post_build_commands
14591474
COMMAND ${PYTHON_EXECUTABLE} ${ZEPHYR_BASE}/scripts/uf2conv.py
14601475
-c
14611476
-f ${CONFIG_BUILD_OUTPUT_UF2_FAMILY_ID}
1462-
-b ${CONFIG_FLASH_LOAD_OFFSET}
1477+
-b ${flash_addr}
14631478
-o ${KERNEL_UF2_NAME}
14641479
${KERNEL_BIN_NAME}
14651480
)

Kconfig.zephyr

+8
Original file line numberDiff line numberDiff line change
@@ -486,6 +486,14 @@ config BUILD_OUTPUT_UF2_FAMILY_ID
486486
name string. If the SoC in use is known by UF2, the Family ID will
487487
be pre-filled with the known value.
488488

489+
config BUILD_OUTPUT_UF2_USE_FLASH_BASE
490+
bool
491+
default n
492+
493+
config BUILD_OUTPUT_UF2_USE_FLASH_OFFSET
494+
bool
495+
default n
496+
489497
endif # BUILD_OUTPUT_UF2
490498

491499
config BUILD_OUTPUT_STRIPPED

0 commit comments

Comments
 (0)