I’ve had mixed success using Mbed with Blue Pill boards that I have lying around. I can get it to upload perfectly fine with an ST-LinkV2. But it seems my code is never executed. A simple blink sketch doesn’t blink the LED like I expect it to. The LED does blink but it seems to be stuck in a boot loader or something… Possibly the one for Arduino. It blinks 5 times slowly. Then blinks rapidly, before repeating.
I’ve had it work before but I can never seem what to figure out how I got it to work.
Indeed it fails in mbed-os internals for the thread_sleep_for. When initializing the OS timer (triggered by thread_sleep_for) it sees that it wasn’t properly configured to either use “tickless from µS ticker” with a µS ticker peripheral or not tickless from µS ticker but a low-power ticker. The bluepill has no LPTIM but it has several TIMs, so low-power ticker is not possible and the normal µS ticker should be used.
Can be fixed by overriding tickless-from-us-ticker for the bluepill target in the target.json file (found in C:\Users\<user>\.platformio\packages\framework-mbed\targets\target.json) via the overrides directive.
Are you modifying the correct file? Is there more than one framework-mbed (with different versions) in C:\Users\<user>\.platformio\packages? In the project folder’s .pio\build\bluepill_f103c8\mbed_config.h at the bottom, does it correctly say
#define MBED_CONF_TARGET_TICKLESS_FROM_US_TICKER 1 // set by target:BLUEPILL_F103C8
which is not compiled in for me. Can you remove this library from your lib_deps in the platformio.ini and .pio\libpdeps folder? Have you added the #if .. block in the code from above? Becasue I don’t see the output from that and it should give one regardless.
Are you sure 3V3, GND, SWCLK SWDIO are correctly wired? Does it help if you connect the NRST signal from the programmer to the board? Also what’s helped me is to just try to flash a firmware and at the start, hold down the reset button, then when openocd has started up and waits for the target reset, release the reset button.