Error uploading Bluepill STM32 Arduino

Hello all, I’m new in PlatformIO under VS-Code on Win7. My configuration is the following : VS-Code with latest release of PlatformIO, STM32 with Bluepill with ST-Link V2, platformio.ini is :

[env:bluepill_f103c8_128k]
board = bluepill_f103c8_128k
platform = ststm32
framework = arduino
upload_protocol = stlink

Validation of my code is OK :slight_smile:

But Upload fail :disappointed:
Upload

Do you have a solution for this Error solving ?
Thanks.
Vincent.

Sorry all, this already solved in Post : Cannot upload to STM32 Bluepill board over STLink-V2 As a workaround by Manuelni, we need to modify for clone Chinese Bluepill module the configuration file under :
you can edit the file ~/.platformio/packages/tool-openocd/scripts/target/stm32f1x.cfg and change the line:

set _CPUTAPID 0x1ba01477

to:

set _CPUTAPID 0x2ba01477

Sorry again & Thanks !
Vincent.

1 Like

So, after that I try with very basic program one (Blink) Build & Upload work fine (no message, warning or fail) but the on board Led does not blink as expected !
I try to add this in platformio.ini :
upload_protocol = stlink
build_flags = -DCONFIG_MAPLE_MINI_NO_DISABLE_DEBUG=1

No more effects … Any idea ?
Thanks.
Vincent.

What code are you running?

Sorry maxgerhardt, when I mean basic it’s this one :
#define LED_BUILTIN PC13 // La LED de la carte est en PC13.
// Fonction de Setup
void setup()
{
// Initialise la LED de la carte en Sortie.
pinMode(LED_BUILTIN, OUTPUT);
}

// La boucle sans fin …
void loop()
{
digitalWrite(LED_BUILTIN, HIGH); // LED ON
delay(100); // Attendre xxx ms
digitalWrite(LED_BUILTIN, LOW); // LED OFF
delay(100); // Attendre xxx ms
}

I have just personally verified that this firmware runs perfectly fine on my bluepill board and stlink with the code and platformio.ini you have given me. Have you tried pressing the reset button? Have you set the BOOT0 and BOOT1 jumpers to 00 so that the MCU boots the program in flash and not the bootlaoder?

grafik

Also this is an invalid option because the Arduino core is chosen as the STM32(Duino) one, not Maple

Does using board = blackpill_f103c8 make a difference?

Thanks a lot maxgerhardt, I try first this code with the Arduino IDE, of course to upload the program I move the jumper to programming mode. Without not moving back the jumper to Operating mode the Led is blinking.
So, I move back to platformio and to see the Led blinking I need (instead of Arduino IDE) to move the jumper after upload & push the Reset button to get Led blinking.
That’s probably due to a Soft-Reset or any bad setup on platformio ?
Thanks !
Vincent.

Does the Arduino IDE also upload via STLink or the USB DFU bootloader? Because you only need to set it into “programming” mode for the USB (/UART) bootloading mode. Boot0 = 1 will start this bootloader on reset, Boot0 = 0 will boot the normal user firmware from flash.

Since you’re using the STLink upload with PlatformIO, you don’t need the chip to enter this bootloader mode, since it does a reset via the SWD programming interface. So I’d just leave it there on 00 and upload / program as normal. Then, also no explicit reset press should be needed, because it again resets the chip via the SWD commands.

No unfortunately, I try it without the same result as Arduino IDE.
I need to move back the jumper to see the Led blinking.
Regards.
Vincent.

Yes, when I use Arduino IDE to upload the sketch I use ST-Link V2. With this setup Arduino-Setup
In that configuration after upload the Led blink directly.

And with PlatformIO plus the jumpers set to “operating mode” (00) the LED doesn’t blink directly after upload?

Ok, back to platformio, I put jumpers to (00) and now that’s working !
I change the time and after Upload the ST-Link Led is blinking and the BluePill Led blink at the new time I program. Without Reset and moving jumper.
Not sure to understand, but the fact is that’s works now.
Thanks a lot for your support !!!
Now time to sleep for me … Tomorrow I will try the debug breakpoints on code with VSCode and PlatformIO.
Regards.
Vincent.

By the way do you know how to setup the launch.json ?

You should not need to manually setup the file. When you have exported the project for VSCode (pio init --ide=vscode), or have created the project directly with it through the plugin, it is autogenerated. For example

// AUTOMATICALLY GENERATED FILE. PLEASE DO NOT MODIFY IT MANUALLY

// PIO Unified Debugger
//
// Documentation: https://docs.platformio.org/page/plus/debugging.html
// Configuration: https://docs.platformio.org/page/projectconf/section_env_debug.html

{
    "version": "0.2.0",
    "configurations": [
        {
            "type": "platformio-debug",
            "request": "launch",
            "name": "PIO Debug",
            "executable": "c:/Users/Maxi/Documents/stackoverflow_testing/.pio/build/genericSTM32F105RB/firmware.elf",
            "toolchainBinDir": "C:/Users/Maxi/.platformio/packages/toolchain-gccarmnoneeabi/bin",
            "preLaunchTask": {
                "type": "PlatformIO",
                "task": "Pre-Debug"
            },
            "internalConsoleOptions": "openOnSessionStart"
        },
        {
            "type": "platformio-debug",
            "request": "launch",
            "name": "PIO Debug (skip Pre-Debug)",
            "executable": "c:/Users/Maxi/Documents/stackoverflow_testing/.pio/build/genericSTM32F105RB/firmware.elf",
            "toolchainBinDir": "C:/Users/Maxi/.platformio/packages/toolchain-gccarmnoneeabi/bin",
            "internalConsoleOptions": "openOnSessionStart"
        }
    ]
}

Hello, there is probably something missing, in the project I am creating under platformIO, there is a .pio directory but I do not see the rest (pio init --ide = vscode), how should I proceed? Thank you. Vincent.

Here my platformio.ini file : (this is using BluePill + STLink)
inifile
I use the genericSTM32F103C8 and the 2 last lines are necessary !
With this profile I’m able to start debug using platformIO, this is super !

2 Likes