cancel
Showing results for 
Search instead for 
Did you mean: 

Make use of the 64k CCM

jorgen2
Associate
Posted on January 11, 2012 at 11:08

I've spent (too many) hours trying to figure out how to use the CCM for something useful.

And with useful I mean easy access from my code written in C. I use GNU GCC, etc

(the Yagarto toolchain).

At first I thought that putting some variable, array into a specified section, let's call it .ccm, (and of course the appropriate lines in the linker script) would be the solution.

For example:

uint8_t test[1024] __attribute__ ((section(''.cmm'')));

Well, it works... Kind of... :\

I compiles and links nicely. Checking the memory map/dump of the generated ELF-file I see that the array is located @0x1000 0000

However, producing a binary image produces a LARGE 100+MB file. Doing a hex-file makes it smaller but will not load into ST-Link Utility (file too large to fit, it says)

Now... That's probably due to the gap between 0x1000 FFFF and 0x2000 0000

The part in the linker script is something like (under the SECTIONS part)

.ccm :

{

  .= ALING(4);

  *(.ccm)

  .= ALIGN(4);

} >CCMRAM

And CCM is defined under MEMORY as

  CCRAM    (rwx)      : ORIGIN = 0x10000000, LENGTH = 64K

Also tried to use NOLOAD to make it NOBITS instead of PROGBITS but it still takes

up space in the binary or hex-file. Removing the section with objcopy and --remove-section .ccm does nothing to help either.

Isn't there anyway of makeing your own section behave like the .bss section and not

taking space in the image?

I hope I make sense with my problem/question.

Best regards // J�rgen

#stm32-stm32f4-ccm-linker-section #gcc-linker-ccm
44 REPLIES 44
Posted on October 03, 2013 at 15:34

Like Jan says

I put it there because I had fun once with .bss when the compiler output a .bss.something object specific section and the startup code failed to clear it. This is perhaps less likely to occur with explicit use of .ccm, but nevertheless allows you to use .ccm.this and .ccm.that and see where space is going in the .MAP file.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
bluexav
Associate III
Posted on October 09, 2013 at 01:16

Thank you all for these hints !

I'm trying to use this CCM but it seems to work only for simple variables and not arrays and structures. Is it an alignement problem ?

Posted on October 09, 2013 at 02:56

array of structure of arrays, are you perhaps initializing them?

typedef struct _FOO {
int a[3];
int b[4];
int c[5];
} FOO;
FOO ccmFoo[1024] __attribute__ ((section(''.ccm'')));

.ccm 0x10000000 0xc000
0x10000000 . = ALIGN (0x4)
*(.ccm)
.ccm 0x10000000 0xc000 out/main.o
0x10000000 ccmFoo
*(.ccm.*)
0x1000c000 . = ALIGN (0x4)

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
bluexav
Associate III
Posted on October 09, 2013 at 18:18

Thanks for your answer !

Well they're not initialized. Compilation and linking are OK and the arrays appear as intended in the map file at the right place !  Dysfunctioning is at runtime.

It concerns only arrays (or structures with arrays). Those are global variables.

Posted on October 09, 2013 at 19:06

And it fails how exactly? Can you share a code example that demonstrates the failure?

CCM can't be used for DMA, and does not support bit-banding, or code execution.
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
jpeacock2399
Associate II
Posted on October 09, 2013 at 23:45

You might need to check the startup file where the C runtime is initialized.  Typically the runtime init is to copy a flash image to initialized RAM (.data section in SRAM) and then to zero the .bss section in SRAM.  You have to initialize your custom SRAM sections like .ccm with your own init code.

The C runtime init code usually does a block copy, which won't work with split SRAM address spaces using CCM.

  Jack Peacock
bluexav
Associate III
Posted on October 10, 2013 at 00:42

Thank you Jack !

It was definitly an initialization problem : filling my sound buffer with zeros during an init function solved the problem. I think I had no more sound because of bad datas in the buffer.

That's great, you all are great masters !!

atomassini
Associate II
Posted on September 02, 2014 at 02:42

Hello,

this was an interesting tip, but i cannot get the NOLOAD bit to work. If i don't use it, i see that on the compiled output i have my buffer out of .bss section, but as many wrote, i get that huge bin file. Putting the NOLOAD bit into the ld file, i get no errors from compiler or linker, the bin file generated has a reasonable size, but i see the .bss section grown by the size of my buffer, like it was placed back into this section. Why this? Here's the ccmram block descriptor, RAMB is defining the CCM ram area: Thanks .ccmram (NOLOAD) : { . = ALIGN(4); *(.ccmram) *(.ccmram.*) . = ALIGN(4); } > RAMB From: clive1 Posted: Wednesday, January 11, 2012 1:41 PM Subject: Make use of the 64k CCM

.ccm (NOLOAD) :
{
.= ALING(4);
*(.ccm)
.= ALIGN(4);
} >CCMRAM

[DEAD LINK /public/STe2ecommunities/mcu/Lists/cortex_mx_stm32/Flat.aspx?RootFolder=/public/STe2ecommunities/mcu/Lists/cortex_mx_stm32/Adding%20an%20uninitialized%20data%20section%20to%20a%20GCC%20build&FolderCTID=0x01200200770978C69A1141439FE559EB459D7580009C4E14902C3CDE46A77F0FFD06506F5B&currentviews=83]https://my.st.com/public/STe2ecommunities/mcu/Lists/cortex_mx_stm32/Flat.aspx?RootFolder=%2Fpublic%2FSTe2ecommunities%2Fmcu%2FLists%2Fcortex_mx_stm32%2FAdding%20an%20uninitialized%20data%20section%20to%20a%20GCC%20build&FolderCTID=0x01200200770978C69A1141439FE559EB459D7580009C4E14902C3CDE46A77F0FFD06506F5B¤tviews=83
Posted on September 02, 2014 at 03:06

Why this?

No idea, how can I replicate this? How are you directing data into the section? What could I learn from the .MAP file?

If data is going into the BSS section, then it's not going into the CCM one, you might want to look at the structures and attributes of the things that aren't going where you expect.
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
atomassini
Associate II
Posted on September 02, 2014 at 07:54

Here's how the array which should go to CCM is declared:

uint8_t netbuf[NETBUF_LEN] __attribute__((section(''.ccmram'')));

As written, without changing anything else, it seems that the array is going to CCM only if i do not activate the NOLOAD switch into the linker script.

I saw the linker file is somewhat sensible to spacing, so i copied exactly what you posted.

  .ccmram (NOLOAD) :

    {

        . = ALIGN(4);

        *(.ccmram)

        *(.ccmram.*)

        . = ALIGN(4);

    } > RAMB

when i compile the project with the linker configured as above, the array goes to bss

  .ccmram :

    {

        . = ALIGN(4);

        *(.ccmram)

        *(.ccmram.*)

        . = ALIGN(4);

    } > RAMB

In this case, array go to ccm.

The weird thing to me is that the compiler generates no error in the case when array is not allocated in ccm.

I'm not that gcc expert, but anyway i'm going to look into map file.