MCUboot loses pending update image in slot 1 after reset

I'm trying to download and flash an MCUboot image at runtime. All goes well, the image is flashed to the secondary slot, confirmed, and marked for upgrade. The secondary slot is in external spi flash.

On reboot MCUboot has no knowledge of the secondary image and boots back into the primary image. What could be going wrong here?

Stack trace BEFORE reset:

`mcumgr image list` BEFORE reset:

Stack trace AFTER reset:

`mcumgr image list` AFTER reset:

My `mcuboot.conf`:

My overlay:

My `partitions.yml`:

The code: