how to allocate an area from internal flash to store private user data in CodeWarrior2.x

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

how to allocate an area from internal flash to store private user data in CodeWarrior2.x

716 Views
plabgh
Contributor I

Hi,

 

If my 'inernal_flash' length is 1M, i want to allocate 100K memory from 'internal_flash' to store private user data.

Complier and linker can't use the 100K area to store hardware initialization routines, application code, constants and so on.

how should i modify the .lcf file ?

I consider that whether only modify length of 'internal_flash' segment from 1M to 924K in .lcf file ?

The 'internal_flash' segment defined in a MEMORY directive is used to to store sections .init, .text, .rodata, .ctors, .dtors, extab, extabindex and so on.

what operation I need to carry out for .lcf file ?

1、whether i need use .lcf file's MEMORY directive to associate a name 'myrom' for the 100K area ?

2、And then whether i need use .lcf file's SECTIONS directive to define a section which will be loaded in the memory area named 'myrom' ?

3、Finally, using #pragma and __declspec() directives to specify private user data write to specific section in source file ?

The 100K area is used to store all global variable value of CW every 60 seconds by flash_write driver function. After power-on startup, using flash_read driver function to read these global variable value which are stored in the 100K area last time. After the reading of global variable value, respectively assigning these read vlaue to global variable of CW project in order.

Could you tell me how to implement the feature ?

 

PS:

flash_read and flash_write driver functions are linked into 'inernal_flash' segment.

The 100K area can only be used to store all global variable value of CW project, not object code or/and other data.

Labels (1)
0 Kudos
4 Replies

472 Views
TICS_Fiona
NXP Employee
NXP Employee

Hi

To place your data in a specific memory area, you need to define a new section, and allocate memory area for it in link command file, like below:

in the C file :

#pragma section RW ".NM_CONST" ".NM_CONST"

__declspec(section ".NM_CONST" )

static const UINT8 NM_BIT_BYTE_POS[NM_NUM_BITS_IN_BYTE] =

{

    0x80, 0x40, 0x20, 0x10, 0x08, 0x04, 0x02, 0x01

} ;

with this added to the LCF file:

SECTIONS

{

......

  GROUP:{

        .NM_CONST (CONST) LOAD (ADDR(nm_const_flash)) : {}

    }> nm_const_flash

......

}

The application note in the link below should also be helpful:

http://cache.freescale.com/files/soft_dev_tools/doc/app_note/AN4497.pdf

Hope it helps!

Fiona Kuang

Technical Information & Commercial Support

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

Note: If this post answers your question, please click the Correct Answer button. Thank you!

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

0 Kudos

472 Views
plabgh
Contributor I

Hi, Xin Kuang.

Thank you for your answer.

I want to know:

1、Whether I can only use #pragma and __declspec() directives to store all global variable value of CW per minute into the section .NM_CONST, not using the flash_write driver function ?

2、Whether it is allowed to change the element value of "static const  UINT8 NM_BIT_BYTE_POS[NM_NUM_BITS_IN_BYTE]" which will be linked into the section .NM_CONST  ? Because I want to updata their values per minute.

3、Whether I can directly read their values of "static const  UINT8 NM_BIT_BYTE_POS[NM_NUM_BITS_IN_BYTE]", not using  the flash_read driver function ?

Tks.

0 Kudos

472 Views
BlackNight
NXP Employee
NXP Employee

Hello,

I'm using Processor Expert to store data into on-chip flash at runtime, see

Configuration Data: Using the Internal FLASH instead of an external EEPROM | MCU on Eclipse

You say you want to write data every minute: in that case make sure you consider the flash wear-out (flash erase cycles).

The number of flash erases is limited by the flash technology used in your device.

I hope this helps,

Erich

0 Kudos

472 Views
plabgh
Contributor I

Hi, Erich Styger

I have never attempted to program the internal flash using Processor Expert Component, so i'm not familiar with this tool.

Whether there are any other methods or ideas to solve the problem through modifying .lcf file ?

0 Kudos