Skip to content

Changing default serial port conflicts with other serial ports #13510

@masoudr

Description

@masoudr

Description of defect

My target is a Nucleo F103RB board and I want to use two serial ports. One is a USB port and a USART1 serial.
I'm trying to change the default serial pins for printf as described in here to use with USART1 instead of default USB and manually initialize USB serial in my code.

Target(s) affected by this defect ?

STM32F103RBT6

Toolchain(s) (name and version) displaying this defect ?

GNU gdb (GNU Arm Embedded Toolchain 9-2020-q2-update

What version of Mbed-os are you using (tag or sha) ?

mbed-os 6.2.0

What version(s) of tools are you using. List all that apply (E.g. mbed-cli)

mbed-cli 1.10.1

How is this defect reproduced ?

mbed_app.json:

{
    "requires": ["bare-metal"],
    "macros": [
        "MBED_HEAP_STATS_ENABLED=1",
        "MBED_STACK_STATS_ENABLED=1",
        "MBED_MEM_TRACING_ENABLED=1"
    ],
    "target_overrides": {
        "*": {
            "target.c_lib": "small",
            "target.printf_lib": "minimal-printf",
            "platform.minimal-printf-enable-floating-point": false,
            "platform.stdio-baud-rate": 115200,
            "target.stdio_uart_tx": "PA_9",
            "target.stdio_uart_rx": "PA_10"
        }
    }
}

Sample code:

#include "mbed.h"

static BufferedSerial USBSerial(USBTX, USBRX, 115200);

int main()
{
    const char* msg = "Message from USB Serial\r\n";
    USBSerial.write(msg, strlen(msg));
    // This should print to USART1
    printf("Message from USART1\r\n");
}

I get no results in the USB port and get both outputs in USART1:

22:49:13.109 -> Message from USB Serial
22:49:13.109 -> Message from USART1

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions