Can't Make STM32F103CB to Work with Mbed - `FLASH` Overflowed

Hi,

I want to use Mbed with STM32F103CB. I have followed every instruction I found on the internet. If I use stm32f103c8 as my board in platformio.ini, then I will get this error, no matter how much I config every file:
.platformio/packages/toolchain-gccarmnoneeabi/bin/../lib/gcc/arm-none-eabi/9.2.1/../../../../arm-none-eabi/bin/ld.exe: .pio/build/bare_metal_release/firmware.elf section '.text' will not fit in 'FLASH' .platformio/packages/toolchain-gccarmnoneeabi/bin/../lib/gcc/arm-none-eabi/9.2.1/../../../../arm-none-eabi/bin/ld.exe: region 'FLASH' overflowed by 7852 bytes

If I set my board to stm32f103cb, then it’s not supported by Mbed, and no matter how much I config files, I still get this error of board not supported, cannot find config or cannot find info unless I change the genericSTM32F103CB in variants_remap.json file to BLUEPILL_F103C8, which causes the first error mentioned above. I’m stuck and tired. Any would be much appreciated!

Just dynamically change the maximum upload size in the platformio.ini and fixup the linker template.

If I create a project with the platformio.ini

[env:genericSTM32F103C8]
platform = ststm32
board = genericSTM32F103C8
framework = mbed
; set 128K flash
board_upload.maximum_size = 131072

with src\main.cpp and mbed_app.json from platform-ststm32/examples/mbed-rtos-blink-baremetal at develop · platformio/platform-ststm32 · GitHub, then modify in C:\Users\<user>\.platformio\packages\framework-mbed@6.51506.201227\targets\TARGET_STM\TARGET_STM32F1\TARGET_BLUEPILL_F103C8\device\TOOLCHAIN_GCC_ARM\STM32F103XB.ld the 64K value to 128K, it all works nicely.

Linking .pio\build\genericSTM32F103C8\firmware.elf
Checking size .pio\build\genericSTM32F103C8\firmware.elf
Advanced Memory Usage is available via "PlatformIO Home > Project Inspect"
RAM:   [==        ]  16.2% (used 3312 bytes from 20480 bytes)
Flash: [====      ]  36.7% (used 48064 bytes from 131072 bytes)
Building .pio\build\genericSTM32F103C8\firmware.bin
==========[SUCCESS] Took 11.18 seconds ==========

The root of the problem is that mbed-os in the used version only has TARGET_BLUEPILL_F103C8, not the CB version, but the linker script change above basically creates that.

1 Like

Thanks! You saved me!
I had done this before, but I have edited the wrong ld file (I have edited the one in the ststm32 folder).
Thanks again!