STM32MP1 support available in SW4STM32

   With System Workbench for Linux, Embedded Linux on the STM32MP1 family of MPUs from ST was never as simple to build and maintain, even for newcomers in the Linux world.
And, if you install System Workbench for Linux in System Workbench for STM32 you can seamlessly develop and debug asymmetric applications running partly on Linux, partly on the Cortex-M4; you can download a short video showcasing this on the ac6-tools website (registration required).

System Workbench for STM32

HardFault debugging

Hello everyone, I am developing a board and am fairly new working with stm32. My source code is triggering a hard fault in an unpredictable manner. It will run fine until I place a breakpoint or interact with the system workbench IDE in any way, at this point something triggers a hardfault. I am wondering how I can debug this problem I’ve found the following method at https://freertos.org/Debugging-Hard-Faults-On-Cortex-M-Microcontrollers.htmlQuestion to store the location of the program counter at time the fault occurs in a variable to try to understand whats causing the hard fault. However I am never reaching the
prvGetRegistersFromStack function from within the hardfault handler. The program just jumps to some strange address. Interestingly when I place the same instructions anywhere else in the program the function can be reached. Does anyone have any insight on what could be causing this or how to properly debug hard faults?

void HardFault_Handler(void) {
__ASM volatile(“BKPT #01”);
__asm volatile
” tst lr, #4 \n”
” ite eq \n”
” mrseq r0, msp \n”
” mrsne r0, psp \n”
” ldr r1, r0, #24 \n”
” ldr r2, handler2_address_const \n”
” bx r2 \n”
” handler2_address_const: .word prvGetRegistersFromStack \n”

void prvGetRegistersFromStack(uint32_t *pulFaultStackAddress) {
/* These are volatile to try and prevent the compiler/linker optimising them
away as the variables never actually get used. If the debugger won’t show the
values of the variables, make them global my moving their declaration outside
of this function. */
volatile uint32_t r0 attributeunused;
volatile uint32_t r1 attributeunused;
volatile uint32_t r2 attributeunused;
volatile uint32_t r3 attributeunused;
volatile uint32_t r12 attributeunused;
volatile uint32_t lr attributeunused; /* Link register. */
volatile uint32_t pc attributeunused; /* Program counter. */
volatile uint32_t psr attributeunused;/* Program status register. */

r0 = pulFaultStackAddress;
r1 = pulFaultStackAddress;
r2 = pulFaultStackAddress;
r3 = pulFaultStackAddress;

r12 = pulFaultStackAddress;
lr = pulFaultStackAddress;
pc = pulFaultStackAddress;
psr = pulFaultStackAddress;

/* When the following line is hit, the variables contain the register values. */
__ASM volatile(“BKPT #01”);
for( ;; );