>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 */
* 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,
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.