gcc optimizes printf("x") to putchar('x'), but we #define putchar to be something else.
Now lib/printf.c defines a putchar() function that always prints on the sercomm port, it will break uart consoles. --- src/target/firmware/lib/printf.c | 16 ++++++++++++++++ 1 files changed, 16 insertions(+), 0 deletions(-)
diff --git a/src/target/firmware/lib/printf.c b/src/target/firmware/lib/printf.c index a4fc687..887b5b4 100644 --- a/src/target/firmware/lib/printf.c +++ b/src/target/firmware/lib/printf.c @@ -17,3 +17,19 @@ int printf(const char *fmt, ...)
return r; } + +/* HACK: we define putchar to be sercomm_putchar, + * but gcc optimizes printf("x") to putchar('x') + * so it will generate a call to the function putchar(). + * + * Note: This will break non-sercomm consoles! + */ + +#ifdef putchar +#undef putchar + +int putchar(char c){ + return sercomm_putchar(c); +} + +#endif