Erasing memory before programming

nRF Util

tags
nRF Util

For erasing, you can either use the nrfutil device erase command or take advantage of various options supported by the programming command, such as chip_erase_mode or ext_mem_erase_mode.

For example, the following command uses several of the available programming options:

nrfutil device --x-ext-mem-config-file config.json program --firmware zephyr.hex --options ext_mem_erase_mode=ERASE_RANGES_TOUCHED_BY_FIRMWARE,chip_erase_mode=ERASE_NONE,verify=VERIFY_READ --serial-number 1050065027
This command erases only the ranges of external memory that are touched by the firmware being programmed to the device with the serial number 1050065027. It does not erase the internal memory. It then verifies that the data has been written correctly.

Run nrfutil device program --help to see the extended description of the available option values.