Commit db9a7f58 authored by Jamie McCrae's avatar Jamie McCrae Committed by Jamie
Browse files

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: default avatarJamie McCrae <jamie.mccrae@nordicsemi.no>
parent 8cee3550
Loading
Loading
Loading
Loading
+21 −1
Changes for boot/zephyr/CMakeLists.txt: 21 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -393,17 +393,29 @@ 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(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})
        elseif(DEFINED erase_size_slot1)
          set(erase_size ${erase_size_slot1})
        endif()

        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})
        elseif(DEFINED write_size_slot1)
          set(write_size ${write_size_slot1})
        endif()
      else()
        dt_prop(erase_size PATH "${slot0_flash}" PROPERTY "erase-block-size")
        dt_prop(write_size PATH "${slot0_flash}" PROPERTY "write-block-size")
@@ -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()