cancel
Showing results for 
Search instead for 
Did you mean: 

How to compile HAL library for a particular series

HPere.1
Associate II

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

6 REPLIES 6

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.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
HPere.1
Associate II

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?

>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

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

All these modules are already defined in my HAL_conf.h file0693W000001poyqQAA.png

HPere.1
Associate II

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.