2012-05-30 01:35 AM
I'm coding my 3rd testing project on stm8, to be exact in 2 different mcus, 103 and I'm using cosmic compiler, and i didnt have any problem with the previous 2 projects (because i didnt verify the size).
The problem is that binary files generated by cosmic linker are oversized,... I expain it.
Until now ( I have more than 25 years programming and 13 years in MCU's world) when you included functions and you didnt use them, the linker was able to remove them from final binary since they are not being used..., I say until now because cosmic compiler is not doing that.
In my 3rd testing project i wanted to create the bigger array in flash (with const char noname[***];, where *** is the size). What was my surprise when with a small code (about 10 lines my code, basically initializing ports and timers) the bigger table size that I was able to create in a 8kb flash stm8s103 was just 3.. I though then that i did something wrong so i started to do different tests...., I called my provider and he started to do his own tests, after a while we talked again and our conclusion was that COSMIC compiler doesn't remove unused functions.
To verify it, just create a cosmic project with stvd, then include for example in the project stm8_gpio.c, generate a map file (linker tab then output in category combobox). You will see a .map file generated and a line, something like:
start 0000909d end 0000a444 length 5031 segment .text
After that I edit the stm8s_gpio.c file and remove with a #if defined(XXXX) the function GPIO_ExternalPullUpConfig that i'm not using in my code, and i get:
start 0000909d end 0000a42c length 5007 segment .text
So basically it is including the function, even when I dont use it in the code
If you continue reading the programmer.map file in the first case you will see
_GPIO_ExternalPullUpConfig > 6 (6)
....
25 > _GPIO_ExternalPullUpConfig: (6)
...
_GPIO_ExternalPullUpConfig 00009f27 defined in Debug\stm8s_gpio.o section .text
Maybe the problem is that i'm using the 32kb limited version of the compiler but at least they can notice you this ''hidden feature'' when you get it.
#cosmic-linker-hidden-features2012-05-30 02:37 AM
Probably i have found it
Checking, I will comment if it worked2012-05-30 03:03 AM
Default cosmic compiler flags
start 00008080 end 0000908c length 4108 segment .const
start 0000909d end 0000a444 length 5031 segment .text
Setting compiling flag +split
start 00008080 end 00009080 length 4096 segment .const
start 00009091 end 000098e7 length 2134 segment .text
Still a bit oversized, but it is at least working. Anyways it is stupid to set as default the non-optimized flag....
2012-05-30 12:15 PM
>> I have more than 25 years programming and 13 years in MCU's world..
not a fast learner, are you ?2012-06-04 03:09 AM
:D
A lot of slow people :),.. or maybe compiler problem! :)[DEAD LINK /public/STe2ecommunities/mcu/Lists/STM8Discovery/Flat.aspx?RootFolder=/public/STe2ecommunities/mcu/Lists/STM8Discovery/text size overflow (1581) - cosmic&FolderCTID=0x01200200770978C69A1141439FE559EB459D7580004008F0975979A844820611B699DF2ED1]https://my.st.com/public/STe2ecommunities/mcu/Lists/STM8Discovery/Flat.aspx?RootFolder=%2fpublic%2fSTe2ecommunities%2fmcu%2fLists%2fSTM8Discovery%2ftext%20size%20overflow%20%281581%29%20%2d%20cosmic&FolderCTID=0x01200200770978C69A1141439FE559EB459D7580004008F0975979A844820611B699DF2ED12012-06-25 03:30 AM
Even not so bad after all: the Cosmic Compiler. I tested all the others (IAR, Raisonance), and found COSMIC-STM8-CX meeting most of my requirements.
BUT!!! I really agree with you: It would be in keeping with the times, that for the functions ''the linker is able to remove them from final binary since they are not being used...'' It should be a minor problem to Cosmic to integrate this feature. Btw: an earlier posted problem. See [DEAD LINK /public/STe2ecommunities/mcu/Lists/stm81/Flat.aspx?RootFolder=/public/STe2ecommunities/mcu/Lists/stm81/eliminate unused functions out of linked file&FolderCTID=0x01200200770978C69A1141439FE559EB459D7580001E3853D9DB932A46A3FE4CD15CAB46FB]unused_functionsRegards,
WoRo