Skip to content

Commit 509df14

Browse files
committed
Changed minimal-printf to call fputc so that it does not bypass the retargetting code
1 parent a6c316a commit 509df14

File tree

3 files changed

+3
-45
lines changed

3 files changed

+3
-45
lines changed

platform/source/minimal-printf/mbed_printf_implementation.c

Lines changed: 1 addition & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -37,39 +37,9 @@ static char mbed_stdio_out_prev = 0;
3737
#endif
3838

3939
#if CONSOLE_OUTPUT == CONSOLE_OUTPUT_UART
40-
#if DEVICE_SERIAL
41-
/*
42-
Serial initialization and new line replacement is a direct copy from mbed_retarget.cpp
43-
If the static modifier were to be removed, this part of the code would not be necessary.
44-
*/
45-
#include "hal/serial_api.h"
46-
47-
static serial_t stdio_uart = { 0 };
48-
49-
/* module variable for keeping track of initialization */
50-
static bool not_initialized = true;
51-
52-
static void init_serial()
53-
{
54-
if (not_initialized) {
55-
not_initialized = false;
56-
57-
serial_init(&stdio_uart, STDIO_UART_TX, STDIO_UART_RX);
58-
#if MBED_CONF_PLATFORM_STDIO_BAUD_RATE
59-
serial_baud(&stdio_uart, MBED_CONF_PLATFORM_STDIO_BAUD_RATE);
60-
#endif
61-
}
62-
}
63-
64-
#define MBED_INITIALIZE_PRINT(x) { init_serial(); }
65-
#define MBED_PRINT_CHARACTER(x) { serial_putc(&stdio_uart, x); }
66-
67-
#else
6840

6941
#define MBED_INITIALIZE_PRINT(x)
70-
#define MBED_PRINT_CHARACTER(x)
71-
72-
#endif // if DEVICE_SERIAL
42+
#define MBED_PRINT_CHARACTER(x) { fputc(x, stdout); }
7343

7444
#elif CONSOLE_OUTPUT == CONSOLE_OUTPUT_SWO
7545

platform/source/minimal-printf/mbed_printf_wrapper.c

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -64,18 +64,6 @@
6464
#warning "This compiler is not yet supported."
6565
#endif
6666

67-
// Prevent optimization of printf() by the ARMCC or IAR compiler.
68-
// This is done to prevent optimization which can cause printf() to be
69-
// substituted with a different function (e.g. puts()) and cause
70-
// the output to be missing some strings.
71-
// Note: Optimization prevention for other supported compilers is done
72-
// via compiler optional command line arguments.
73-
#if defined(__CC_ARM) /* ARMC5 */
74-
#pragma push
75-
#pragma O0
76-
#elif defined(__ICCARM__) /* IAR */
77-
#pragma optimize=none
78-
#endif
7967
int SUB_PRINTF(const char *format, ...)
8068
{
8169
va_list arguments;

tools/profiles/extensions/minimal-printf.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
{
22
"GCC_ARM": {
3-
"common": ["-DMBED_MINIMAL_PRINTF", "-fno-builtin-printf"],
3+
"common": ["-DMBED_MINIMAL_PRINTF"],
44
"ld": ["-Wl,--wrap,printf", "-Wl,--wrap,sprintf", "-Wl,--wrap,snprintf",
55
"-Wl,--wrap,vprintf", "-Wl,--wrap,vsprintf", "-Wl,--wrap,vsnprintf",
66
"-Wl,--wrap,fprintf", "-Wl,--wrap,vfprintf"]
77
},
88
"ARMC6": {
9-
"common": ["-DMBED_MINIMAL_PRINTF", "-fno-builtin-printf"]
9+
"common": ["-DMBED_MINIMAL_PRINTF"]
1010
},
1111
"ARM": {
1212
"common": ["-DMBED_MINIMAL_PRINTF"]

0 commit comments

Comments
 (0)