cancel
Showing results for 
Search instead for 
Did you mean: 

FLASH MEMORY FULL

NKaur.1
Associate II

I am using STM32L011K4 with 16KB flash memory. I did simple code to implement I2C ,timer with PWM. But I have issue of memory overflow.

I have enabled following:

void SystemClock_Config(void);

static void MX_GPIO_Init(void);

static void MX_I2C1_Init(void);

static void MX_TIM2_Init(void);

What should I do?

6 REPLIES 6
TDK
Guru

Enable optimization by selecting the Release configuration rather than Debug.

Remove unnecessary or optimize existing code.

Reduce the heap and stack sizes to minimum required.

HAL isn't really build to run on chips with only 16kB of flash.

If you feel a post has answered your question, please click "Accept as Solution".
NKaur.1
Associate II

Thanks for reply. Where is Release configuration option in stm32CubeIDE? Also, if I don't use HAL then what should use?

Project -> Build Configuration -> Set Active -> Release.
You can access registers directly. Reference manual explains how they work. ST doesn't publish register-level examples, but some can be found online.
If you feel a post has answered your question, please click "Accept as Solution".
NKaur.1
Associate II

I will try assessing through registers. Does it matters in the terms of memory space if microcontroller is 32bit, 16bit or 8 bit. Does 32bit microcontroller's flash memory gets full faster than 16bit or 8bit? I am using 32bit micro, may be that's why it gets full faster? Every word takes 32bit. Am I correct?

16KB isn't a lot of memory, floating point libraries will also eat a lot of space.

Keil might do a more efficient job, ST has a free Keil license for STM32 Cortex-M0(+) parts.

Still you might actually have to get involved in the coding task rather than expecting Cube / HAL to be the best fit. You might want to optimize the code to reflect the specific use case rather the the general use case with all possible options available/supported.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..

Most of the thumb instructions are 16-bit wide, but operate on data/registers which are 32-bit wide. The trade-off vs old 8-bit MCU is that it can typically do more math with each instruction so needs less of them.

Code and Data size tends to get consumed faster, especially with compilers and libraries

I picked the L011 due to their small physical size, MAXIM has some small CM4F parts with more memory that I'd probably chose in retrospect, as everyone wanted diagnostic and configuration options.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..