FOTA failure after SDK upgrade (partitioning issue)

Hello everyone,

I have a firmware running on nRF9160 which was developed with nrf sdk v2.2.0, now I want to update it to use nrf sdk v3.1.1.
I cannot build the firmware when having the same partitioning as before. This is the error the I get:

/opt/nordic/ncs/v3.1.1/nrf/modules/trusted-firmware-m/tfm_boards/common/assert.c:18:9: note: '#pragma message: 

!!!Partition alignment error!!!
The non-secure start address in pm_static.yml or generated partition.yml is: 0x20200
which is not aligned with the SPU/MPC HW requirements.
In nRF53/nRF91 series the flash region need to be aligned with the SPU region size.
In nRF54L15/nRF54L10 the flash region need to be aligned with the MPC region size.
Refer to the documentation section 'TF-M partition alignment requirements'
for more information.

   '
   18 | #pragma message \
      |         ^~~~~~~
/opt/nordic/ncs/v3.1.1/nrf/modules/trusted-firmware-m/tfm_boards/common/assert.c:29:2: error: #error "TF-M non-secure start address is not aligned to SPU/MPC HW requirements"
   29 | #error "TF-M non-secure start address is not aligned to SPU/MPC HW requirements"

And this is the flash partitioning of the old firmware:

To solve this issue I modified the partitioning to this:

When I try to update the firmware via FOTA, After finishing downloading the firmware, I get "Image in the secondary slot is not valid!" and the firmware goes back to the old one.
This happens when the old FW is running and I want to upgrade it to the new one, If I do the fota for the same old fw the process completes successfully.

*** Booting Zephyr OS build v3.2.99-ncs1 ***
I: Starting bootloader
I: Primary image: magic=good, swap_type=0x2, copy_done=0x1, image_ok=0x1
I: Secondary image: magic=good, swap_type=0x2, copy_done=0x3, image_ok=0x3
I: Boot source: none
I: Swap type: test
E: Image in the secondary slot is not valid!
I: Bootloader chainload address offset: 0x10000

Any idea how I can solve this issue?

Related