Skip to main content
Associate III
Question

STVisual Develop building libraries

I have a very simple main using UART1 and already my application is 7kB!  The web implies that this is because I am getting a lot of UART1 and CLK code built and linked in that I am never using.  One suggestion is to split the UART1 and CLK files into individual "one file per method" codebases, build a library, and then when my application links it will pull in only those methods that I am actually using.

However I cannot see how to configure a project to build a library instead of an image.  Could someone point me an example of how to do this please?

    This topic has been closed for replies.

    7 replies

    AA1
    Senior III

    I think you are using COSMIC compiler. COSMIC linker can remove unused code even without a library and without split the code into individual files "one file per method". Read COSMIC manual.

    Use +split compiler option to create a separate sub-section per function. To create a library use clib utility.

    How do you know your application uses 7KB of FLASH?

    Associate III

    Thanks for the COSMIC tip - I will go and look.

    The 7KB value came from the size of the resulting `s19` file.  For comparison, having not yet checked out your suggestions but having `#defined` out UART functions that I am not using, the `s19` file is now 2.4kB.

    Am I misunderstanding how the size of these `s19 files relates to the about of flash used for store the program on the stm8s?  I'm new to these processors.

    Thanks.

    AA1
    Senior III

    s19 file is not a binary file. s19 file size if more than twice the code size.

    You can see code size in map file.

     

    Associate III

    Another newbie question.  I have enabled `+simple` at compile time but the linker requires me to also enable `-k` against a segment.  I was hoping to find a compile time macro that would allow this but didn't find one so in the context of the STVD IDE, how do I do this?

    Thanks.

    AA1
    Senior III

    I don't know '+simple' compiler option. Maybe you want '+mods0' compiler option.

     

    Associate III

    Bother - I meant `+split`.

    Associate III

    What I did with this was...

    - Added `+split` to the compiler options

    - Added `-k` to the linker segment options for the `.const` segment.

    This seem to have done the trick as the mapfile now contains likes like this:

    _UART1_ClearFlag ******** *** removed from Debug\stm8s_uart1.o ***