Showing results for 
Search instead for 
Did you mean: 

STM32G030K6T6 FLASH MEMORY SIZE I am using a STM32G030K6T6 with ST32CubeIDE and HAL. Is there any way to reduce the flash memory usage? Need to reduce the fasl memory usage by 1kbyte.

Associate III
Lead II

Open the linker script - stm32????_FLASH.ld file

Reduce the FLASH size:

 FLASH   (rx)   : ORIGIN = 0x8000000,  LENGTH = 32K

- change from the default value (32K above) to whatever you want, like 31K

Principal III

set optimizer for size , -Os

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

If you need to use less you'll likely need to remove something or do it more efficiently.

Optimization for size might shrink it sufficiently.

Remove any floating point code/math where possible.

There's a free Keil compiler for STM32 CM0(+) devices, it might do a more aggressive job at code optimization or dead-code removal.

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


Is possible to use the Keil compiler with STM32CubeIDE? Any instructions on how to replace the toolchain would be helpful.



Hi @GErma.1​ ,

STM32CubeIDE is a toolchain like Keil. If your request is to generate code then compile it with Keil, so this is possible.

You need to use STM32CubeMX to generate code and you select Keil project as output.

May you explain why you need to switch from STM32CubeIDE to Keil?


To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

Associate III

The HAL Libraries are memory hogs. You can make a significant reduction by writing your own drivers "bare metal". As an example, my current project reads a message from a UART, and turns on (or off) the requested GPIO pin. Using the HAL Libraries the code (flash) size was 24K. Eliminaring the HAL Library calls, the code size was 4K.