How to make a keil driver library out of HAL source. Weak definitions gets selected unexpectedly.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2022-01-27 07:34 AM
When doing generating a project from STM32CubeMX (for F4 family) and converting it to a library in keil, then when keeping main in executable project and linking to library wrong implementation of *MspInit gets selected. The weak ones are selected even though there is a "strong" one in library too.
Problem is how compilers work. They don't look extensively in librarys so they don't even bother to find the strong one if first stumbled upon a weak symbol.
i.HAL_UART_Init 0x08001260 Section 0 stm32f4xx_hal_uart.o(i.HAL_UART_Init)
i.HAL_UART_MspInit 0x080012c2 Section 0 stm32f4xx_hal_uart.o(i.HAL_UART_MspInit)
See keil map file above. The weak MspInit were selected despite the "strong" version is in library too.
For IAR there is an linker option --whole_archive that forces linker to actually look in all object files and then the strong one is selected.
For Keil I haven't fond similar option (neither old or clang based version).
- Labels:
-
STM32CubeMX
-
STM32F4 Series
-
UART-USART
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2022-01-27 09:13 PM
The Keil forum is here: https://community.arm.com/support-forums/f/keil-forum