Cortex-M4 Hard Float ABI Issue

namcho wrote on Wednesday, February 24, 2016:

Hello,
I’m using stm32f429 which is cortex-m4 based also it has got **hardware FPU **unit. I’m using Eclipse Luna 4.4.2 with ARM GNU GCC C++ compiler and GNU-ARM plugin. The version of GNU GCC is 5_2-2015q4.

I’m choosing GCC/ARM_CM4F as porting files and my freertos version is 8.2.3.
The completion is done without any errors but in run-time when I trying to create any task and let it to start than program suddenly goes into HardFault_Handler().

Here is my simple code:

static LedClass led1(LED1, 300), led2(LED2, 600);

int
main(int argc, char* argv[])
{
  HAL_Init();

  /* Configure the system clock */
  SystemInit();
  SystemClock_Config();

  MX_GPIO_Init();

  led1.Create("LED1", configMINIMAL_STACK_SIZE, 1);
  led2.Create("LED2", configMINIMAL_STACK_SIZE, 1);
  FreertosAbstract::PortSysTickHandler();
  
  while(1){
	  //Error handler
  }
}
/*
 * @brief         : 1ms systick timer
 */
void SysTick_Handler(void)
{
	HAL_IncTick();
	FreertosAbstract::PortSysTickHandler();
}

The problem occurs after PortSysTickHandler() function was executed.
Here is the other simple code which is working well: Leds are blinking…

int
main(int argc, char* argv[])
{
  HAL_Init();

  SystemClock_Config();

  MX_GPIO_Init();
  
  led1.Create("LED1", configMINIMAL_STACK_SIZE, 1);
  led2.Create("LED2", configMINIMAL_STACK_SIZE, 1);
  //FreertosAbstract::TaskStartScheduler();
  
  while(1){
      HAL_Delay(100);
      led1.LedOff(LED1);
      HAL_Delay(200);
      led1.LedOn(LED1);
  }
}
/*
 * @brief         : 1ms systick timer
 */
void SysTick_Handler(void)
{
    HAL_IncTick();
//  FreertosAbstract::PortSysTickHandler();
}

Other problemed example is:

int
main(int argc, char* argv[])
{
  HAL_Init();

  SystemClock_Config();

  MX_GPIO_Init();
  
  led1.Create("LED1", configMINIMAL_STACK_SIZE, 1);
  led2.Create("LED2", configMINIMAL_STACK_SIZE, 1);
  //FreertosAbstract::TaskStartScheduler();
  FreertosAbstract::PortSysTickHandler();  //Program is going to HardFault after this statement

  while(1){
      HAL_Delay(100);
      led1.LedOff(LED1);
      HAL_Delay(200);
      led1.LedOn(LED1);
  }
}
/*
 * @brief         : 1ms systick timer
 */
void SysTick_Handler(void)
{
    HAL_IncTick();
//  FreertosAbstract::PortSysTickHandler();
}

So the problem’s cause is the xPortSysTickHandler() function.

Compiler Settings are:
Float ABI: FP Instruction hard
FPU Type: fpv4-sp-d16

I can share my whole code if necessary.

rtel wrote on Wednesday, February 24, 2016:

The problem occurs after PortSysTickHandler() function was executed.

Please place a break point on that line, then step through the code to see at which point the hard fault is triggered. It may also be possible to use the technique described on this link: Debugging and diagnosing hard faults on ARM Cortex-M CPUs to get additional information.

I note you are using a C++ wrapper, which will not of come from us, so people reading the post will first assume there is a problem there, and will not be able to support that directly as its unknown code. You can also try using the native API without the wrapper, or obtaining support whoever supplied the wrapper.

namcho wrote on Wednesday, February 24, 2016:

Okay there is no problem about freertos with hard fpu compiling. I created new project than has made simple demo, it has worked well with and without wrapper class.

Still I dont know why my first demo wasn’t worked. I have to look deeper to find out the root reason. Anyway thanks for allowed time to me have nice days.