2018-08-13 01:59 PM
I'm bringing up an STM32F103 part using a Makefile project generated by CubeMX. Previously I've always used the Keil IDE and during this switch I encountered some difficulty with retargetting printf. I implemented my fputc prototype as I usually would be nothing was working. I then realized that I should have been using the __io_putchar prototype since I'm using GCC. However that still did not work until I finally realized I needed to include syscalls.c. Everything is working now, but I'm still unclear on a few things I was hoping could be cleared up.
2018-08-13 02:39 PM
Keil != GNU/GCC, they have been doing embedded systems with semi-hosting for decades, and the libraries and methods are different. The Keil and IAR tool chains are not derived from GNU/GCC, and consequential have solved problems differently.
In GNU/GCC the File IO, abort handlers, and heap allocator code are handled in a syscalls or newlib file. The startup.s file also has to manage symbols and statics set up in the linker script, whereas the Keil linker builds a table structure describing the load regions and unpacks this with the __main library function before calling your main() function.
The libraries can link due to "weak" functions that provide default behaviour, but can be replaced by user and board specific code when/if you choose to supply it.
I guess by understanding how your selected tools function, rather than stabbing around in the dark.