cancel
Showing results for 
Search instead for 
Did you mean: 

Store data in Flash at specific address

Daniel S
Associate II
Posted on January 31, 2017 at 10:23

I'm working with STVD and COSMIC compiler and I'm just trying to store data in flash at a specific location. What I've done up to now:

- Defining a new segement and section in STVD for the linker, specificed location for test issues should be 0xfff0 - 0xffff

-> My linker file has now an additional segment and section:

   # Segment test:

   +seg .testsection -b 0xfff0 -m 0x10 -n .testsection

Now I'm trying to add a constant value to this section, in this way (as COSMIC recommends):

#pragma section const {testsection}

const unsigned char variable = 0xAA;

const unsigned char variable2 = 0xBB;

#pragma section const {}

If I compile this everything works...but when I watch the end of the .s19 file (address 0xfff0 - 0xffff) everything is empty, where are my variables stored?

Does anyone has a hint?

6 REPLIES 6
luca239955_stm1_st
Senior II
Posted on January 31, 2017 at 11:09

Hello,

looks correct to me, what does the map file say ?

Regards,

Luca

Daniel S
Associate II
Posted on January 31, 2017 at 13:52

Hi Luca,

thanks for the answer,

My map file for the new section:

start 0000fff0 end 0000fff0 length     0 segment .testsection

length 0 and start and end address the same?

luca239955_stm1_st
Senior II
Posted on January 31, 2017 at 15:53

Hi,

I have done exactly the same thing and it works as expected for me:

start 0000fff0 end 0000fff2 length     2 segment .testsection

make sure there's no trivial problem (like you are linking something different from what you are compiling, like different directories or similar problems) and also that, in the linker file, the segment definition comes before the name of the object file that contains your special section.

Luca

Daniel S
Associate II
Posted on January 31, 2017 at 16:46

Hey Luca,

I add the new segment with STVD (Project->Settings->Linker->Input), did you add there any options?

0690X00000603NXQAY.jpg

I recompiled the whole project with STVD.

My Linker file:

0690X00000603afQAA.jpg

Based on this linker file the map file was generated:

0690X00000603U9QAI.jpg

This code was added in the main.c file as a global definition:

#pragma section const {testsection}

const unsigned char variable = 0xAA;

const unsigned char variable2 = 0xBB;

#pragma section const {}

But still the length of the testsection is 0?!

luca239955_stm1_st
Senior II
Posted on January 31, 2017 at 17:41

try to add a -k on the segment line in the linker file (through stvd or manually):

+seg .testsection -b 0xfff0 -m 0x10 -n .testsection -k

If it still does not work please share the whole lkf and map files, either here or on our support address (

mailto:support@cosmic.fr

)

Regards,

Luca

Posted on February 01, 2017 at 08:00

Hi Luca,

adding the option -k into section was the problem, together with this option it works.

Many thanks for the support

Best Regards

Daniel