2025-07-11 1:18 AM - last edited on 2025-07-11 2:57 AM by mƎALLEm
I’m using NUCLEO STM32H753ZI.
I use ST ID: STM32cudeIDE
I have HardFault_Handler when call vTaskStart_Scheduler() using FreeRTOS
Could you please let me know how to resolve this issue?
Below is the sample code
int main(void)
{
(void) HAL_Init();
/* Configure the system clock */
SystemClock_Config();
/* Enable the CPU Cache */
CPU_CACHE_Enable();
BaseType_t xReturned;
TaskHandle_t xHandle = NULL;
/* Create tasks /
xReturned = xTaskCreate(
Task_Code,
“SB”,
configMINIMAL_STACK_SIZE,
(void) NULL,
tskIDLE_PRIORITY+2U,
&xHandle
);
if( xReturned == pdPASS )
{
vTaskStartScheduler();
}
else
{
}
while(1);
Solved! Go to Solution.
2025-07-19 4:42 AM
Hi.
What should I do when I change like below?
#define SFU_ISOLATE_SE_WITH_MPU -> #undef SFU_ISOLATE_SE_WITH_MPU
Hardfault happens when I change like above.
2025-07-11 6:33 AM
Hello @EddiePark
Could you increase your heap and stack size and try again?
2025-07-11 7:06 AM
Hi,
I increase the heap and stack size. but the result is same.
Thanks
2025-07-11 8:03 AM
Hello @EddiePark
Please refer to the article below to debug hardfault:
How to debug a HardFault on an Arm® Cortex®-M STM3... - STMicroelectronics Community
2025-07-12 3:57 AM
From the screenshot it looks like SFU software is involved, and the hard fault is expected. Have you tried to continue and let it recover?
2025-07-12 4:30 AM
Hi.
I know what is problem for this issue.
But I don't know how to resolve this issue.
In case of normal, the api is called as the below.
Could you please let me know how to resolve this issue?
vTaskStartScheduler -> xPortStartScheduler -> vPortSVCHandler
void vPortSVCHandler( void )
{
__asm volatile (
" ldr r3, pxCurrentTCBConst2 \n"/* Restore the context. */
" ldr r1, [r3] \n"/* Use pxCurrentTCBConst to get the pxCurrentTCB address. */
" ldr r0, [r1] \n"/* The first item in pxCurrentTCB is the task top of stack. */
" ldmia r0!, {r4-r11, r14} \n"/* Pop the registers that are not automatically saved on exception entry and the critical nesting count. */
" msr psp, r0 \n"/* Restore the task stack pointer. */
" isb \n"
" mov r0, #0 \n"
" msr basepri, r0 \n"
" bx r14 \n"
" \n"
" .align 4 \n"
"pxCurrentTCBConst2: .word pxCurrentTCB \n"
);
}
But hard fault happens when SVC_Handler api is called in sfu_se_mpu.s file
===sfu_se_mpu.s======
.section .text,"ax",%progbits
.syntax unified
.weak MPU_SVC_Handler
.global SVC_Handler
.type SVC_Handler, %function
SVC_Handler:
MRS r0, PSP
B MPU_SVC_Handler
2025-07-12 5:03 AM - edited 2025-07-15 4:42 AM
Then there's some confusion between the SFU software you're using and FreeRTOS. I am not very familiar with SFU, perhaps it is not compatible with FreeRTOS, or assumes another flavor of FreeRTOS. In plain FreeRTOS the SVC handler vPortSVCHandler is invoked once, to start the scheduler. Here in sfu_se_mpu.s you have something different.
2025-07-13 5:36 PM
Hi.
In current, I use "STM32H753_SBSFU\Projects\NUCLEO-H753ZI" demo project.
I want to use xTaskCreate api from FreeRTOS.
so I apply freertos to demo project.
But vPortSVCHandler is not called in port.c of Freertos in when vTaskStartScheduler is called,
and hard fault happens "SVC_Hanlder" api is called in sfu_se_mpu.s
Is there any way to resolve this issue?
BRs.
Eddie Park
2025-07-15 4:46 AM
Yes this alone is easy to resolve: in FreeRTOS use some other unused interrupt vector instead of SVC. Not sure how this will interact with SFU.
2025-07-16 10:27 PM
Hi Pavel.
I am using "STM32H753_SBSFU" demo project which is downloaded from ST.
But I want to use xTaskCreate api of freertos in this demo project.
Hardfault happens as the below.
Could you please me know how to resolve this issue?