Arm Mbed OS support forum

Minimal printf() in Mbed OS v.6.4.0 adds unwanted carriage return before line feed

Using Mbed OS v.6.4.0 and NUCLEO_F429ZI. Trying a simple test program with :
#include “mbed.h”
int main() {
while (true) {
printf(“Hello World!\n”);
ThisThread::sleep_for(1000ms); // changed for Mbed OS v.6 instead of wait()
}
Looking at the oscilloscope, a carriage return (\r) is added before the line feed (\n). But the program does not show a \r. Of course TeraTerm or other terminal shows a carriage return at the end of the string.
I feel this is a bug as in the case of version 6.2.0 where a \r was added before any string coming from minimal printf(). However this bug was solved with v.6.3.0.
Old 5.14.4 version did not show this problem and a line feed was a real line feed.
Any help?
Thanks. Andrea Scorzoni

Apparently, the described problem was not considered as worthy for being answered, therefore I solved the problem. Actually, this is not a problem but probably a wanted “feature” (but I totally disagree with the introduction of this “feature”). In Mbed OS v.6.2.0 the string “Hello World!” is headed by a carriage return. Mbed OS v.6.3.0 modified the position of the carriage return: looking at the oscilloscope, a carriage return (\r) is added before the line feed (\n). So why does Mbed OS add a \r? The answer can be found in the mbed_app.json file that can be found in …\Project_name\mbed-os\platform:
{
“name”: “platform”,
“config”: {
“stdio-convert-newlines”: {
“help”: “Enable conversion to standard newlines on stdin/stdout/stderr”,
“value”: true
},

    "stdio-convert-tty-newlines": {
        "help": "Enable conversion to standard newlines on any tty FILE stream",
        "value": true
    }, ...

In order to fix the problem the “true” values should be changed to “false”:

{
“name”: “platform”,
“config”: {
“stdio-convert-newlines”: {
“help”: “Enable conversion to standard newlines on stdin/stdout/stderr”,
“value”: false
},

    "stdio-convert-tty-newlines": {
        "help": "Enable conversion to standard newlines on any tty FILE stream",
        "value": false
    },