I use the IAR IDE. For any given bit of example code (lwdemo, for example), there is a workspace comprising several different projects. There's one project for each library (mqx library, ksdk library, etc)and then one for the example itself. In many (maybe all) of the example projects, there's a Debug Console sub-directory containing a number of files, including:
fsl_debug_console.c
fsl_debug_console.h
print_scan.c
print_scan.h
Maybe they're named improperly, and the fsl_debug_console files should just be named fsl_console.c & fsl_console.h. The point is, these files appear to let you redirect stdio to whichever port you'd like. In board.h, for the FRDM-KL43Z & -27Z, you'll find the line
#define BOARD_USE_LPUART
which makes stdio (printf, scanf) use the LPUART. On the FRDM boards, this actually gets sent out the SDA port. By using this line instead
#define BOARD_USE_VIRTUALCOM
the fsl_debug_console module should redirect stdio to the USB port using the CDC Virtual COM port functionality.
BUT it's not as simple as just changing the #define in board.h. I've added the USB Device library to the workspace, and link it into the example code. I've added virtual_com.c & .h and usb_descriptor.c & .h to the example project. I've merged the main functions together (virtual.c has its own main).
The first big problem is that the init_bsp.c function _bsp_pre_init() has code to configure the UART pins for BOARD_USE_LPSCI, BOARD_USE_LPUART, and BOARD_USE_UART. Anything else, like BOARD_USE_VIRTUALCOM, causes a compile error by way of this statement:
#error Default serial module is unsupported or undefined.
So, I need to know what else I need to do to make my USB port be used for stdio.