Hi @kellykan
Q1: Is it possible to update the bootloader from application code?
Yes, it is possible, but it involves several critical steps and considerations due to the ECRP protection. The ECRP value locks the first page in flash to protect it, and typically, to update the bootloader, you must perform a mass erase to clear the ECRP protection. After the mass erase, you can reprogram the bootloader and set the ECRP value again.
Q2: Do I require a reset after erasing all sectors to clear the lock of flash sector?
Yes, a reset is generally required after a mass erase to reinitialize the flash controller and to ensure that the ECRP lock is cleared properly. Without a reset, the flash controller may still have remnants of the lock, which could cause issues during subsequent flash operations.
Q3: Issues with flashing the second page using IAP command
1. Incomplete Erase or Programming: Ensure that the mass erase was successful and that the flash sectors are correctly erased before attempting to program.
2. Incorrect IAP Command Sequence: Verify that you are using the correct sequence of IAP commands for erasing and programming flash sectors.
3. Reset Requirement: As mentioned, performing a reset after the mass erase might be necessary to clear the ECRP lock completely.
Hope this will help you.
BR
Hang