Trying to debug with MCUBOOT enabled fails to boot.

Hello,
I am looking for a way to debug firmware that includes MCUBOOT. There seem to be quite some questions in regards to same problem with no real resolution.
I am using various versions of JLink, it seems that the problem occurs when flash breakpoint functionality does its magic.

From my understanding what happens:
- I flash firmware to target MCU (in this case it is nRF52840)
- Device boots normally, MCUBOOT does its magic and all the checks seem fine.
- I start debug session, device reboots into MCUBOOT and sets breakpoint to main as entry point to run to - I have no other breakpoints enabled!
- Because debugger is using flash breakpoints, it will replace some instructions in flash with a breakpoint instruction.
- Because debugger modified flash contents, application firmware image integrity is no longer the same as MCUBOOT expects.
- MCUBOOT therefore fails to boot with no bootable image found/FIH_PANIC.

I already tried all the MCUBOOT related kconfigs, that are supposed to disable checks on image:
- enable BOOT_SIGNATURE_TYPE_NONE
- disable BOOT_VALIDATE_SLOT0
- BOOT_VALIDATE_SLOT0_ONCE doesn't solve the problem either
- enable BOOT_FIH_PROFILE_OFF


How can I make sure that I will be able to debug firmware, despite using mcuboot? I don't think disabling it just for the sake of being able to debug the code is really suitable solution to the issue. I noticed that this issue does seem to depend on debugging hardware being used and its support for flash breakpoints and number of HW breakpoints being supported. But there also seems no exact clear requirement.

Related