Upload Marlin Firmware with ST-Link to BTT SKR MINI E3 V1.2 not working

Hello dear community, I have a Bigtreetech SKR MINI E3 V1.2 mainboard that had a defective microcontroller (STM32F103RC). After desoldering the MCU and replacing it with a new one, I wanted to flash the Marlin firmware with the ST-Link via the SWD interface. According to PlatformIO, the upload was successful, but the mainboard did not work. To check the function of the MCU, I uploaded a code with the Arduino IDE that should make the status LED of the SKR Mini flash. That worked, so I uploaded Marlin again with PlatformIO via the ST-Link, which was successful, but the mainboard did not work. What surprised me was that the status LED continued to flash despite the Marlin upload, so the test code was not erased.

Does anyone know what mistake I have made?
I suspect it has to do with the bootloader or the PlatformIO settings, but I don’t know what I should change. I would therefore be grateful for any advice.

First of all: The new MCU I soldered in is 100% original and not a fake. It is also recognized by the STM32 cube programmer software.

Thank you very much.

What is the output of the “Upload” project task?

Here is the output from the upload:

The Marlin configuration for the F103RC_btt expects a bootloader to be present in the first 0x7000 (=28672) bytes of flash. The actual firmware code is flashed to 0x08007000 instead of 0x08000000 (start of flash).

If this bootloader is not present, the firmware fails to start. (The microcontroller starts execution from 0x08000000)

The bootloader is likely responsible for e.g. accepting firmware updates via SD card or USB.

It could be that the firmware you uploaded in the Arduino IDE that just makes the LED blink was written to the start of flash (0x8000000) and thus worked normally.

I see 2 possibilities here:

  1. Run the Marlin firmware without a bootloader. (This means you won’t have that "upgrade via SD card functionality or whatever the bootloader provides!). I.e., comment out or delete the lines
board_build.offset          = 0x7000
board_upload.offset_address = 0x08007000
  1. Find and flash the original bootloader to your board, e.g. using ST-Link Utility or STM32CubeProg as programming tool to burn the bootloader bin file to the 0x08000000 address. The bootloader can apparently be found here. This will get you the original, intended functionality.
  2. Plus, if a self compiled marlin won’t run at all, you can still burn the original bootloader + Marlin firmware from this file.