This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

HardFault when writing/erasing flash unless RTT debugger active

Hi,

I found one older question (7 months ago) with the same problem but that had no answer.

Situation:

- SDK 15.3, s132 v6.1.1
- The softdevice has been enabled and ble stack initialized
- Code needs to erase and write a flash page (settings) unless already initialized

As soon as the flash erase (or write) is performed, the app crashes unless the RTT debugger (RTT viewer or Ozone) is attached. If the debug-connection is active everything works.

My code stores the hardfault information into noinit memory and prints it to RTT on next reboot, so when I attach a RTT connection to continuously rebooting MCU, I get:


00:00:00 *CPU FAULT*
00:00:00 - HFSR = 40000000
00:00:00 - CFSR = 400
00:00:00 - MMFAR = e000ed34
00:00:00 - BFAR = e000ed38
00:00:00 - R0 = 2000587c
00:00:00 - R1 = 1
00:00:00 - R2 = 76b6f
00:00:00 - R3 = 4001e400
00:00:00 - R12 = 0
00:00:00 - LR = 200058ac
00:00:00 - PC = 77141
00:00:00 - PSR = 0

PC is in the bootloader memory though the application code is clearly being run (seen from power curve).


Same thing happens with both Debug & Release builds and I'm running out of ideas...

Related