Hi Ming Jiang,
In my opinion, you should follow the kind of produce to configure the 0x40D and 0x40C field.
1. First of all, you'd better to load the whole bootloader code run in the RAM instead of flash.
2. Next, assure the 0x40D and 0x40C field are 0xFF, in another word, the field need to be erased previously before reprogram.
So you can use some kind of erase commands to achieve it.
3. Finally, reprogram the field and other erased area by using the program longword command.
Hope it helps.
Have a great day,
Ping
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------