Skip to content

Add USBDevice for STM32F103RB with bare-metal profile #13664

@masoudr

Description

@masoudr

Description of defect

I'm trying to add USBSerial for my custom STM32F103RB board which is based on NucleoF103RB board.
If I add the bare-metal profile I get a linker error for USBSerial class. I tried to add drivers to requires section but it didn't work as it already exists.

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.3.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 ?

main.cpp:

#include "mbed.h"
#include "USBSerial.h"
//Virtual serial port over USB
USBSerial serial;


int main(void)
{
    printf("USBSerial test\n");
    while (1) {
        serial.printf("I am a virtual serial port\r\n");
        thread_sleep_for(1000);
    }
}

mbed_app.json (without bare-metal profile):

{
    "requires": ["bare-metal"],
    "target_overrides": {
        "*": {
            "target.c_lib": "small",
            "target.printf_lib": "minimal-printf",
            "platform.minimal-printf-enable-floating-point": false,
            "target.clock_source": "USE_PLL_HSE_EXTC|USE_PLL_HSI",
            "target.macros_add": ["HSE_VALUE=8000000"],
            "target.components_add": [
                "SPIF"
            ],
            "target.device_has_add": ["USBDEVICE"]
        }
    }
}

error log:

Compile [100.0%]: main.cpp
Link: Main
c:/program files (x86)/gnu arm embedded toolchain/9 2020-q2-update/bin/../lib/gcc/arm-none-eabi/9.3.1/../../../../arm-none-eabi/bin/ld.exe: BUILD/NUCLEO_F103RB/GCC_ARM/src/main.o: in function `_GLOBAL__sub_I_usbserial':
F:\Work\VehicleFunction\Codes\Main\Main/.\src/main.cpp:5: undefined reference to `USBSerial::USBSerial(bool, unsigned short, unsigned short, unsigned short)'       
c:/program files (x86)/gnu arm embedded toolchain/9 2020-q2-update/bin/../lib/gcc/arm-none-eabi/9.3.1/../../../../arm-none-eabi/bin/ld.exe: BUILD/NUCLEO_F103RB/GCC_ARM/src/main.o: in function `mbed::DigitalOut::DigitalOut(PinName)':
F:\Work\VehicleFunction\Codes\Main\Main/./mbed-os/drivers/include/drivers/DigitalOut.h:59: undefined reference to `USBSerial::~USBSerial()'
collect2.exe: error: ld returned 1 exit status
[ERROR] c:/program files (x86)/gnu arm embedded toolchain/9 2020-q2-update/bin/../lib/gcc/arm-none-eabi/9.3.1/../../../../arm-none-eabi/bin/ld.exe: BUILD/NUCLEO_F103RB/GCC_ARM/src/main.o: in function `_GLOBAL__sub_I_usbserial':
F:\Work\VehicleFunction\Codes\Main\Main/.\src/main.cpp:5: undefined reference to `USBSerial::USBSerial(bool, unsigned short, unsigned short, unsigned short)'       
c:/program files (x86)/gnu arm embedded toolchain/9 2020-q2-update/bin/../lib/gcc/arm-none-eabi/9.3.1/../../../../arm-none-eabi/bin/ld.exe: BUILD/NUCLEO_F103RB/GCC_ARM/src/main.o: in function `mbed::DigitalOut::DigitalOut(PinName)':
F:\Work\VehicleFunction\Codes\Main\Main/./mbed-os/drivers/include/drivers/DigitalOut.h:59: undefined reference to `USBSerial::~USBSerial()'
collect2.exe: error: ld returned 1 exit status

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