cancel
Showing results for 
Search instead for 
Did you mean: 

Cube MX: how to protect middleware or other code from overwritten if I wish to add peripheral driver

Riscy
Senior

As an example, I have added Segger System View to the FreeRTOS and decided to add (say) SPI HAL driver or modify the system clock from CubeMX from LL driver, how to make Cube MX aware I do not want to overwrite/update the FreeRTOS or similar code blocks?, any suggestion?. The FreeRTOS does not have all the protected domains, especially from the segger patch file.

3 REPLIES 3
Semer CHERNI
ST Employee

Hello @Community member​ 

First let me thank you for posting.

I want to start by asking you to be a little more clearer about the modification you have done which you want to protect.

If I am well understanding the question, you made modification to the FreeRtos middleware's file and you want to protect the modification when regenerating code with CubeMx.

Waiting for your feedback.

Kind regards,

Semer.

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

Riscy
Senior

Sorry for late reply, I have been busy of late. Yes, that is correct. I have looked into the backup code before changing as well as generating peripheral pairs within Code Generator, but they do not protect middleware. I have offloaded the non-CubeMX regulated code into another folder to preserve them so I can apply the CubeMX config change, but I need more protection options from middleware and alike.

Semer CHERNI
ST Employee

Hello @Community member​ 

Thanks for your reply.

What I want to say is that as you already know, the CubeMX tool will keep only the user code put between the "USER CODE BEGIN" and the "USER CODE END" comment in the files generated by the tool.

However, the drivers and middleware's source code files are not generated by CubeMX when generating the project; but they are copied from the firmware package.

So, whenever you make a modification for the middleware's files and regenerate the project, the tool will copy again those files from the FW pack and overwrite your modifications.

So, in this use case this is my advice:

  • Make a copy from the FW pack you want to use
  • Implement your modifications to the files in that made copy
  • In the CubeMX and under the [Project Manager]view go the Mcu and firmware Package and change the Firmware Relative Path to the one of the modified copy

Try this approach and give me your feedback.

Kind regards,

Semer.

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.