Target crash/reset

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

Target crash/reset

762 Views
oaf
Contributor IV

Is there a single point where all resets run through? I'm thinking of a place to put a breakpoint so that a crashing sw doesn't just reboot, but stop in my debugger.

Labels (1)
Tags (3)
0 Kudos
4 Replies

534 Views
anthony_huereca
NXP Employee
NXP Employee

To expand on David's reply, the KSDK code will start from reset at C:\Freescale\KSDK_1.1.0\platform\startup\<device_family>\<toolchain>\starup_<device_fmaily>.s in the "Reset_Handler" subroutine.

It's toolchain dependent on how to setup your debugger to start there instead of main() (which is the default setting), but typically it's in the debug settings, and you can either set it to be blank or use "Reset_Handler". Note that you will likely have to "run" through the watchdog disable, since trying to step through line by line of that code will cause the device to reset. So just set a breakpoint after that those lines David pointed out (so line 33) and you'll be good to go.

On a related note, if someone reading this is using MQX for KSDK, the entry point for MQX can be found at C:\Freescale\KSDK_1.1.0\rtos\mqx\mqx\source\psp\cortex_m\core\<core>\boot.S at the "Reset_Handler" subroutine.

0 Kudos

534 Views
DavidS
NXP Employee
NXP Employee

Hi Ole,

It depends on the tools being used but in general all code will have disabling Watchdog and checking to clear flag related to LLSx/VLLSx wakeups.

The example I just tested with was using the hello_world_frdmk22f (C:\Freescale\KSDK_1.1.0\demos\hello_world\kds\frdmk22f) and added a software breakpoint below:

/* ----------------------------------------------------------------------------

   -- Core clock

   ---------------------------------------------------------------------------- */

uint32_t SystemCoreClock = DEFAULT_SYSTEM_CLOCK;

/* ----------------------------------------------------------------------------

   -- SystemInit()

   ---------------------------------------------------------------------------- */

void SystemInit (void) {

#if ((__FPU_PRESENT == 1) && (__FPU_USED == 1))

  SCB->CPACR |= ((3UL << 10*2) | (3UL << 11*2));    /* set CP10, CP11 Full Access */

#endif /* ((__FPU_PRESENT == 1) && (__FPU_USED == 1)) */

#if (DISABLE_WDOG)

  /* WDOG->UNLOCK: WDOGUNLOCK=0xC520 */

  WDOG->UNLOCK = WDOG_UNLOCK_WDOGUNLOCK(0xC520); /* Key 1 */

  /* WDOG->UNLOCK: WDOGUNLOCK=0xD928 */

  WDOG->UNLOCK = WDOG_UNLOCK_WDOGUNLOCK(0xD928); /* Key 2 */

  /* WDOG->STCTRLH: ?=0,DISTESTWDOG=0,BYTESEL=0,TESTSEL=0,TESTWDOG=0,?=0,?=1,WAITEN=1,STOPEN=1,DBGEN=0,ALLOWUPDATE=1,WINEN=0,IRQRSTEN=0,CLKsrc=1,WDOGEN=0 */

  WDOG->STCTRLH = WDOG_STCTRLH_BYTESEL(0x00) |

                 WDOG_STCTRLH_WAITEN_MASK |

                 WDOG_STCTRLH_STOPEN_MASK |

                 WDOG_STCTRLH_ALLOWUPDATE_MASK |

                 WDOG_STCTRLH_CLKSRC_MASK |

                 0x0100U;

#endif /* (DISABLE_WDOG) */

  if((RCM->SRS0 & RCM_SRS0_WAKEUP_MASK) != 0x00U)

  {

    if((PMC->REGSC & PMC_REGSC_ACKISO_MASK) != 0x00U)

    {

       PMC->REGSC |= PMC_REGSC_ACKISO_MASK; /* Release hold with ACKISO:  Only has an effect if recovering from VLLSx.*/

    }

  } else {

#ifdef SYSTEM_RTC_CR_VALUE

    SIM_SCGC6 |= SIM_SCGC6_RTC_MASK;

    if ((RTC_CR & RTC_CR_OSCE_MASK) == 0x00U) { /* Only if the OSCILLATOR is not already enabled */

      RTC_CR = (uint32_t)((RTC_CR & (uint32_t)~(uint32_t)(RTC_CR_SC2P_MASK | RTC_CR_SC4P_MASK | RTC_CR_SC8P_MASK | RTC_CR_SC16P_MASK)) | (uint32_t)SYSTEM_RTC_CR_VALUE);

      RTC_CR |= (uint32_t)RTC_CR_OSCE_MASK;

      RTC_CR &= (uint32_t)~(uint32_t)RTC_CR_CLKO_MASK;

    }

#endif

  }

#if 1 //DES 1=test, 0=default code

    __asm("bkpt 4");

#endif

  /* Power mode protection initialization */

#ifdef SYSTEM_SMC_PMPROT_VALUE

  SMC->PMPROT = SYSTEM_SMC_PMPROT_VALUE;

#endif

  }

#if 1 //DES 1=test, 0=default code

    __asm("bkpt 4");

#endif

  /* Power mode protection initialization */

#ifdef SYSTEM_SMC_PMPROT_VALUE

  SMC->PMPROT = SYSTEM_SMC_PMPROT_VALUE;

#endif

0 Kudos

534 Views
oaf
Contributor IV

Hi,

Sorry, but I don't see where you put your breakpoint. I hope this point is before a new stack is setup? The point was to discover the last traces before the crash....

0 Kudos

534 Views
DavidS
NXP Employee
NXP Employee

Email reply didn't have my cut-n-paste material added correctly.  I have updated the post to include the example code.  Yes it is before any stacks are initialized.

Regards,

David

0 Kudos