2026-01-22 8:15 AM
I'm experiencing a HardFault that occurs always on cold boot (after the board sits unpowered for ~1 hour). It also occurs sometimes when flashing and immediately running from the debugger.
I'm using FreeRTOS, and I've noticed that commenting a task, flashing the new firmware, no hard faults. De-commenting the same code, flashing again, problem solved (with debugger on).
I exit the debugger and try to power cycle the device, all works.
After the board sits unpowered for a certain time and I try to turn it on, Hard Fault again.
The issue is always the same CFSR.IMPRECISERR (imprecise data access error)
I managed to have a call stack and the assembly code
CFSR.IMPRECISERR (imprecise data access error)
PC = 0x70017DD2
Stack trace:
HardFault_Handler
<Exception frame>
touchgfx::LCDGPU2D_AXI::blitCopyCompressedRGB565_16BPP() + 0x69d0x7001'7dca: LDRGT R2, [SP, #0x1c] ; Load scratchBuffer address
0x7001'7dcc: STRHGT.W R10, [R2, R5, LSL #1] ; Store halfword
0x7001'7dd0: ADDGT R5, R5, #1
0x7001'7dd2: SUBGT R7, R7, #1 ; <-- Fault occurs hereMPU configuration is
// Region 1: XSPI2 Flash (code execution)
MPU_InitStruct.BaseAddress = 0x70000000;
MPU_InitStruct.Size = MPU_REGION_SIZE_128MB;
MPU_InitStruct.IsCacheable = MPU_ACCESS_CACHEABLE;
MPU_InitStruct.IsBufferable = MPU_ACCESS_BUFFERABLE;
MPU_InitStruct.DisableExec = MPU_INSTRUCTION_ACCESS_ENABLE;
// Region 3: External RAM (framebuffer)
MPU_InitStruct.BaseAddress = 0x90000000;
MPU_InitStruct.Size = MPU_REGION_SIZE_32MB;
MPU_InitStruct.IsCacheable = MPU_ACCESS_NOT_CACHEABLE;
MPU_InitStruct.IsBufferable = MPU_ACCESS_NOT_BUFFERABLE;
// Region 6: RAM_CMD (uncached GPU buffers)
MPU_InitStruct.BaseAddress = 0x24068000;
MPU_InitStruct.Size = MPU_REGION_SIZE_32KB;
MPU_InitStruct.IsCacheable = MPU_ACCESS_NOT_CACHEABLE;
MPU_InitStruct.IsBufferable = MPU_ACCESS_NOT_BUFFERABLE;I'm monitoring the stack usage of the various tasks and the free heap, and all are below <50% of usage.
Attached the .icf file.
I've really no idea how to debug it; it happens sometimes, and it is not perfectly reproducible.