2014-09-29 02:38 AM
Hello,
I am using the STM32F3 Discovery Board to try out CubeMX for IAR and FreeRTOS.I have encountered the following situation, where the system hangs:SysTick_Handler
is never reached. The system hangs in theHardFault_Handler
.I have replaced the code inSysTick_Handler
as mentioned in the fora by ST employees to:if (xTaskGetSchedulerState() != taskSCHEDULER_NOT_STARTED)
{
xPortSysTickHandler();
}
HAL_IncTick();
but this is irrelevant, since the device branches to the
HardFault_Handler
before ever reaching theSysTick_Handler.
The solution I have found to this, is to comment out theosDelay(1)
line inStartThread
thread, or completely avoid using this thread.I have tested this with a single other thread, written by me and it works well.I will reply to this post, after testing with more threads.I do not know the true cause to this mishap, but I'd like to see this fixed since it's something that is given as a starting point for Discovery and Development Kits.Regards,George #freertos #cubemx2014-09-29 04:25 AM
Also tested this with 2 threads with thread messaging and delays.
All seem to work just fine. It seems that for some reason, the Cube generated thread caused problems.2014-09-30 01:12 PM
Hi,
have similar problem with F2 on custom board. Project generated by F2CubeMX for Keil MDK, only FreeRTOS included (and oscillator pins enabled), all RTOS setting on default values, no user code, and it does not work. On very first Systick called chain xPortSysTickHandler() - xTaskIncrementTick() and system is getting in Hard Fault. As I figured out on very first Systick pointer pxCurrentTCB is still not enabled (==NULL), and when it is used in xTaskIncrementTick() it causes HardFault error. That happened when FreeRTOS configured with both ''configUSE_PREEMPTION'' and ''configUSE_TIME_SLICING'' enabled. I added check for NULL before pxCurrentTCB accessed, and now it works #if ( ( configUSE_PREEMPTION == 1 ) && ( configUSE_TIME_SLICING == 1 ) ) { if (pxCurrentTCB != NULL) { ...... Would be interesting to hear from ST, is it some kind of bug of CubeMX, or I am missing something in FreeRTOS configuration? Thanks guys PS. CubeMX is great product!! even with such features2014-09-30 11:30 PM
Hello,
To be honest I am about to abandon FreeRTOS generated projects from CubeMX.I have tried to add more threads with messaging queues, but the code branches always to hard faults. I traced execution, and right now it hard faults before entering the scheduler, while runningMX_GPIO_Init()
. This is before running any User or RTOS code, so I can't figure out what's going on.Edit: Also changing compiler optimization produces hard faults in different places, before starting the scheduler.2014-10-08 04:57 AM
Hello,
There is an issue with the generated code that will be fixed in CubeMX 4.4. Modify the stm32f3xx_it.c generated file as follows:First add:
#include ''cmsis_os.h''
Second - add an if condition to call xPortSysTickHandler only once the scheduler has started:
void SysTick_Handler(void)
{ // Add this If condition (missing from MX 4_3_1 and earlier versions if (xTaskGetSchedulerState() != taskSCHEDULER_NOT_STARTED) { xPortSysTickHandler(); } HAL_IncTick(); }Please find attached a simple example.
Other recommendations are:
When using FreeRTOS functions from ISR the priority of interrupt should be lower (higher numerical value) than configMAX_SYSCALL_INTERRUPT_PRIORITY. Check heap and stack size (freeRTOS parameters in MX config tab), as well as your project heap/stack size (adjust within your IDE) Best Regards ________________ Attachments : simple_F3Disco_CubeMX_FreeRTOS_project.zip : https://st--c.eu10.content.force.com/sfc/dist/version/download/?oid=00Db0000000YtG6&ids=0680X000006HzXM&d=%2Fa%2F0X0000000bNE%2FhaHmGAub7pvqLxGTAEuZfBbOXfkBslNG9opyyywXPy0&asPdf=false2014-10-22 10:00 AM
Hi, George.
I think that faced with a similar problem ... All the matter in �?¡ubeMX. I use in conjunction with IAR 6.70.When re-generation project Cube does not include in the project file startup_stm32f373xc.s This does not always happen. Remarked casually.The project is compiled, but after the start in different places jumping to Hard Fault.Try to Generate project several times and open in you IDE.Maybe the problem is solved in 4.40, have not tried it.2014-11-06 01:17 AM
Solved through CubeMX 4.4.0