2019-05-08 12:19 AM
Hi !
I already had some checksum problems with older versions of COSMIC. They have been fixed by COSMIC.
btw; Do not set breakpoints inside code while running checksum functions...
Now I have a new issue:
STM8S207SB with modsl setting.
I like to use one of the build-in checksum functions. According to the manual, the section .cksum is inserted in linker settings. I use _checksum16(). It works as expected.
But:
If you insert a const section like
#pragma section const {version}... a part of the regular const area will be split and inserted into THIS section.
So now I have 11 bytes as my const vars in this section PLUS more than 200 bytes from "normal" const section according to the map file.
What happens now is, that the checksum area does NOT start behind my 11 bytes const values. Instead it starts 238 bytes behind 0x8080. This means that a part of the const area is NOT covered by checksum anymore. This seems be a bug (V4.4.7-4.4.9 - did not check with older versions).
I expected the following:
.version 11 Bytes
.const around 6000 bytes according to my app.
.text...
instead:
start 00008080 end 0000816e length 238 segment .version (but only 11 bytes as const defined in my file segment code in main.c)
start 0000816e end 000099c5 length 6231 segment .const (split, and segment version is filled up by 238-11 bytes)
start 00009a91 end 00014733 length 44194 segment .text
In the generated code I see my 11 bytes starting at 0x8080 as exptected. Behind this block I can see the rest of the const. But 238-11 additional bytes are in the first section.
Why is segment version too big? Should be only 11 bytes. As a result, the checksum function inside the linker only covers .const and .text starting at 0x816e missing the split part in front.
The issue remains even if I change the segment order or checksum function. I do not want to cover the version segment itself. I need the checksum around the regular const and text area.
If I use -ck for version segment, the whole area is covered. This is working fine. version segment still remains 238 bytes in this case.
Is there workaround for this? I use the SEMI AUTO configuration in STVD.
Do I miss a compiler flag?
Do I have to use custom settings instead to separate the version area with -b / -e?
Generating another SECTION with only 11 bytes gives an overflow. The linker always tries to build a size of more than 200 bytes for this segment.
2019-05-14 12:14 AM
Hello,
it's difficult to say where the problem might be based only on the explanation above: please send your .lkf and .map files to support@cosmic.fr so that we can take a look.
Regards,
Luca (Cosmic)
2019-05-23 01:18 AM
Thanks for your reply!
Problem solved: no linker issue.
Section was not closed properly:
#pragma section const {}
const was missing, leading to concatenated const segment... Makes sense now...
And linker then needs -k for this segment, otherwise my const values (12 bytes) will be removed (size 0).
start 00008080 end 0000808c length 12 segment .version_crc
start 0000808c end 000099c6 length 6458 segment .const
start 00009a94 end 0001473e length 44202 segment .text
Internal checksum16 function now reflects const and text segments as intended.