ARM broke it and will not fix it for less-capable boards. I ported mbed (“classic” or “mbed-lib”) to generic Chinese STM32F103C8T6 boards called “Blue Pill” but after merging with RTOS and in current state of mbed-os board with 64KB flash is barely usable because of bloat imposed by (intentionally non-functional) RTOS. I am very sorry to say but the only viable option for these boards now is stm32duino.
Simple code that initializes Serial object and blinks onboard led now compiles to ~55KB firmware so I guess it’s time to move on.
There are many other options than mbed, I wanted it to be “enabler” framework for this hw as it is cheap and quite powerful. It provides nice abstraction just like Wiring, there are some libs that simplify development and it’s overall clean and well supported.
Recently started digging NuttX RTOS and this one looks promising.
The same applies to DISCO_F051R8 target - program that only initializes Serial and writes “Hello world” to UART exceeds available flash (this board has 48k, IDK why neither mbed nor PIO does not barf after compiling but maybe this will happen upon attempt to upload, I don’t have this board at hand):