Uploaded code doesn't work (stm32f103rc)

I have a custom designed pcb with stm32f103rct6 and i want to program it with platformio, first i tried blink example and uploaded the code with arduino ide and it works, but when i tried the same code in platformio it uploads successfully but the led doesn’t blink, it says target halted due to debug request i don’t know if that’s the problem.

xPack OpenOCD x86_64 Open On-Chip Debugger 0.11.0+dev (2021-10-16-21:15)
Licensed under GNU GPL v2
For bug reports, read
        http://openocd.org/doc/doxygen/bugs.html
debug_level: 1

hla_swd
target halted due to debug-request, current mode: Thread 
xPSR: 0x01000000 pc: 0x1ffff020 msp: 0x200001fc
** Programming Started **
** Programming Finished **
** Verify Started **
** Verified OK **
** Resetting Target **
shutdown command invoked

platformio.ini:

[env:genericSTM32F103RC]
platform = ststm32
board = genericSTM32F103RC
framework = arduino
;debug_tool = stlink
upload_protocol = stlink

Any idea what could be the problem?

  • What code are you running exactly?
  • Did you use the Maple core or STM32Duino in the Arduino IDE?
  • Give a screenshot if the Arduino IDE → Tools menu so that we can see the exact configuration you used there?
  • What board are you running it on exactly? Does the board have a HSE crystal (e.g. 8MHz)?

Uploaded code:

int previousMillis = 0;        // will store the last time the LED was updated
int interval = 3000;            // interval at which to blink (in milliseconds)
int pin = PA15;

void setup() {
    // Set up the built-in LED pin as output:
    pinMode(pin, OUTPUT);
}

void loop() {
    // Check to see if it's time to blink the LED; that is, if the
    // difference between the current time and last time we blinked
    // the LED is bigger than the interval at which we want to blink
    // the LED.
    if (millis() - previousMillis > interval) {
        // Save the last time you blinked the LED
        previousMillis = millis();

        // If the LED is off, turn it on, and vice-versa:
        digitalWrite(pin,!digitalRead(pin));// Turn the LED from off to on, or on to off
    }
}

I used stm32 duino
It’s a custom design board, i have an external 16MHz crystal.
screenshot

This configuration menu doesn’t look like the STM32Duino at all, and STM32Duino does not know of a “Generic STM32F103R series” board. Looks like you used Maple instead with this board.

As per documentation, add

board_build.core = maple

to the platformio.ini. Does it make a difference?

Thanks now it works, but a new problem appeared, i have a ili9341 display and i am using the adafruit library which works if i upload it using arduino ide maple, but it doesn’t work with stm32duino, and in vscode it doesn’t even work with maple, it doesn’t compile, but with stm32duino core it does compile but the display doesn’t work. Not sure why, any ideas?

errors when compiling in vscode with maple core:

.pio/libdeps/genericSTM32F103RC/Adafruit BusIO/Adafruit_I2CDevice.cpp: In member function 'bool Adafruit_I2CDevice::write(const uint8_t*, size_t, bool, const uint8_t*, size_t)':
.pio/libdeps/genericSTM32F103RC/Adafruit BusIO/Adafruit_I2CDevice.cpp:110:47: error: invalid conversion from 'const uint8_t* {aka const unsigned char*}' to 'uint8* {aka unsigned char*}' [-fpermissive]
     if (_wire->write(prefix_buffer, prefix_len) != prefix_len) {
                                               ^
In file included from /home/jfkjhgsd/.platformio/packages/framework-arduinoststm32-maple/STM32F1/libraries/Wire/Wire.h:42:0,
                 from .pio/libdeps/genericSTM32F103RC/Adafruit BusIO/Adafruit_I2CDevice.h:5,
                 from .pio/libdeps/genericSTM32F103RC/Adafruit BusIO/Adafruit_I2CDevice.cpp:1:
/home/jfkjhgsd/.platformio/packages/framework-arduinoststm32-maple/STM32F1/libraries/Wire/utility/WireBase.h:123:12: note:   initializing argument 1 of 'size_t WireBase::write(uint8*, int)'
     size_t write(uint8*, int);
            ^~~~~
.pio/libdeps/genericSTM32F103RC/Adafruit BusIO/Adafruit_I2CDevice.cpp:119:31: error: invalid conversion from 'const uint8_t* {aka const unsigned char*}' to 'uint8* {aka unsigned char*}' [-fpermissive]
   if (_wire->write(buffer, len) != len) {
                               ^
In file included from /home/jfkjhgsd/.platformio/packages/framework-arduinoststm32-maple/STM32F1/libraries/Wire/Wire.h:42:0,
                 from .pio/libdeps/genericSTM32F103RC/Adafruit BusIO/Adafruit_I2CDevice.h:5,
                 from .pio/libdeps/genericSTM32F103RC/Adafruit BusIO/Adafruit_I2CDevice.cpp:1:
/home/jfkjhgsd/.platformio/packages/framework-arduinoststm32-maple/STM32F1/libraries/Wire/utility/WireBase.h:123:12: note:   initializing argument 1 of 'size_t WireBase::write(uint8*, int)'
     size_t write(uint8*, int);
            ^~~~~
*** [.pio/build/genericSTM32F103RC/lib54d/Adafruit BusIO/Adafruit_I2CDevice.cpp.o] Error 1
.pio/libdeps/genericSTM32F103RC/Adafruit BusIO/Adafruit_SPIDevice.cpp: In member function 'void Adafruit_SPIDevice::transfer(uint8_t*, size_t)':
.pio/libdeps/genericSTM32F103RC/Adafruit BusIO/Adafruit_SPIDevice.cpp:133:31: error: no matching function for call to 'SPIClass::transfer(uint8_t*&, size_t&)'
     _spi->transfer(buffer, len);
                               ^
In file included from .pio/libdeps/genericSTM32F103RC/Adafruit BusIO/Adafruit_SPIDevice.h:9:0,
                 from .pio/libdeps/genericSTM32F103RC/Adafruit BusIO/Adafruit_SPIDevice.cpp:1:
/home/jfkjhgsd-/.platformio/packages/framework-arduinoststm32-maple/STM32F1/libraries/SPI/src/SPI.h:285:11: note: candidate: uint8 SPIClass::transfer(uint8) const
     uint8 transfer(uint8 data) const;
           ^~~~~~~~
/home/jfkjhgsd/.platformio/packages/framework-arduinoststm32-maple/STM32F1/libraries/SPI/src/SPI.h:285:11: note:   candidate expects 1 argument, 2 provided
*** [.pio/build/genericSTM32F103RC/lib54d/Adafruit BusIO/Adafruit_SPIDevice.cpp.o] Error 1