Hi,
no, backdoor unsecure doesn't involve flash erase/reprogram. After backdoor unsecure MCU stays unsecured until reset (power cycle, reset pin, COP, etc). If you want permanently unsecure, then yes, you need to manipulate NVSEC (0x7F_FF0F) bits erasing reprogramming flash sector. But 1) backdoor unsecure has nothing to do with it and 2) it's not possible if NVPROT bits are set to protect NVPROT location (0x7F_FF0C, see Table 27-3. Flash Configuration Field). Anyway manipulating top flash sector, which includes reset vector is like shooting into you own foot, sudden power loss at bad time and you get dead unit in the field.
First of all let's check if we distinguish properly apples and oranges, security and write protection. You say FPROT is set up to not allow reprogramming 0x7F_F000–0x7F_FFFF. Do we understand that this is flash program/erase protection and not security, right? Security term is only about accessing RAM/FLASH/EEPROM vie BKGD pin.
Backdoor unsecure allows temporary (until first reset) BDM (BKGD pin) access to RAM/FLASH/EEPROM. Backdoor unsecure is there to avoid erasing or reprogramming anything, as well avoid unprotecting write protected FLASH when you need just temporary debug access to secured MCU.
1- backup the sector contains the flash configuration registers.
Not necessary
not necessary
3- make the desired manipulations:
3-1- clear ACCERR and PVIOL in FSTAT register.
3-2- program the back-door registers using write command (0x06) .
No. You need to use Verify Backdoor Access Key command (0xC).
3-3- launch the command (FSTAT = 0x80).
4- restore the rest of flash sector.
Restore is not necessary, Verify Backdoor Access Key command is not destructive, nothing to restore
- is it necessary to enable the backdoor access before securing operations?
If backdoor is disabled (KEYEN bits at NVKEY location are not 10), you can't use backdoor unsecure.
BTW all flash commands make flash not readable while command executes. This means you need to start command while executing code in RAM and stay in RAM until flash command completes. This means as well interrupt vectors in flash won't be readable to CPU while flash command executes, so you need to disable interrupts for duration of flash command.