What’s your project’s platformio.ini
and code?
platformio.ini
[env:bluepill_f103c8]
platform = ststm32
board = bluepill_f103c8
framework = mbed
main.cpp
#include "mbed.h"
DigitalOut led(PC_13);
int main() {
while(1) {
led.write(0);
thread_sleep_for(500);
led.write(1);
thread_sleep_for(500);
led.write(0);
thread_sleep_for(500);
led.write(1);
thread_sleep_for(5000);
}
}
A pretty text book blink code.
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.
"BLUEPILL_F103C8": {
"inherits": ["FAMILY_STM32"],
"core": "Cortex-M3",
"default_toolchain": "GCC_ARM",
"extra_labels_add": ["STM32F1", "STM32F103C8"],
"supported_toolchains": ["GCC_ARM"],
"device_has_add": [
"CAN",
"SERIAL_ASYNCH",
"FLASH"
],
"device_has_remove": ["STDIO_MESSAGES", "LPTICKER"],
"overrides": {
"tickless-from-us-ticker": true
}
},
Also note that the LED is logically inverted so writing 1
to it will make it turn off.
I’ll check why this isn’t the default anymore…
Thanks, sadly it seems to be still exhibiting the same behavior. I also tried going back to just wait
and that does the same thing :-/ I honestly feel like this is a boot loader issue or something.
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
now? Cleaning and rebuilding doesn’t help?
All of that is correct. Did a clean and build and it didn’t help. Maybe a gif will help explain things better:
I have the bluepill board in front of me and it blinks as it’s meant to be by the firmware, not like the error blinking your video shows.
Can you add the block
#if MBED_CONF_TARGET_TICKLESS_FROM_US_TICKER && DEVICE_USTICKER
#warning "All macros correct"
#else
#error "ERROR! invalid settings"
#endif
after the #include <mbed.h>
in the main.cpp.
Then, can you use pastebin.com to
- upload the content of
pio\build\bluepill_f103c8\mbed_config.h
- in a PIO terminal, execute
pio run -t clean
, thenpio run -v > build_log.txt 2>&1
. Upload the resulting log file and post link.
Build Logs:
mbed_config.h
Pastebin apparently has a 512KB limit for non pro accounts so hopefully a gist is cool.
Well one difference is
|-- <Adafruit_DotStar_mbed> (/Users/laveur/Documents/PlatformIO/Projects/DFU Blink/lib/Adafruit_DotStar_mbed)
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.
So I moved over my code to another project and it seems to have worked right. Not sure why… sadly now my STLink won’t recognize any of my boards though…
Yikes any error message? Holding and releasing the reset button during upload doesn’t help?
Sorry for taking so long to reply… Seems st-link can’t figure out what board I have…
Found 1 stlink programmers
serial: 513f69064966555039241867
openocd: "\x51\x3f\x69\x06\x49\x66\x55\x50\x39\x24\x18\x67"
flash: 0 (pagesize: 0)
sram: 0
chipid: 0x0000
descr: unknown device
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.
Holding the reset button did the trick… Man this stuff is more complicated… I see why most people choose to just use Arduino now…
Now that I’ve worked that all out it seems the issue is with my port of Adafruit’s DotStar Library some place…
If you want to take a look at the code: GitHub - laveur/Adafruit_DotStar_mbed: Re-write of Adafruit's DotStart Arduino library for mbed
What’s the exact problem that’s occuring? Firmware doesn’t start anymore / error message / LEDs not working?
It goes back to that error LED flashing pattern that I showed you before… Seems that its isolated to the begin method which simply creates two DigitalOut objects.
I’ll check. Creating an DigitalOut
object with a valid PinName
shouldn’t result in that o_o. Have you also setup debugging with the STLink in your IDE yet?