Great question. There is an example of this on the eCompass_Project that’s on the website.
Once downloaded look on lines 145 – 175 in the file eCompass_Project/Source/eCompass_Project.c
You can enable and disable this just by toggling the #if 0 to #if 1
What’s important to understand is that once the Boot-to-Flash bit is set, the only way to boot back to ROM code is
to have included a command in your executable that rewrites the BF bit, or to use the P&E Multilink debug probe to flash a new image with the desired BF bit setting.
If you are routinely using the P&E for downloading then this won’t be a problem.