The Zephyr implementation of flash_area_to_sectors() returns struct flash_area entries whose size is equal to that of the scratch partition, rather than the sector size of the underlying hardware.
We may run into situations where, e.g. due to variable flash sector size on the device, this is the best we can do. However, the current code won't work on targets that do have a flash sector size, but whose image size is not divisible by its sector size.
This is affecting the integration of the NRF52840-PDK:
On that board, we want to have 432 KiB images and a 116 KiB scratch area. Since 432 is not divisible by 116, the return value of flash_area_to_sectors() is not correct, and image swapping infinite loops.
This ticket tracks fixing flash_area_to_sectors() on Zephyr, or at least providing an alternate implementation when the flash sector size is known, to allow for supporting the NRF52840-PDK with the flash area sizes described above.