cancel
Showing results for 
Search instead for 
Did you mean: 

BUG: CubeMX generates erroneous SVC and PendSV handlers with FreeRTOS

CubeMX selects and will not disable code generation for SVC and PendSV interrupts.

The generated empty ISR handlers in stm32f4xx_it.c conflict with FreeRTOS handlers:

0690X000009jK4OQAU.png

IOC is attached. This did not happen in other projects.

Windows 10, STM32CubeIDE Version: 1.0.2, Build: 3566_20190716-0927 (UTC)

@Markus GIRDLAND​ - Can you verify that you can reproduce and ticket opened?

Thanks, Best Regards, Dave

10 REPLIES 10
Markus GIRDLAND
ST Employee

This seems to be way more in the CubeMX side of things, @Nawres GHARBI​  any chance you could take a look at it?

@Nawres GHARBI​ - Have you had a chance to look at this?

Also, can you open a related ticket:

All generated empty handlers should be weak so customers can provide their own implementations without mucking with CubeMX regeneration.

This includes the above and similar handlers.

In your generated freertos.c file you already specifiy weak for hook functions, but you need to add weak to StartDefaultTask.

Thanks!

Best Regards, Dave

@Nawres GHARBI​ ? @Markus GIRDLAND​ ? Anybody there??

Hello @Dave Nadler​ 

Thanks for the feedback,

it will be fixed in the next STM32CubeMX release.

Best regards,

Nesrine

Hello @Dave Nadler​ 

Try to reproduce the same configuration on a new .ioc. You will no longer find an error message.

Best regards,

Nesrine

@Nesrine.JLASSI​ - What do you mean a new IOC ?

I have existing projects I need to work with.

Please STM, just fix the bug so generated code is correct!

Thanks,

Best Regards, Dave

ADunc.1
Senior

I too battled with this problem! It has not been fixed as of latest version. Here is my workaround for anyone else having this problem. At the top of your stm32xxxx_it.c file, add the following to effectively rename the auto generated functions. Then you can use the FreeRTOS defined ones in their place. It also will prevent STM32CubeMX replacing them on every code generation.

Even worse, is if you call the FreeRTOS pendSVHandler from inside the auto generated interrupts, you get stack corruption as FreeRTOS expects these handler to be called directly without wrapper functions that push onto the stack!

/* Private define ------------------------------------------------------------*/

/* USER CODE BEGIN PD */

void UnusedHandler1(void);

void UnusedHandler2(void);

#define PendSV_Handler UnusedHandler1

#define SVC_Handler UnusedHandler2

/* USER CODE END PD */

Hello @Dave Nadler​ 

Could you please provide us the procedures used to generate this .Ioc,

Please, try to disable the "Generate peripheral initialization as a pair of '.c/.h" function and tell me if it can solve the problem.

Regards,

Nesrine

@Nesrine.JLASSI​ , @Amel NASRI​ , @Camilo LEMOS​ - It is absolutely appalling that this is still not fixed after more than 6 months!

I just regenerated code using the attached IOC using CubeMX IDE 1.3, FW_F4 V1.24.2, and

it is still producing bogus non-weak SVC and PendSV handlers!

For heavens sake, get this fixed already!!

Really now!!!