cancel
Showing results for 
Search instead for 
Did you mean: 

Any way to lower RAM in order to add to FLASH?

SScot.3
Associate II

Hello All.

I am working on a small project for a friend while learning the STM32 environment.

The project is currently using a STM32F030x4 in a 20 pin TSSOP20.

I have committed a sin; I have run out of Flash Memory.

Is there any way to reduce the RAM allocation and move it to FLASH?

STM makes a chip with the same footprint and pinout with more memory (STM32F042x4) but no one has any stock.

Just curious if there is any 'dirty little secret' to doing this......

Regards to All,

Steve

12 REPLIES 12
TDK
Guru

No, RAM and FLASH are not interchangeable.

Make sure your optimization settings are turned up to full. That can buy you some space. You can example the map file to see what code is taking the most space and optimize it where possible.

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

Thanks! I figured but it was worth a shot just in case......

If your code was compressable, the tighter data in flash could be unpack to RAM to be run.

Watch for things like the floating point library, or sscanf() / sprintf() type functions eating a lot of space.

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

TDK, I have looked through CubeIDE and can't find the optimization area. Any pointers?

Tesla, I don't think I can compress any of it. I would like to half the RAM and put it in FLASH, oh well.

Ordered a few of the larger memory chips - who knows when they may show up.

Right click project -> Properties -> C/C++ Build -> Settings -> Tool Settings -> MCU GCC Compiler -> Optimization

> Ordered a few of the larger memory chips - who knows when they may show up.

Good luck. I haven't had any luck with STM32 chips getting sent early.

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

Holy Crap!

I gained some memory!

TDK I will have an Adult Beverage in your Honor (or 2) this evening!

I chose the Os method for space.

Cheers.
You can also use the Build Analyzer (Window -> Show View -> Build Analyzer) to see the exact breakdown of what's taking up space. It can be quite informative.
If you feel a post has answered your question, please click "Accept as Solution".
MM..1
Chief II

Warning i mean you miss x4 chips have 16k flash both. You need x6 x8 usw for more flash.

And if your code for 030 is over flash in gcc try KEIL , is little better and free for code less 32k

Uwe Bonnes
Principal III

Often the smaller chips like the f103x8 arelarger chip in disguise (f103xb) with the upper flash not tested but still available. Some tools may refuse to write above the announced flash. For a a hobby or low security approach, try to use the unannounced flash as a first test.