Generate and use an STM32 Hal library, can't override __io_putchar
Hi everyone,
I am currently trying to create a library from STM32 Hal driver (Name of this project is Nucleol073rzHalTest).
The aim for this library is to contain all pin configuration to be used in other projetcs.
For this I simply create a stm32 executable project with the desire board/micro and configure pin.
I then convert this project to library (by changing the type of project from "Executable" to "Static Library' and the output file extension from "elf" to "a"),
and call the function "main_app" in the main in order I call define it in other projects.
(I keep the .IOS file in order to modify at demand the pin configuration, but delete .ld and .s files which will depend on executable project)
I then create another stm32 project (or simple C/C++ project) executable project which will use this library (Name of this project is SandboxHal or SandBoxHalTest for the simple C/C++ project).
I add the path to search the library, and necessary header files from the library.
I delete the ioc file, source and driver files in the stm32 project because they are already compiled in the previous library.
I create my own c++ file and define in it the "main_app" function which simply toggle a led and print messages.
It works well (after some adjustement) and I can control the led on the demo board.
However when it comes to overwrite the function __io_putchar in order to get the uart output redirect to the terminal, I didn't suceed.
It works well in a standard project where all hal drivers are already in it, but not for my projects which are linked to the previous library.
In debug, the code doesn't stop into the function __io_putchar if I add breakpoint.
And __io_putchar is added in the section "Discarded input sections" in the map file after compilation for both the STM32 Executable project and the simple C/C++ Executable project.
I don't know why.
I can't succeed to get this function works in this situation, do you have suggestion about it ?
STM32CubeIDE version : Version: 1.13.2
Board used: Nucleo-L073rz
Here the code, and project view:


