Memory Alignment on STM32

ChibiOS public support forum for all topics not covered by a specific support forum.

Moderators: RoccoMarco, lbednarz, utzig, tfAteba, barthess

brian360
Posts: 27
Joined: Wed Dec 08, 2010 5:47 pm
Location: Seattle, WA, USA

Memory Alignment on STM32

Postby brian360 » Thu Feb 24, 2011 1:54 am

Hi,

I was trying to do a call such as:

Code: Select all

chPoolFree(&mp, chCoreAlloc(512));


and was getting an assert failure. Upon further investigation, it looks like chCoreAlloc was returning memory alligned on 4 bytes rather than 8. It, in turn, seems to be doing that because the global variable __heap_base__ (from where nextmem is set) is set to an address of 0x20009f94 which doesn't seem to be aligned on 8 bytes.

Since I'm nothing close to an expert on linker files, what should I be modifying in ch.ld to fix this? Should I replace every instance of "ALIGN(4)" with "ALIGN(8)" in the whole file? Or just for the data (and/or bss) section?

I'm using the linker file as-is from the ARMCM3-STM32F107-GCC demo.

Thanks!

User avatar
Giovanni
Site Admin
Posts: 14458
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 1076 times
Been thanked: 922 times
Contact:

Re: Memory Alignment on STM32

Postby Giovanni » Thu Feb 24, 2011 9:03 am

Hi Brian,

I would add an ". = ALIGN(8);" just before "PROVIDE(end = .);". There is no need to align every section to 8 bytes.

I will add this issue to the tracker.

Giovanni

brian360
Posts: 27
Joined: Wed Dec 08, 2010 5:47 pm
Location: Seattle, WA, USA

Re: Memory Alignment on STM32

Postby brian360 » Thu Feb 24, 2011 6:20 pm

That was it. Thanks Giovanni.


Return to “General Support”

Who is online

Users browsing this forum: No registered users and 7 guests