printf(), retarget and syscalls.c
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.
- What is syscalls.c and why have I not encountered it at all while using Keil? I can't even find it when trying to look through a previous project.
- Before adding syscalls.c my code was still compiling but it seemed like printf had no effect. What was I calling when I called printf and why was the compiler not throwing an error?
- What's the proper way to debug this kind of issue in the future? Ie. I'm calling printf but nothing is happening and I can't step into it in the debugger.
- Why does Keil's toolchain use fputc instead of __io_putchar, and what's the difference?
