Skip to content

Commit db9a7f5

Browse files
committed
boot: zephyr: cmake: Fix issue with missing dts entries
Fixes an issue whereby a device might not have a write or erase entry for the flash controller in devicetree. In the case whereby the other slot has this information, use that instead. In the case whereby neither slot has this information, use default values and show a warning to the user Signed-off-by: Jamie McCrae <[email protected]>
1 parent 8cee355 commit db9a7f5

File tree

1 file changed

+25
-5
lines changed

1 file changed

+25
-5
lines changed

boot/zephyr/CMakeLists.txt

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -393,15 +393,27 @@ if(SYSBUILD)
393393
dt_prop(erase_size_slot1 PATH "${slot1_flash}" PROPERTY "erase-block-size")
394394
dt_prop(write_size_slot1 PATH "${slot1_flash}" PROPERTY "write-block-size")
395395

396-
if(${erase_size_slot0} GREATER ${erase_size_slot1})
396+
if(DEFINED erase_size_slot0 AND DEFINED erase_size_slot1)
397+
if(${erase_size_slot0} GREATER ${erase_size_slot1})
398+
set(erase_size ${erase_size_slot0})
399+
else()
400+
set(erase_size ${erase_size_slot1})
401+
endif()
402+
elseif(DEFINED erase_size_slot0)
397403
set(erase_size ${erase_size_slot0})
398-
else()
404+
elseif(DEFINED erase_size_slot1)
399405
set(erase_size ${erase_size_slot1})
400406
endif()
401407

402-
if(${write_size_slot0} GREATER ${write_size_slot1})
408+
if(DEFINED write_size_slot0 AND DEFINED write_size_slot1)
409+
if(${write_size_slot0} GREATER ${write_size_slot1})
410+
set(write_size ${write_size_slot0})
411+
else()
412+
set(write_size ${write_size_slot1})
413+
endif()
414+
elseif(DEFINED write_size_slot0)
403415
set(write_size ${write_size_slot0})
404-
else()
416+
elseif(DEFINED write_size_slot1)
405417
set(write_size ${write_size_slot1})
406418
endif()
407419
else()
@@ -413,7 +425,15 @@ if(SYSBUILD)
413425
dt_prop(write_size PATH "${slot0_flash}" PROPERTY "write-block-size")
414426
endif()
415427

416-
if(write_size LESS 8)
428+
if(NOT DEFINED erase_size)
429+
message(WARNING "Unable to determine erase size of slot0 or slot1 partition, setting to 1 (this is probably wrong)")
430+
set(erase_size 1)
431+
endif()
432+
433+
if(NOT DEFINED write_size)
434+
message(WARNING "Unable to determine write size of slot0 or slot1 partition, setting to 8 (this is probably wrong)")
435+
set(write_size 8)
436+
elseif(write_size LESS 8)
417437
set(write_size 8)
418438
endif()
419439

0 commit comments

Comments
 (0)