2017-01-31 01:23 AM
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 .testsectionNow 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?
2017-01-31 02:09 AM
Hello,
looks correct to me, what does the map file say ?
Regards,
Luca
2017-01-31 04:52 AM
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?
2017-01-31 06:53 AM
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
2017-01-31 07:46 AM
Hey Luca,
I add the new segment with STVD (Project->Settings->Linker->Input), did you add there any options?
I recompiled the whole project with STVD.
My Linker file:
Based on this linker file the map file was generated:
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?!
2017-01-31 08:41 AM
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
2017-02-01 12:00 AM
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