Quality RTOS & Embedded Software

 Real time embedded FreeRTOS RSS feed 
Real time embedded FreeRTOS mailing list 
Quick Start Supported MCUs PDF Books Trace Tools Ecosystem TCP & FAT Training




Loading

FreeRTOS STM32F429i-DISCOVERY HardFault

Posted by alexanderbaev on January 16, 2015

Dear friends. I have the following problem – my program ends in the HardFaultHandler. I use STM32F429i-discovery board. On the first place I took the demo project (CORTEXM4FSTM32F407ZG-SK). I substituted several files and managed to run the kernel. Then I changed something (I really do not remember what) – and the problem occurred. I tried to do everything from scratch – nothing changed. Then I took template project presented by ST and added I suppose all necessary files for FreeRTOS (again from the ST package). All the code works properly before vTaskStartScheduler(); (I just display test string on the lcd). I tried to use the code by Joseph Yiu and it helped me to determine the place in which the program goes to the HardFault. It is in the file – portcm4.c

portBASETYPE xPortStartScheduler( void ) { /* Make PendSV and SysTick the lowest priority interrupts. */ *(portNVICSYSPRI2) |= portNVICPENDSVPRI; *(portNVICSYSPRI2) |= portNVICSYSTICK_PRI;

/* Start the timer that generates the tick ISR.  Interrupts are disabled
here already. */
prvSetupTimerInterrupt();

/* Initialise the critical nesting count ready for the first task. */
uxCriticalNesting = 0;

/* Ensure the VFP is enabled - it should be anyway. */
vPortEnableVFP();

/* Lazy save always. */
*( portFPCCR ) |= portASPEN_AND_LSPEN_BITS;

/* Start the first task. */
vPortStartFirstTask();

/* Should not get here! */
return 0;

}

After stepping through return 0 – program goes to the HardFault. In the disassembly window returne 0 is represented by the following: MOVS R0, #0 POP {R1, PC}

The value in the register R1 (again thanks to Joseph Yiu program) which then is loaded to PC points to the empty region (B55F38B9) – if I determined correctly it is 512 MB Block 5 FMC.

What should I check next?

PS: Demo project of ST with FreeRTOS works great, but it has much more then I need, and when I tried to remove certain parts I finished with compilation problems. PPS. In the current project I had to add the following to the main.c module to pass the compilation: void EndIdleMonitor(void) { }

void StartIdleMonitor(void) { }

void vApplicationTickHook(void) { }

void vApplicationMallocFailedHook(void) { }

void vApplicationIdleHook(void) { }


FreeRTOS STM32F429i-DISCOVERY HardFault

Posted by rtel on January 16, 2015

You code should not return from the call to vPortStartFirstTask(); (the clue is on the next line, where the comment says "should not get here").

vPortStartFirstTask() calls SVC 0, and I am guessing your problem is related to not have an SVC handler installed.

Normally FreeRTOS uses vPortSVCHandler() as the SVC handler, which can be mapped to its CMSIS name using a #define as described on this page: http://www.freertos.org/FAQHelp.html

What is installed as the SVC handler? It might be an ST handler that needs to chain with the FreeRTOS handler, but I think you can just install the FreeRTOS handler outright.

Regards.


FreeRTOS STM32F429i-DISCOVERY HardFault

Posted by alexanderbaev on January 16, 2015

Thank you for the quick respond. The problem was exactly as you explained. What I did: 1) I added #define vPortSVCHandler SVCHandler #define xPortPendSVHandler PendSVHandler #define xPortSysTickHandler SysTickHandler to the FreeRTOSConfig.h file 2) Commented PendSVHandler, SysTickHandler, and SVCHandler in the stm32f4xx_it.c file. Did I do right?


FreeRTOS STM32F429i-DISCOVERY HardFault

Posted by rtel on January 16, 2015

Provided none of the ST libraries are relying on those handlers then that is fine.

Regards.


[ Back to the top ]    [ About FreeRTOS ]    [ Sitemap ]    [ ]




Copyright (C) 2004-2010 Richard Barry. Copyright (C) 2010-2016 Real Time Engineers Ltd.
Any and all data, files, source code, html content and documentation included in the FreeRTOSTM distribution or available on this site are the exclusive property of Real Time Engineers Ltd.. See the files license.txt (included in the distribution) and this copyright notice for more information. FreeRTOSTM and FreeRTOS.orgTM are trade marks of Real Time Engineers Ltd.

Latest News:

FreeRTOS V9.0.0 is now available for download.


Free TCP/IP and file system demos for the RTOS


Sponsored Links

⇓ Now With No Code Size Limit! ⇓
⇑ Free Download Without Registering ⇑


FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

Renesas Electronics Gold Alliance RTOS Partner.jpg

Microchip Premier RTOS Partner

RTOS partner of NXP for all NXP ARM microcontrollers

Atmel RTOS partner supporting ARM Cortex-M3 and AVR32 microcontrollers

STMicro RTOS partner supporting ARM7, ARM Cortex-M3, ARM Cortex-M4 and ARM Cortex-M0

Xilinx Microblaze and Zynq partner

Silicon Labs low power RTOS partner

Altera RTOS partner for Nios II and Cortex-A9 SoC

Freescale Alliance RTOS Member supporting ARM and ColdFire microcontrollers

Infineon ARM Cortex-M microcontrollers

Texas Instruments MCU Developer Network RTOS partner for ARM and MSP430 microcontrollers

Cypress RTOS partner supporting ARM Cortex-M3

Fujitsu RTOS partner supporting ARM Cortex-M3 and FM3

Microsemi (previously Actel) RTOS partner supporting ARM Cortex-M3

Atollic Partner

IAR Partner

Keil ARM Partner

Embedded Artists