In trying to create a test project in C++ for the FRDM-K64F with MCUXpresso, I found that UART redirection of printf and std::count calls was not working. After some investigation, I found that fsl_debug_console.c does not define the necessary redirection functions for Newlib (_write and _read, see Using printf()) in C++ projects. For Redlib in C projects, the equivalent functions (__sys_write, __sys_readc) are correctly defined but for some reason the Newlib functions are missing.
The attached fsl_debug_console.c adds the missing functions and successfully redirects to/from the UART with printf, scanf, std::cout, and std::cin.
Here are the versions that I am using:
- MCUXpresso IDE v10.0.2 [Build 411] [2017-07-11]
- MXUXpresso SDK 2.2.0
Ran into the same issue described above for std::cout redirection.
Modified for MCUXpresso v10.1.0 (build 606) and SDK 2.3.0 (below) and std::cout displays to UART.
Note: A separate CR (\r) is necessary in addition to std::endl.
MCUXpresso SDK team, would you be able to promote this change into the SDK sources for future projects?