2024-11-26 11:38 AM
I am using the Nucleo-H743ZI with a c++ project, and have used this code many times before with this board and c++; however, now the printf() function no longer prints to uart:
int __io_putchar(int ch) {
HAL_UART_Transmit(&huart3, (uint8_t*) &ch, 1, 0xFFFF);
return ch;
}
[...]
printf("hello\n");
I can send chars using HAL_UART_Transmit(&huart3, (uint8_t*) &ch, 1, 0xFFFF);
I stepped through the disassembly and found that __io_putchar is called with the following:
112 __io_putchar(*ptr++);
08003718: ldr r3, [r7, #8]
0800371a: adds r2, r3, #1
0800371c: str r2, [r7, #8]
0800371e: ldrb r3, [r3, #0]
08003720: mov r0, r3
08003722: nop.w
To the best I can tell, it seems like the default weak __io_putchar is being called.
In the memory map file it is listed as:
.text._Z12__io_putchari
0x00000000 0x24 ./Core/Src/main.o
Ant ideas what is going wrong and how to fix it?
Thanks,
Ethan
Solved! Go to Solution.
2024-11-26 12:36 PM
Shouldn't you be using extern "C" to prevent the name mangling?
extern "C" int __io_putchar(int ch) { ...
2024-11-26 12:36 PM
Shouldn't you be using extern "C" to prevent the name mangling?
extern "C" int __io_putchar(int ch) { ...
2024-12-02 08:43 AM
Could've sworn I had tried that, but that fixed it...