cancel
Showing results for 
Search instead for 
Did you mean: 

assign predefined data to the FLASH arrey and put values STM32F207

Barbie
Associate II
Posted on December 23, 2012 at 10:30

Hello.

I try to put a 32 bit word in the FLASH section which need to get know value at programming and during the program it can be modify. In this way I can know next time I power up that this varible has beed update.

I use the IAR ARM 6.4.

I modify the link icf file this way:

/*♯♯&sharpICF♯♯♯ Section handled by ICF editor, don't touch! ****/

/*-Editor annotation file-*/

/* IcfEditorFile=''$TOOLKIT_DIR$\config\ide\IcfEditor\cortex_v1_0.xml'' */

/*-Specials-*/

define symbol __ICFEDIT_intvec_start__ = 0x08000000;

/*-Memory Regions-*/

define symbol __ICFEDIT_region_CONSTANT_start__ = 0x08004000;// change by Bar for placing constant in the FLASH

define symbol __ICFEDIT_region_CONSTANT_end__ = 0x0800BFFF; // change by Bar for placing constant in the FLASH

define symbol __ICFEDIT_region_ROM1_start__ = 0x08000000;  // for BOOTLOADER

define symbol __ICFEDIT_region_ROM1_end__   = 0x08003FFF;  // for BOOTLOADER

define symbol __ICFEDIT_region_ROM2_start__ = 0x0800C000;

define symbol __ICFEDIT_region_ROM2_end__   = 0x080FFFFF;

define symbol __ICFEDIT_region_RAM_start__ = 0x20000000;

define symbol __ICFEDIT_region_RAM_end__   = 0x20020000;

/*-Sizes-*/

define symbol __ICFEDIT_size_cstack__ = 0x400;

define symbol __ICFEDIT_size_heap__   = 0x200;

/**** End of ICF editor section. ♯♯&sharpICF♯♯♯*/

define memory mem with size = 4G;

define region ROM1_region   = mem:[from __ICFEDIT_region_ROM2_start__   to __ICFEDIT_region_ROM2_end__] ;  //-mem:[from __ICFEDIT_region_ROM1_start__   to __ICFEDIT_region_ROM1_end__];

define region VECTOR_region   =mem:[from __ICFEDIT_region_ROM1_start__   to __ICFEDIT_region_ROM1_end__];

define region RAM_region   = mem:[from __ICFEDIT_region_RAM_start__   to __ICFEDIT_region_RAM_end__];

define region CONSTANT = mem:[from __ICFEDIT_region_CONSTANT_start__ to __ICFEDIT_region_CONSTANT_end__ ];

define block CSTACK    with alignment = 8, size = __ICFEDIT_size_cstack__   { };

define block HEAP      with alignment = 8, size = __ICFEDIT_size_heap__     { };

initialize by copy { readwrite };

do not initialize  { section .noinit };

//place at address mem:__ICFEDIT_intvec_start__ { readonly section .intvec };

place in CONSTANT      {section .noinit};

place in ROM1_region   { readonly };

place in VECTOR_region { readonly section .intvec };

place in RAM_region    { readwrite, block CSTACK, block HEAP };

The idea is to leave the first section for startup and the bootloader, the second one for modify variable , the third for fix data like version ect. and from the 4th to the code.

And in the main file I write at the top before the main this:

             /* Sector 1, 16 Kbytes */

         /* the last know MCU Baud Rate */

&sharppragma location=0x08004000

__no_init volatile uint32_t Baud_Rate_USART=0;

I have 2 problems about it.

I can't see in the memory windows the FLASH area. Is it possible from the view menu?

I see that for FLASH assign I need to write no_init. SO how I can give it perleminary values because i see it doesn't?

Regards

Bar.

#variable-assign-to-flash
2 REPLIES 2
Posted on December 23, 2012 at 14:52

Well, you're not going to want to use noinit if you expect a value to be set.

The most sensible solution is to have code to identify the uninitialized state and to write default values. You could also write specific/calibration values during a final test procedure on the board. Placing all this in configuration structure, with a signature and checksum, is also something to consider.

I'd probably use ''const'' or ''static const'' to define at variable at a specific location, but modified outside of normal C functionality (ie a simple write is not possible)

const int baud @ 0x08004000 = 9600;

http://supp.iar.com/Support/?note=36121

Tips, buy me a coffee, or three.. PayPal Venmo Up vote any posts that you find helpful, it shows what's working..
Barbie
Associate II
Posted on December 23, 2012 at 17:06

Thanks for the answer.

I solve the init problem.

But I have anther problem.

Also I have define a special place for the CONSTANT  from  0x08004000 to 0x0800BFFF.

and the start up code from 0x08000000 to 0x08004000

and the code I ask to start from 0x0800C000 to 0x080FFFFF

here is the setting in link icf

/*###ICF### Section handled by ICF editor, don't touch! ****/

/*-Editor annotation file-*/

/* IcfEditorFile=''$TOOLKIT_DIR$\config\ide\IcfEditor\cortex_v1_0.xml'' */

/*-Specials-*/

define symbol __ICFEDIT_intvec_start__ = 0x08000000;

/*-Memory Regions-*/

define symbol __ICFEDIT_region_CONSTANT_start__ = 0x08004000;// change by Bar for placing constant in the FLASH

define symbol __ICFEDIT_region_CONSTANT_end__ = 0x0800BFFF; // change by Bar for placing constant in the FLASH

define symbol __ICFEDIT_region_ROM1_start__ = 0x08000000;  // for BOOTLOADER

define symbol __ICFEDIT_region_ROM1_end__   = 0x08003FFF;  // for BOOTLOADER

define symbol __ICFEDIT_region_ROM2_start__ = 0x0800C000;

define symbol __ICFEDIT_region_ROM2_end__   = 0x080FFFFF;

define symbol __ICFEDIT_region_RAM_start__ = 0x20000000;

define symbol __ICFEDIT_region_RAM_end__   = 0x20020000;

/*-Sizes-*/

define symbol __ICFEDIT_size_cstack__ = 0x400;

define symbol __ICFEDIT_size_heap__   = 0x200;

/**** End of ICF editor section. ###ICF###*/

define memory mem with size = 4G;

define region ROM1_region   = mem:[from __ICFEDIT_region_ROM2_start__   to __ICFEDIT_region_ROM2_end__] ;  //-mem:[from __ICFEDIT_region_ROM1_start__   to __ICFEDIT_region_ROM1_end__];

define region VECTOR_region   =mem:[from __ICFEDIT_region_ROM1_start__   to __ICFEDIT_region_ROM1_end__];

define region RAM_region   = mem:[from __ICFEDIT_region_RAM_start__   to __ICFEDIT_region_RAM_end__];

define region CONSTANT = mem:[from __ICFEDIT_region_CONSTANT_start__ to __ICFEDIT_region_CONSTANT_end__ ];

define block CSTACK    with alignment = 8, size = __ICFEDIT_size_cstack__   { };

define block HEAP      with alignment = 8, size = __ICFEDIT_size_heap__     { };

initialize by copy { readwrite };

do not initialize  { section .noinit };

place at address mem:__ICFEDIT_intvec_start__ { readonly section .intvec };

place in CONSTANT      {readonly section .data_init};

place in ROM1_region   { readonly };

place in VECTOR_region { readonly section .cstart };

place in RAM_region    { readwrite, block CSTACK, block HEAP };

I don't get it in the Memory map.

Attach the start of the map where you can see the reset vector start on 0x08000000 but immediate after it the code is writing.

''A1'':  place at 0x08000000 { ro section .intvec };

''P1'':  place in [from 0x08000000 to 0x080fffff] { ro };

''P2'':  place in [from 0x20000000 to 0x20020000] { rw, block CSTACK, block HEAP };

  Section            Kind        Address    Size  Object

  -------            ----        -------    ----  ------

''A1'':                                      0x184

  .intvec            ro code  0x08000000   0x184  startup_stm32f2xx.o [1]

                            - 0x08000184   0x184

''P1'':                                     0x478c

  .text              ro code  0x08000184  0x115c  APP_handle_main.o [1]

  .text              ro code  0x080012e0   0x1fc  TIM_APP_handle.o [1]

  .text              ro code  0x080014dc   0x7f8  ADC_DMA_APP_handle.o [1]

Where I wrong in the link icf file and what can be done to fix it?

Regards

Bar.