I'm using iMX7D (Sabre board, or other with same SoC), and Segger's JLink for JTAG debugger.
I'm using M4's BSP as provided by NXP, with FreeRTOS: FreeRTOS_BSP_1.0.1_iMX7D.
I have problem with debugging applications when I link & place the code into OCRAM. Refer to provided by NXP sample linker script in the BSP - MCIMX7D_M4_ocram.ld
Using the provided in the BSP Hello world sample, if linked to OCRAM, the code will run, but I cannot set breakpoints & debug because, once any of the breakpoints are hit starting from main(), the CPU will not run further, it will just stay halted on teh break point.
The culprit appears the cache usage. Ref. SystemInit() in system_MCIMX7D_M4.c:
/* Initialize Cache */
/* Enable System Bus Cache */
/* set command to invalidate all ways, enable write buffer
and write GO bit to initiate command */
LMEM_PSCCR = LMEM_PSCCR_INVW1_MASK | LMEM_PSCCR_INVW0_MASK;
LMEM_PSCCR |= LMEM_PSCCR_GO_MASK;
/* wait until the command completes */
while (LMEM_PSCCR & LMEM_PSCCR_GO_MASK);
/* Enable cache, enable write buffer */
LMEM_PSCCR = (LMEM_PSCCR_ENWRBUF_MASK | LMEM_PSCCR_ENCACHE_MASK);
If I disable / skip entirely this cache initialization, then the breakpoints are working again.
Any help with this issue? How do I keep using Cache, yet also able to actually debug the code ...