Flashing firmware without erasing factory data

Hi there

I'm working on nRF5340 chip and looking for a way to preserve the factory data that is saved in factory_data region. I tried playing around with the factory data related configs in Kconfig file, the closest config about preserve the factory data is CHIP_FACTORY_DATA_WRITE_PROTECT. However it seems not working with my configuration:

mcuboot_primary_app:
orig_span: &id002
- app
span: *id002
address: 0x8200
size: 0xeee00
factory_data:
address: 0xf7000
size: 0x1000
region: flash_primary
settings_storage:
address: 0xf8000
size: 0x8000
region: flash_primary

The FPROTECT_BLOCK_SIZE for zephyr is 0x4000 and for multiprotocol_rpmsg is 0x800.

When using the flash option in VS Code(not the Erase and Flash to Board), the factory data region is not preserved after the flash. The factory data flash process is separated from app/nwk FW flash, so I can't call FPROTECT in the app firmware to lock the region 0x3000 before the factory data region. I'm hoping to find a way to preserve the factory data from flashing action from both VS code interface and command line interface.

Would moving factory data onto external flash work? Can I store the factory data to external flash by updating the factory_data region to "region: external_flash" and the address I'd like it to be on external flash?

Thanks,

Yuelin

Related