CCM data RAM of STM32F405

General discussions and questions abound development of code with MicroPython that is not hardware specific.
Target audience: MicroPython Users.
Post Reply
inaugurator
Posts: 23
Joined: Tue Sep 30, 2014 4:02 pm

CCM data RAM of STM32F405

Post by inaugurator » Sat Nov 29, 2014 10:16 am

Hi,
STM32F405 have 64 kbyte of CCM data RAM. As I understand, this is special RAM, and only CPU accessing to it. How micropython uses this memory? Why is it so big (1/3 of RAM)? Is it possible to relocate, for example, UART cache here? May I use it in someway?
Thanks.
Evgeny

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

Re: CCM data RAM of STM32F405

Post by dhylands » Sat Nov 29, 2014 6:08 pm

Currently, I believe that its being used by the flash driver.

The internal flash file system has a 64K block in it. In order to rewrite that block, you need to read the 64K block into memory, make your modifications, erase the block in flash, and then write flash block back out.

https://github.com/micropython/micropyt ... rage.c#L40

inaugurator
Posts: 23
Joined: Tue Sep 30, 2014 4:02 pm

Re: CCM data RAM of STM32F405

Post by inaugurator » Sat Nov 29, 2014 8:22 pm

Thank you.
But what about writing on sd card? I found that some flashes have 128 kbyte blocks.
Evgeny

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

Re: CCM data RAM of STM32F405

Post by dhylands » Sun Nov 30, 2014 5:24 am

Writing to the sdcard just requires enough for a single block (or maybe a cluster). It should be less than 64K. The flash blocks

The pyboard flash has 4 x 16K, 1 x 64K, and the remainder are 128K.

The internal flash storage is stored on 3 of the 16K + the 64K which is where the 112K comes from, and we don't have enough RAM to support putting any of the 128K blocks into the storage area.

If you were to disable the internal storage area, then I think that the 64K could be used for other purposes (as long as it isn't being used as cache for the sdcard).

inaugurator
Posts: 23
Joined: Tue Sep 30, 2014 4:02 pm

Re: CCM data RAM of STM32F405

Post by inaugurator » Sun Nov 30, 2014 12:50 pm

Is it possible to add option in boot.py, so that micropython may use CCM as part of RAM (with read-only mode for internal flash), when I use only external Micro SD? I think it could be efficient for some scripts.
Evgeny

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

Re: CCM data RAM of STM32F405

Post by dhylands » Sun Nov 30, 2014 4:45 pm

There currently isn't any such option.

inaugurator
Posts: 23
Joined: Tue Sep 30, 2014 4:02 pm

Re: CCM data RAM of STM32F405

Post by inaugurator » Sun Nov 30, 2014 6:08 pm

Ok. I hope it will be implemented in the future.
Thank you.
Evgeny

pfalcon
Posts: 1155
Joined: Fri Feb 28, 2014 2:05 pm

Re: CCM data RAM of STM32F405

Post by pfalcon » Fri Jan 23, 2015 5:18 pm

The issue is that current garbage collection implementation in uPy requires continuous heap. So, there're 2 steps to make use of CCM:

1. Refactor current GC implementation so it was more pluggable, and can be replaced with another implementation(s).
2. Write GC implementation supporting CCM.

Interested users are welcome to contribute to both areas. Otherwise, you can just treat CCM as reserved memory available only to drivers (you can also write your own driver using it for its needs, after making sure that usage doesn't conflict with other drivers).
Awesome MicroPython list
Pycopy - A better MicroPython https://github.com/pfalcon/micropython
MicroPython standard library for all ports and forks - https://github.com/pfalcon/micropython-lib
More up to date docs - http://pycopy.readthedocs.io/

Damien
Site Admin
Posts: 647
Joined: Mon Dec 09, 2013 5:02 pm

Re: CCM data RAM of STM32F405

Post by Damien » Fri Jan 23, 2015 8:52 pm

One issue is that machine code cannot be executed from CCM, so it can only hold bytecode functions.

CCM could hold the stack, freeing up some of the main RAM.

On the user side of things, could add an option to pyb.mount to remount the flash readonly. Doing this would then repurpose the CCM for heap or stack.

Post Reply