Skip to main content
Visitor II
June 1, 2020
Question

How to compile HAL library for a particular series

  • June 1, 2020
  • 3 replies
  • 1984 views

I wanted to compile all the HAL library sources so that I could make a one archive of all the files. I found this as this project which build HAL sources for F4 series (but the version of the HAL code is much old) I tried to generate HAL code from cubeMX but when though I explicitly mention to include all the source library files and change the auto generated makefile to compile all the sources it doesn't compile all the source files. Anybody have an idea or a hint about how to achieve my requirement? Thanks

P.S. I even tried with system workbench but the compilation takes place only for the default set of files. But instead I need to compile all the files

    This topic has been closed for replies.

    3 replies

    Graduate II
    June 1, 2020

    How would you normally generate static libraries?

    General problem is that ST has CPU and board level dependencies baked in, and these are acheived via pre-processor directives, and not resolved at link time.

    You'd need to get all of the defines in order, and have stm32fxyz_hal_conf.h enable all the modules compatible with your platform, compile all the library source files, and then get the linker to combine them into a library.

    HPere.1Author
    Visitor II
    June 1, 2020

    Thank you very much. I was able to get around the problem. However I have a follow up question. The object files generated for few modules does not seem to have any content though their underline implementation does contain code. For example 'stm32l4xx_hal_rng_ex' and 'stm32l4xx_hal_cryp' does not have any content as I observed through GDB. (and the file very small) Do you have any idea about a reason behind this?

    Super User
    June 1, 2020

    >The object files generated for few modules does not seem to have any content

    This is because all these files are guarded by #ifdef:

    #ifdef HAL_????_MODULE_ENABLED

    Provide stm32xxx_hal_conf.h with all these symbols defined, for each module you want to include in the library.

    -- pa

    HPere.1Author
    Visitor II
    June 2, 2020

    I already had defined those modules. For example, I had already defined HAL_CRYP_MODULE_ENABLED is defined in stm32xxx_hal_conf file

    HPere.1Author
    Visitor II
    June 2, 2020

    So I did for one of MCU from F4 series, and cypt module produce the object file. The only reason I am thinking is maybe these modules, (for example cypto module) is not supported in STM32L4xx MCU that I selected but there in the STM32F4xx MCU. Other than that, maybe there is a bug somewhere in the source codes generated from the CubeMX.