Skip to main content
Dave Nadler
Senior III
September 26, 2019
Question

BUG: CubeMX generates erroneous SVC and PendSV handlers with FreeRTOS

  • September 26, 2019
  • 9 replies
  • 4873 views

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

This topic has been closed for replies.

9 replies

Markus GIRDLAND
ST Employee
September 27, 2019

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

Dave Nadler
Senior III
September 27, 2019

@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

Dave Nadler
Senior III
October 8, 2019

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

Nesrine.JLASSI
Visitor II
October 11, 2019

Hello @Dave Nadler​ 

Thanks for the feedback,

it will be fixed in the next STM32CubeMX release.

Best regards,

Nesrine

Nesrine.JLASSI
Visitor II
October 14, 2019

Hello @Dave Nadler​ 

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

Best regards,

Nesrine

Dave Nadler
Senior III
October 14, 2019

@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
March 16, 2020

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 */

Nesrine.JLASSI
Visitor II
March 24, 2020

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

Dave Nadler
Senior III
March 30, 2020

@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!!!

Nesrine.JLASSI
Visitor II
May 4, 2020

Hi @Dave Nadler​ 

Thanks for the feedback,

It will be fixed next STM32CubeMX version.

Best regards,

Nesrine