cancel
Showing results for 
Search instead for 
Did you mean: 

STM32Cube Memory Usage

jon2
Associate II
Posted on September 03, 2014 at 19:43

I created a very simple project targetting a STM32F042K6 processor.  It includes a USB Device with CDC class as the only Middleware selected.  No other items are enabled.  When I go to compile the STM32Cube output in Atollic, the output cannot fit due to RAM overflow, by 1512 bytes.  This can't be right.  Can anyone tell me where to look for excess ram usage?

I am also getting this warning:

#warning ''Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)'' [-Wcpp]

5 REPLIES 5
Posted on September 04, 2014 at 11:35

Hi,

Thanks for the feedback. We understand that this is limitation that some of you are experiencing. We’ll pass it along to our STM32CubeMX team.

You have just to change your project properties following these instructions:

  • Right click on project > Properties
  • C/C++ build > Settings > Tool Settings tab
  • Assembler > Target and set Floating point to Software implementation
  • Do the same for C Complier, and C Linker

Once deactivation the FPU use, normally the stack usage will be reduced. Let's try it and keep us informed about your finding.

Regards.
jon2
Associate II
Posted on September 04, 2014 at 14:32

That fixed the warning, but the memory usage remains the same.  Any other ideas?

How much ram should I expect the USB Device with CDC to consume?  I see too 512 byte buffers in the CDC code, but nothing else looks substantial.

Posted on September 04, 2014 at 16:02

OK, good.

To reduce the example footprint, andsince only one allocation is handled in the CDC classdriver,the toolchain dynamic allocation is replaced by a static allocationby returning the address of a pre-defined static buffer with the CDC class structure size. You've only to define within the usbd_conf.h file:

#define MAX_STATIC_ALLOC_SIZE 140 

/*CDC Class Driver Structure size*/
#define USBD_malloc (uint32_t *)USBD_static_malloc
#define USBD_free USBD_static_free

And within the usbd_conf.cfile:

/**
* @brief static single allocation.
* @param size: size of allocated memory
* @retval None
*/
void *USBD_static_malloc(uint32_t size)
{
static uint32_t mem[MAX_STATIC_ALLOC_SIZE];
return mem;
}
/**
* @brief Dummy memory free
* @param *p pointer to allocated memory address
* @retval None
*/
void USBD_static_free(void *p)
{
}

For more details you can refer to the STM32CubeF3 firmware package available

http://www.st.com/web/catalog/tools/FM147/CL1794/SC961/SS1743/LN1897/PF260613?icmp=pf260613_****_nb_jun2014&sc=stm32cubef3-pr#

. Let's try it and keep us informed about your finding. Regards.
jon2
Associate II
Posted on September 04, 2014 at 19:10

Thanks, that worked.  However, now I am hitting a code-size limitation from Atollic Lite...  Ah well, off to look for another IDE/Compiler.

Posted on September 08, 2014 at 10:29

Great !

___________________________________________________________

Do, click ''

Mark as helpful post

'', if any of my replies helps solve your problem.