If using the Config Tool:
In the Debug Console component, pick Custom near the top right.
Then select Serial port UART.
Then in UART configuration pick Peripheral, for me it was LPUART2.
It will be different for you.
Do not install a UART driver for this port as it will conflict with this Debug Console selection (I found the hard way).
Then over in the Pin Config Tool try to remap the pins to the UART that is being used.
I never did get this to work, I could never get the Pin Tool synced with the new Config Tool UART selection. The system just kept arguing with me that there was a conflict between different UART pins.
My solution was to start with an empty project then tediously assign all ~50 pins from their unused state.
If not using Config Tool, and using Newlib low level functions for _write() and _read() need to be written that map them to your actual hardware. printf() eventually reaches this low level. These are my debug_X functions. Sorry I can't help with Redlib, never used it.
/** @(#)syscalls.c <25-Sep-2013 12:17:43 bpaddock>
* \date Last Time-stamp: <15-Apr-2016 11:45:41 bob p>
*
* \file syscalls.c
* \brief Low level memory and I/O functions for newlib
*
* Minor changes from Andrew Payne original.
* Copyright (c) 2012-2013 Andrew Payne <andy@payne.org>
*/
#include <sys/stat.h> /* struct stat and S_IFCHR*/
#include "compiler.h"
#include "debug.h"
#include "fault_soft.h"
int _close( int const fd );
int _close( int const fd ) { UNUSED( fd ); return -1; }
int _isatty( int const fd );
int _isatty( int const fd ) { UNUSED( fd ); return 1; }
int _open( const char *name, int const flags, int const mode );
int _open( const char *name, int const flags, int const mode ) { UNUSED( name ); UNUSED( flags ); UNUSED( mode ); return( -1 ); }
int _fstat( int const fd, struct stat *st );
int _fstat( int const fd, struct stat *st )
{
UNUSED( fd );
st->st_mode = S_IFCHR; /* Character device */
return( 0 );
}
/*
* Read "len" of char to "ptr" from file id "fd"
* Return number of char read.
*/
int _write( int const fd, char const *p, int const len );
int _write( int const fd, char const *p, int const len )
{
switch( fd )
{
case 1: return debug_write( p, len); /* stdout */
case 2: return debug_write_err(p, len); /* stderr */
default: return( -1 );
}
}
/*
* Read "len" of char to "ptr" from file id "fd"
* Return number of char read.
*/
int _read( int const fd, char *p, int const len );
int _read( int const fd, char *p, int const len )
{
UNUSED( fd );
return debug_read(p, len);
}
/* ------------------------------------------------------------------------------------
* _sbrk(len) -- Allocate space on the heap
*/
extern char __heap_start[]; /* Defined by the linker script */
static char *heap_end = __heap_start;
char *_sbrk(int const incr);
char *_sbrk(int const incr)
{
heap_end += incr; /* \todo check for collisions with the stack */
return( (heap_end - incr) );
}
/* Signal handler (fault): */
void _kill( int const pid, int const sig ) __attribute__((noreturn));
void _kill( int const pid, int const sig )
{
UNUSED( pid );
UNUSED( sig );
fault_soft_handler( 0xFEUL );
}