Debug works at first, but fails after a few debug cycles

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Debug works at first, but fails after a few debug cycles

Jump to solution
706 Views
deniscollis
Contributor V

Setup:

  • MCUXpresso IDE v11.7.1 [Build 9221] [2023-03-28]
  • Custom Kinetis K82 board
  • Segger J-Link Base

Debug works after freshly powering up my workstation and board, connecting the debug probe, launching MCUXpresso with my project, and hitting 'Debug' in the Quickstart panel.

However, the debug environment fails after a few debug cycles. (Powering everything down and starting up again fixes it.)

Symptom 1:  Breakpoints are no longer honored, including the auto-breakpoint at the first executable statement in main().

Symptom 2: Some unnamed thread is running, and file 'startup_mk82f25615.c' pops into focus, positioned at function RsetISR()

deniscollis_0-1683309811585.png

Symptom 3: The application is not running (Its blinking LED remains off). If terminate the debug session the application remains stalled. But if I reset the board the application runs normally.

I normally have Semihosting active, but deactivating it does not fix the issue.

Can anyone cast some light onto this?

Denis

0 Kudos
1 Solution
685 Views
deniscollis
Contributor V

Resetting the board and clicking on [Clean Up Debug] after each debug cycle seems to work, but see the Deeper Dive below for the real reason.

deniscollis_1-1683563889454.png

 

Edit: Deeper dive.

This device has a PN5190 NFC that uses PTA4 NMI for its IRQ.  However, this pin's state is integral to the default system reset and startup, as defined in the Flash Config in startup_mk82F25615.c. 

Startup execution after reset fails because of misconfigured FOPT config in the Flash Config. The SDK's template startup_mk82f25615.c Flash Config FOPT config has 'NMI reset enabled', and 'boot source ROM'.  Change this to 'NMI reset blocked' and 'boot source internal flash' will return the board to a stable, debuggable state.  

The reason it works after a POR reset is that at POR the FOPT to 0xFFFF, before the is has been set by the Flash Config in the startup code.

 

 

View solution in original post

0 Kudos
1 Reply
686 Views
deniscollis
Contributor V

Resetting the board and clicking on [Clean Up Debug] after each debug cycle seems to work, but see the Deeper Dive below for the real reason.

deniscollis_1-1683563889454.png

 

Edit: Deeper dive.

This device has a PN5190 NFC that uses PTA4 NMI for its IRQ.  However, this pin's state is integral to the default system reset and startup, as defined in the Flash Config in startup_mk82F25615.c. 

Startup execution after reset fails because of misconfigured FOPT config in the Flash Config. The SDK's template startup_mk82f25615.c Flash Config FOPT config has 'NMI reset enabled', and 'boot source ROM'.  Change this to 'NMI reset blocked' and 'boot source internal flash' will return the board to a stable, debuggable state.  

The reason it works after a POR reset is that at POR the FOPT to 0xFFFF, before the is has been set by the Flash Config in the startup code.

 

 

0 Kudos