cancel
Showing results for 
Search instead for 
Did you mean: 

How to change USBH_malloc

tekampe
Associate II
Posted on November 06, 2017 at 15:59

Hello,

I`m using the CubeMX 4.23 and want to use the HAL USB Driver. In the usbh:conf.h is the code:

/* Memory management macros */

&sharpdefine USBH_malloc malloc

&sharpdefine USBH_free free

&sharpdefine USBH_memset memset

&sharpdefine USBH_memcpy memcpy

But i want to use the FreeRTOS functions for malloc and free. So i changed the code to:

/* Memory management macros */

&sharpdefine USBH_malloc pvPortMalloc

&sharpdefine USBH_free vPortFree

&sharpdefine USBH_memset memset

&sharpdefine USBH_memcpy memcpy

This works fine, but as soon as i generate code with the CubeMX the change is gone. Is it possible to add something similar to the ffconf.h to the 

usbh:conf.h or make it configurable in the CubeMX?

/* define the ff_malloc ff_free macros as standard malloc free */

&sharpif !defined(ff_malloc) && !defined(ff_free)

&sharpinclude <stdlib.h>

&sharpdefine ff_malloc malloc

&sharpdefine ff_free free

&sharpendif

I hope you can help me with a solution 

#usb-fs #cube #cube-hal
3 REPLIES 3
tekampe
Associate II
Posted on December 18, 2017 at 16:40

No one?

Posted on December 18, 2017 at 18:27

 ,

 ,

Evidently...

Can't you find a USER section where you can add a ♯ undef/ ♯ define type construct?

How many times are you iterating through CubeMX? Can you sandbox the working code? Can you merge back in your changes?

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Posted on December 20, 2017 at 10:33

Yes, i could find a 

USER section where i can add a ♯ undef/ ♯ define type construct.

Because there is no USER section in the usbh_conf.h you would have to implement such an constrcut in the main.h, or somewhere else. But, IMHO i shouldn't need to, because the CubeMX should have a solution on board for this problem. The  ♯ undef/ ♯ define type construct would work, but it would be fairly ugly and not as easy to maintain as an other solution. Like for example for the ff_conf.h. 

I don't understand why the library doesn't have the ability to change the malloc defines.