STM32F103RB strange clock behaviour with bootloader

Hi,

I’ve been using Mbed OS5 and OS6 with STM32 based 3D Printer controller boards. No issues with F407 based boards with bootloaders, but now I’m trying an F103 based board and cannot understand why the clock settings are changing as soon as a call to ThisThread::sleep_for(BLINKING_RATE); or wait_us(500000); happens.

The code is a simple “hello world” blinky with serial out. Works without issue when directly flashed to the board.

#define BLINKING_RATE 500ms

int main()

{

// Initialise the digital pin LED1 as an output

DigitalOut led(PC_9);

int i = 0;

printf("Robin E3 is alive\n\r");

while (true) {

    led = !led;

    printf("i = %d\n\r",i);

    i++;

    //ThisThread::sleep_for(BLINKING_RATE);

    wait_us(500000);

}

}

When the stock bootloader ( with “target.mbed_app_start”: “0x08005000”,) , the first serial console prints out ok and then the CPU seems to go into super slow mode. It’s still running, but at crazy slow speed. Serial output is garbage as well.

I’ve confirmed the behaviour with both OS5 and OS6.

Thoughts?

Thanks
Scott