Locating a constant at a fixed Flash Location

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

Locating a constant at a fixed Flash Location

372 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by kcarolan on Tue Apr 01 06:43:56 MST 2014
I have found several post on Locating a constant at a fixed memory location.  The link below looked very promising.  Everything compiled great but my constant was not placed in the flash segment that I specified.  I must be missing something simple.

http://www.lpcware.com/content/faq/lpcxpresso/coderodata-different-flash-blocks

For an example I am trying to put 0x1234 at 0xFFFC
I have defined the Segment ChecksumSeq at 0xFFFE  ( See Map File output below)

__RODATA(ChecksumSeg) const int kevin= 0x1234;  This line is located in my File Called ManufacturingTest.c

Snipets from my Map File

Name             Origin             Length             Attributes
MFlash128        0x00000000         0x0000fffc         xr
ChecksumSeg      0x0000fffc         0x00000004         xr[/b]
MFlash128_64     0x00010000         0x00010000         xr
RamLoc8          0x10000000         0x00002000         xrw
RamPeriph2       0x20000000         0x00000800         xrw
SRAM1_2          0x20004000         0x00000800         xrw
*default*        0x00000000         0xffffffff

START GROUP
LOAD c:/nxp/lpcxpresso_6.1.2_177/lpcxpresso/tools/bin/../lib/gcc/arm-none-eabi/4.6.2/../../../../arm-none-eabi/lib/armv6-m\libcr_c.a
LOAD c:/nxp/lpcxpresso_6.1.2_177/lpcxpresso/tools/bin/../lib/gcc/arm-none-eabi/4.6.2/armv6-m\libcr_eabihelpers.a
END GROUP
                0x0000fffc                __top_MFlash128 = 0xfffc
                0x00010000                __top_ChecksumSeg = 0x10000
                0x00020000                __top_MFlash128_64 = 0x20000
                0x10002000                __top_RamLoc8 = 0x10002000
                0x20000800                __top_RamPeriph2 = 0x20000800
                0x20004800                __top_SRAM1_2 = 0x20004800

.text_Flash2    0x0000fffc        0x0
FILL mask 0xff
*(.text_Flash2*)
*(.text_ChecksumSeg*)
*(.text.$Flash2*)
*(.text.$ChecksumSeg*)
*(.rodata.$Flash2*)
*(.rodata.$ChecksumSeg*)


.rodata.$text_Flash2
                0x00008e90        0x4 ./src/ManufacturingTest.o
                0x00008e90                kevin

The constant 0x1234 end up at 0x8E90

Any ideas on what I am doing wrong?

Thanks, Kevin


0 Kudos
Reply
2 Replies

295 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by kcarolan on Tue Apr 01 11:08:12 MST 2014
Thanks for the lead.  It took a little modification from the example but it is now working.

Located in Source Code File
__attribute__ ((section(".myBuffer"))) const uint16_t myBuffer = 1234 ;


Added to the end of the SECTION part of the Linker Script File  (ProjectName.ld)

.myBuffer : ALIGN(4)
{ *(.myBuffer)
} > MyBufferFLASH


Create an new section in the Linker Script File

MEMORY
{
  MyBufferFLASH (rx) : ORIGIN = 0x7FFC, LENGTH = 0x4
}


Thanks, Kevin
0 Kudos
Reply

295 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by TheFallGuy on Tue Apr 01 07:53:32 MST 2014
That hasn't worked, because you have not told the linker to place RO_DATA anywhere different.

I suggest you look at this FAQ
http://www.lpcware.com/content/faq/lpcxpresso/placing-data-address
0 Kudos
Reply