STMicroelectronics / cmsis-device-g0

Provides the STM32Cube MCU Component "cmsis_device_g0" of the STM32G0 series.
Apache License 2.0
5 stars 5 forks source link

Unable to use Multi-file compilation in IAR ( which typically heavy reduces unused excess code ) #3

Closed HarrisonTuckerTTIFC closed 5 months ago

HarrisonTuckerTTIFC commented 5 months ago

Describe the set-up Include Low level drivers and CMSIS includes to compile without optimizations.

Describe the bug System_stm32g0xx.c does not directly include #include "system_stm32g0xx.h" and cannot include. I tried including the files directly and added stdint.h to the header to get uint32_t types but it still cannot find the SystemInit in Startup_stm32g030xx.s

it seems like you are trying to extern variables and function, but you cannot do that if Mulit-file compilation is enabled, which will reduce the code size by placing all of the code into one object file (.o) the function and variables need to be called and not externed.

This also relates to the C0 which makes the most sense to try to reduce code size to bring up quantity

How To Reproduce

  1. Create a project in IAR
  2. Include all LL files, startup_stm32g030xx.s, system_stm32g0xx.c from st drivers.
  3. set optimization to high and select multi-file compilation and discard unused public

Additional context I am using IAR 9.32

Screenshots If applicable, add screenshots to help explain your problem.

HarrisonTuckerTTIFC commented 5 months ago

I realized I am able to compile if I uncheck discard unused public, which is the part that removes unused code. it does compile.

The reason it did no compile is because there was no code in SystemInit function, so I added __root which is a IAR compile command to force this function to remain, which I typically use on interrupt handler functions for the same reason.

It is compiling, now for me but I guess this is just information that may be helpful

HarrisonTuckerTTIFC commented 5 months ago

image This seems to be the only required fix to allow multi-file configuration given the function is not used but is defined in the .s file

ALABSTM commented 5 months ago

Hi @HarrisonTuckerTTIFC,

Thank you for the proposal. Please allow me to draw you attention that the system_stm32g0xx.c file is under the ./Source/Templates. This means that these files are generic templates.

These generic templates are designed to cover applications common use cases and are intended to be customized by users to cover special use cases.

I hope this clarifies the point. Please allow me to close this issue. Thank you for your comprehension and thank you again for your proposal.

With regards,

HarrisonTuckerTTIFC commented 5 months ago

Hi Ali,

Yea that is fair. I have been using your drivers and CMSIS repositories as submodules in our companies library directly to make sure we use the latest updates. So in doing that, it makes it hard to stay up to date while using the template file as is, since it had not required change before since it is intended to work with the assembly files for each chip. It sounds like you guys do not intend to change to work with the assembly files so I will just stop using the CMSIS repository all together.

Thanks,