Skip to main content
Associate
January 31, 2025
Solved

Patching STM32 FW package before build

  • January 31, 2025
  • 2 replies
  • 730 views

Hi!

I use STM32CubeIde + FreeRTOS + LWIP and quite often, especially for debugging, I change features through CubeMX. It causes reloading of several files that I would like to patch before build.  Examples are LWIP->tcpip.c or LWIP->cc.h.

I face an issue, that once they are reloaded, I need to apply changes manually. I looked into file templates, but it seems even worse idea to manipulate that. I know I could add my patched templates to the project, but it's some kind of CubeIDE feature I guess and could make it work properly. I'd like to just create a patch file and add "git apply" command to pre-build steps. However, it seems that reloading file from the Repository by CubeMX causes patch to be not relevant to the file since I get error that patch "does not apply". I used "git diff" for patch creation.

Any idea how to patch Repository files before building my application and maintain CubeMX "rebuild" functionality?

 

Best answer by TDK

You could run a post-build step that patches them. Pre-build doesn't seem useful.

TDK_0-1738331652620.png

 

If you want to use git to patch, look into why "git apply" is failing. Probably the --reject flag would give the desired result.

Git - git-apply Documentation

2 replies

TDK
TDKBest answer
Super User
January 31, 2025

You could run a post-build step that patches them. Pre-build doesn't seem useful.

TDK_0-1738331652620.png

 

If you want to use git to patch, look into why "git apply" is failing. Probably the --reject flag would give the desired result.

Git - git-apply Documentation

"If you feel a post has answered your question, please click ""Accept as Solution""."
OskarMeAuthor
Associate
January 31, 2025

Thanks, this is actually what I wanted. Putting a shell script into main folder and running after code generation patches files I needed.