Hi @jackl_intercomp
Thank you for reaching out!
I understand that you are on development phase and that you are debugging your bootloader and application, and simply merging them into a single binary for convenient programming. But I still I want your help to understand better the scenario.
It sounds like you are using the MCUXpresso IDE, is this true? If not , which IDE? Yet, I do not quite understand how to replicate it or the debug operation your are triggering, let me explain more about what I understand as debug operation on IDE.
You said that the debug operation deletes whole flash, or at least both bootlaoder and app. This sounds like a tipical and default setup, whenever you want to program a flash, the debug script will simply erase all flash contenst before writting the new image. In more detail, general IDE Debug operation tipically involves erasing, then programming the flash, and finally putting a breakpoint to halt into main(). However, debuggers allow you to do only an attach operation to halt the MCU excecution, does that helps as a workarround for you? I mean you will still need to see where the MCU halts, or set a breakpoint.
Regards,
Diego