Skip to main content
Graduate
March 23, 2024
Question

STVisual Develop building libraries

  • March 23, 2024
  • 3 replies
  • 1802 views

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.

    3 replies

    Visitor II
    March 23, 2024

    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?

    Graduate
    March 24, 2024

    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.

    Visitor II
    March 24, 2024

    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.

     

    Graduate
    March 24, 2024

    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.

    Visitor II
    March 24, 2024

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

     

    Graduate
    March 25, 2024

    Bother - I meant `+split`.

    Graduate
    March 31, 2024

    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 ***