Skip to main content
moredatalesscenter
Associate III
July 30, 2020
Question

Preserving manual code in OSWrappers and TouchGFXConfiguration upon CubeMX code generation?

  • July 30, 2020
  • 5 replies
  • 1172 views

Is there a way to preserve user code in OSWrappers.cpp and TouchGFXConfiguration.cpp, similar to the usual  /* USER CODE BEGIN 1 */  /* USER CODE END 1 */ comment blocks?

Using RTOS: Custom and regenerating overwrites everything. I've tried copying the wanted code into to a second file and excluding or removing the generated files from IAR, but it's restored after regenerating, causing linker duplication errors.

This topic has been closed for replies.

5 replies

Alexandre RENOUX
Visitor II
July 31, 2020

Hello,

No OSWrappers.cpp and TouchGFXConfiguration.cpp are complete generated files so it's not possible to overwrite them. But normally you should not need to change them.

But if it's enough, you can write code in TouchGFXHAL.cpp. Indeed, void touchgfx_init() in TouchGFXConfiguration.cpp calls hal.initialize() that will then call void TouchGFXHAL::initialize().

/Alexandre

moredatalesscenter
Associate III
July 31, 2020

It's mainly OSWrappers that's the problem, as I am using a custom RTOS configuration - making equivalent calls as used in the FreeRTOS configuration, but these are overwritten upon code generation. I would have expected custom to allow just that - use my code.

Alexandre RENOUX
Visitor II
August 18, 2020

OSWrappers.cpp will be regenerated everytime you regenerate with CubeMX.

One solution would be to not regenerate with CubeMX after your setup is done.

I will discuss with the team if we should add USER CODE sections in this file and I will let you know when something is decided and scheduled.

/Alexandre

moredatalesscenter
Associate III
August 18, 2020

That's not a solution though. I think user sections would make most sense, possibly only if custom RTOS is selected in CubeMX.

Is there any way of knowing what upcoming bug fixes and features being considered are, and the roadmap for releases will be?

Alexandre RENOUX
Visitor II
August 21, 2020

Hello,

I discovered something, sorry for the late answer.

If you choose Custom in CubeMX for your OS. You will have an OSWrappers.cpp generated with USER CODE sections.

The trick is that this new file is placed in TouchGFX/target and not in TouchGFX/target/generated because now it is not a file that will be modified by CubeMX or TouchGFX giving the fact that you chose Custom. The problem is that the OSWrapper.cpp in the generated folder is not deleted so you must delete this one and only consider the one in TouchGFX/target.

I hope this will help you.

/Alexandre