In general it is possible, but you might need to use lower-level APIs in order to achieve that. In the Golioth Zephyr DFU sample we use Zephyr’s subsys/dfu/img_util
in order to write downloaded image to flash. This subsystem assumes for now the simplest approach of 2 image slots and the slot is hardcoded in zephyr/subsys/dfu/img_util/flash_img.c
:
#ifdef CONFIG_TRUSTED_EXECUTION_NONSECURE
#define UPLOAD_FLASH_AREA_LABEL slot1_ns_partition
#else
#if FIXED_PARTITION_EXISTS(slot1_partition)
#define UPLOAD_FLASH_AREA_LABEL slot1_partition
#else
#define UPLOAD_FLASH_AREA_LABEL slot0_partition
#endif
#endif
/* FIXED_PARTITION_ID() values used below are auto-generated by DT */
#define UPLOAD_FLASH_AREA_ID FIXED_PARTITION_ID(UPLOAD_FLASH_AREA_LABEL)
In order to write into another partition, you need to either extend this subsystem in Zephyr or write your own utilities that will use partition of your choice.