STM32F405 Default Memory Mapping

C programming, build, interpreter/VM.
Target audience: MicroPython Developers.
Post Reply
User avatar
tstenvold
Posts: 3
Joined: Mon Dec 27, 2021 1:45 pm

STM32F405 Default Memory Mapping

Post by tstenvold » Sun Apr 24, 2022 5:00 pm

While looking for ways to reduce memory usage on the STM32F4 chip, I discovered that MicroPython was only accessing 128K of the total 192K. Which at first confused me until I dug deeply and read in the chip specification about the 64K of CCM memory.

After some testing based on the ideas from reading this post , I changed the memory mapping to have the stack contained in the CCM portion of memory instead. This appears to work without issue.

My question is, should this be changed to be the default on this chipset, as it saves 16K of RAM, or is there a specific reason why this is a bad idea that I'm not aware of?

User avatar
dhylands
Posts: 3821
Joined: Mon Jan 06, 2014 6:08 pm
Location: Peachland, BC, Canada
Contact:

Re: STM32F405 Default Memory Mapping

Post by dhylands » Mon Apr 25, 2022 5:39 pm

The 64K of CCM memory is used when micropython needs to read/write from the flash file system.

Your stack will be ok until micropython needs to use all 64K (which will happen when it needs to update a 64K flash block) and then your program will die in a somewhat unpredictable manner.

This is where the symbols are created:
https://github.com/micropython/micropyt ... ld#L32-L33

And this is the code that uses them:
https://github.com/micropython/micropyt ... .c#L44-L50

Post Reply