using small flash / sram mcus say 4k sram and 16k flash say an m0, g0 etc would have quite various challenges running stm32duino.
that in part as stm32duino pack lots of 'standard' initializations and features/functions.
a possible way is to make a 'custom' core, that is 'trimmed down' in terms of functions/features etc.
it'd take quite some skills though which i'm not too good with either.
i think it is possible to examine the symbols compiled into the elf file, that is 1 step before compiling into a 'bin' file.
reviewing the symbols may give some hints to make that custom, heavily trimmed down core.
if possible use something like a stm32f401cc which has adequate ram and flash, this has adequate space (sram and flash), and it is pretty *fast* in part as it has the 'art accelerator' (on chip cache) and FPU.
I think there is the nucleo stm32f401 or f411 which is one of the supported boards.
https://github.com/stm32duino/Arduino_Core_STM32
there are also quite popular stm32f401/f411 'black pill' boards, try searching for them on aliexpress etc
https://stm32-base.org/boards/STM32F401 ... -Pill-V3.0
there are many more from the likes of adafruit
https://www.adafruit.com/product/4382
olimex
https://www.olimex.com/Products/ARM/ST/
etc. get those with adequate ram and flash
i'd think stm32f103c{b,8} (blue pill, maple mini (clones)) is 'doable' but somewhat cram.
and targetting very small mcus like those 4k sram and 16k flash, one would confront the challenges of putting too much into too little space.