cancel
Showing results for 
Search instead for 
Did you mean: 

Definition of array in flash CoIDE (arm-none-eabi-gcc)

M_1
Associate II
Posted on December 02, 2013 at 16:00

Hi there! I need to define array of fonts in flash.

I'm using STM32F417VG MCU I define it as

const u8 font1[]

But compiler places it in RAM I've found a linker file that Coocox uses to link my project.

OUTPUT_FORMAT (''elf32-littlearm'', ''elf32-bigarm'', ''elf32-littlearm'')
/* Internal Memory Map*/
MEMORY
{
rom (rx) : ORIGIN = 0x08000000, LENGTH = 0x00080000
ram (rwx) : ORIGIN = 0x20000000, LENGTH = 0x00020000
ram1 (rwx) : ORIGIN = 0x10000000, LENGTH = 0x00010000
}
_eram = 0x20000000 + 0x00020000;
/* Section Definitions */ 
SECTIONS 
{ 
.text : 
{ 
KEEP(*(.isr_vector .isr_vector.*)) 
*(.text .text.* .gnu.linkonce.t.*) 
*(.glue_7t) *(.glue_7) 
*(.rodata .rodata* .gnu.linkonce.r.*) 
} > rom
.ARM.extab : 
{
*(.ARM.extab* .gnu.linkonce.armextab.*)
} > rom
__exidx_start = .;
.ARM.exidx :
{
*(.ARM.exidx* .gnu.linkonce.armexidx.*)
} > rom
__exidx_end = .;
. = ALIGN(4); 
_etext = .;
_sidata = .; 
.data : AT (_etext) 
{ 
_sdata = .; 
*(.data .data.*) 
. = ALIGN(4); 
_edata = . ;
} > ram
/* .bss section which is used for uninitialized data */ 
.bss (NOLOAD) : 
{ 
_sbss = . ; 
*(.bss .bss.*) 
*(COMMON) 
. = ALIGN(4); 
_ebss = . ; 
} > ram
/* stack section */
.co_stack (NOLOAD):
{
. = ALIGN(8);
*(.co_stack .co_stack.*)
} > ram
. = ALIGN(4); 
_end = . ; 
} 

What shoul I paste to make compiler place it in FLASH? Directive

__attribute__ ((section(''.text''),used))

causes an ignoring warning I tried to google all day long but found no simple answer how to do it. Thanks #flash-array-coide-coocox
4 REPLIES 4
Posted on December 02, 2013 at 17:10

Perhaps something better asked of CooCox, they don't do much support here.

I'm not sure how/where you are defining this, I'd be using

static const unsigned char Font[] = { 0x01, 0x02, 0x03 };

with global scope, and checking the .MAP file to see what section was being assigned.

Your problem did sound familiar, and did some Googling myself

https://my.st.com/public/STe2ecommunities/mcu/Lists/cortex_mx_stm32/Flat.aspx?RootFolder=https://my.st.com/public/STe2ecommunities/mcu/Lists/cortex_mx_stm32/How%20to%20Store%20Font%20Table%20in%20Flash%20with%20GCC&FolderCTID=0x01200200770978C69A1141439FE559EB459D7580009C4E14902C3CDE46A77F0FFD06506F...

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
M_1
Associate II
Posted on December 02, 2013 at 19:17

I've read this topic but it didn't help me =(

I wrote like you've adviced me but still got build failure by ram overflow

Posted on December 02, 2013 at 22:55

Well you'll need to be more generous with details here if you want me help, the .MAP should be helpful in understanding where that data is being placed, and perhaps why. Is it possible that the linker is using a different script?

Try to generate a small example that illustrates the problem, or shrink the allocation so it fits in RAM for test purposes.
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
M_1
Associate II
Posted on December 03, 2013 at 09:48

I'm sorry. Everything works as you describe. I forgot to add ''const'' word to the two largest fonts in my program.

But there is one more issue: I found out that compiler doest't use ram1 memory (according to the .ld file and to the .map file) How can I use it? As I clearly understand, only DMA won't be abaliable for it?