Skip to content

Commit

Permalink
boot: zephyr: cmake: Fix issue with missing dts entries
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
nordicjm committed Jan 8, 2024
1 parent 8cee355 commit db9a7f5
Showing 1 changed file with 25 additions and 5 deletions.
30 changes: 25 additions & 5 deletions boot/zephyr/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -393,15 +393,27 @@ if(SYSBUILD)
dt_prop(erase_size_slot1 PATH "${slot1_flash}" PROPERTY "erase-block-size")
dt_prop(write_size_slot1 PATH "${slot1_flash}" PROPERTY "write-block-size")

if(${erase_size_slot0} GREATER ${erase_size_slot1})
if(DEFINED erase_size_slot0 AND DEFINED erase_size_slot1)
if(${erase_size_slot0} GREATER ${erase_size_slot1})
set(erase_size ${erase_size_slot0})
else()
set(erase_size ${erase_size_slot1})
endif()
elseif(DEFINED erase_size_slot0)
set(erase_size ${erase_size_slot0})
else()
elseif(DEFINED erase_size_slot1)
set(erase_size ${erase_size_slot1})
endif()

if(${write_size_slot0} GREATER ${write_size_slot1})
if(DEFINED write_size_slot0 AND DEFINED write_size_slot1)
if(${write_size_slot0} GREATER ${write_size_slot1})
set(write_size ${write_size_slot0})
else()
set(write_size ${write_size_slot1})
endif()
elseif(DEFINED write_size_slot0)
set(write_size ${write_size_slot0})
else()
elseif(DEFINED write_size_slot1)
set(write_size ${write_size_slot1})
endif()
else()
Expand All @@ -413,7 +425,15 @@ if(SYSBUILD)
dt_prop(write_size PATH "${slot0_flash}" PROPERTY "write-block-size")
endif()

if(write_size LESS 8)
if(NOT DEFINED erase_size)
message(WARNING "Unable to determine erase size of slot0 or slot1 partition, setting to 1 (this is probably wrong)")
set(erase_size 1)
endif()

if(NOT DEFINED write_size)
message(WARNING "Unable to determine write size of slot0 or slot1 partition, setting to 8 (this is probably wrong)")
set(write_size 8)
elseif(write_size LESS 8)
set(write_size 8)
endif()

Expand Down

0 comments on commit db9a7f5

Please sign in to comment.