Hello,
I am working on an application in which I am required to FlashProtectSet(FlashReadOnly) at the very beginning of the application code to protect the range of memory(internal microcontroller flash) where my application code resides. I have used a custom bootloader which decides whether to continue in application mode or update mode every time the device is turned on or restarts. I have a firmware file(lets say firmware2)which resides in another range of microcontroller flash memory. On receiving certain command from user I am required to update my application code(residing in protected flash memory) with the firmware2 file. I am resetting the microcontroller using "HWREG(NVIC_APINT) = NVIC_APINT_VECTKEY | NVIC_APINT_SYSRESETREQ" api. Bootloader enters into update mode & here I am suppossed to copy firmware2 file to address where my application code resides. But here the application memory still remains in "FlashReadOnly" mode.
In FlashProtectSet api description, it is written that "Changes to the flash protection are maintained only until the next reset".
How should I proceed to make this range of microcontroller flash memory writtable in bootloader?