Strange error debugging serial output on custom board
So I have a project created in STM32CubeMX (version 5, if that’s relevant) and I can compile, flash and run the program on the board. All well and good.
If I call printf(“hi”), there’s no output on the serial lines.
So I read up, and printf() is supposed to call _write(int, char*, int) which in turn is coded to call _ _io_putchar(uint8_t). In my case that’s not happening. I can put a breakpoint in _ _io_putchar() and step into (or over) printf() and the breakpoint never gets triggered.
Just to prove the serial hardware was ok (new, custom board, remember) I tried calling __io_putchar(‘*’) a few times, and this *did* send characters down the serial line.
I can’t find any other instances of __io_putchar() being defined in the codebase (I searched recursively in the project directory for all occurrences using ack), so I’m a bit confused.
my __io_putchar (that works If called directly) is in main.c and looks like:
void __io_putchar(uint8_t ch)
{
if ((char)ch == ‘\n’)
HAL_UART_Transmit(&huart6,(uint8_t*)”\r”,1,1);
HAL_UART_Transmit(&huart6,(uint8_t*)&ch,1,1);
}
my _write is in the STM32CubeMX-generated syscalls.c and looks like:
int _write(int file, char *ptr, int len)
{
int DataIdx;
for (DataIdx = 0; DataIdx < len; DataIdx++)
{
__io_putchar(*ptr++);
}
return len;
}
Anyone got any ideas ? Is it somehow dragging the weakly-linked version of __io_putchar in, instead of mine ? Any ideas gratefully received