How to determine Debug/Release at run-time?

I’m wondering if there’s a way to determine at run-time whether or not image.bin is a debug build or a release build?

I Would guess that one way would be to add a compiler option like -DDEBUG_BUILD to the compiler options for the debug build and then use #ifdef DEBUG_BUILD in the code to do the detection.

I have not specifically tried this but I believe it will do what you need

I should have thought through what I needed before I posted that… on thing my app needs is to use the watchdog timer. What would be nice is if there was some way to detect if the JTAG is connected or not. Then I could enable/disable the watchdog accordingly.

>What would be nice is if there was some way to detect if the JTAG is connected or not
This is fairly easy and I think is already done anyways - check ncc_init.c file:

#if (PROCESSOR == ns9210) || (PROCESSOR == ns9215)
debugger = ((restartFlags & BL_DEBUGGER_FLAG) != 0);
spi_boot = (narm_read_reg(NA_SCM_MSCSR_REG, NA_SCM_MSCSR_ADDRESS, bootMode) == SCM_MSCSR_bootFromSpi);
sleep_wakeup = 0; /* NS9215 uses a different sleep mode /
#else
/

* Check to see if we are in the debugger. We need to know if an ICE is
* being used because there are certain things we do not want to do if
* someone is trying to step through code in a debugger. We don’t want to
* run the FULL memory test.
*
* There is no reliable way of detecting an ICE. By convention, the debugger
* scripts set the second bit of the SCM AHB Arbiter Gen Configuration
* register. This bit is always cleared by a hard reset.
*/
debugger = narm_read_reg(NA_SCM_AHB_GEN_CONFIG, NA_SCM_AHB_GEN_CONFIG_ADDR,
debug);
The simplest way to implement your own if this doesn’t work for you is to find some unused register and write something there from a debugger script. Then check this register from the code. If it has pthe pattern above, then debugger script was running and JTAG is connected.

After looking up the code you referenced, I found a function called are_we_in_debugger (in ncc_init.h). This appears to do exactly what I need. Thanks!