Empty Sketch/Program Taking 13.4KB flash...

Post here all questions related to LibMaple core if you can't find a relevant section!
Post Reply
User avatar
Mangy_Dog
Posts: 91
Joined: Sat May 02, 2020 11:45 pm
Answers: 1

Empty Sketch/Program Taking 13.4KB flash...

Post by Mangy_Dog »

Hi, ok I know this is an old topic. I remember reading about this one a long long time ago... BUT....

Using Rogers core, even a blank sketch/program Its taking up 13.4KB of flash.
The thing is I just scored 40 STM32f103C6 chips at a reasonable price (£1 each at least its reasonable in todays market) And the 32KB flash would be fine for many of my smaller projects that I might use a atmega328 for.

But right off the bat, half that flash is lost to something........ Like I say I know this topic was raised before. Is it the USB stack for emulated Serial?

In the case of Arduino IDE the upload method is stlink, so there shouldnt be a boot loader.

Im assuming this can be optimised out. Just would like to know how?
Just a dogs body developer, mostly making props and stuff...
ag123
Posts: 1655
Joined: Thu Dec 19, 2019 5:30 am
Answers: 24

Re: Empty Sketch/Program Taking 13.4KB flash...

Post by ag123 »

I think in boards.txt, you'd find somewhere where usb-serial is defined.
you may like to 'comment' that define and rebuild.
That said you lose usb serial if it isn't compiled into the core.
the other 'extras' comes form the use of c++ build flags, e.g. select -Os smallest etc.
and that the core do initialize quite a few pheriperials, so things like ADC, Timers, UART, dma etc are probably part of the build.
32k is 'too cramp' for 'comfortable' usage.
i think there are also 'elf file viewers', e.g.
http://www.sunshine2k.de/coding/javascr ... iewer.html
google for 'elf file viewers' would turn up more 'viewers'
those could help examine the symbols that has been compiled into the core

oh i think there is also objdump, look inside the compiler folder, that can be used to dump info on the sections etc.
User avatar
Mangy_Dog
Posts: 91
Joined: Sat May 02, 2020 11:45 pm
Answers: 1

Re: Empty Sketch/Program Taking 13.4KB flash...

Post by Mangy_Dog »

I dont use USB serial any more anyway... So thats ok.
Selectively turning off unused peripherals would be fine too.
Just a dogs body developer, mostly making props and stuff...
User avatar
Mangy_Dog
Posts: 91
Joined: Sat May 02, 2020 11:45 pm
Answers: 1

Re: Empty Sketch/Program Taking 13.4KB flash...

Post by Mangy_Dog »

removing USB shaved 2KB off... Could do with shaving more if possible :)

Is there any more config files to turn off the bits i dont need?
Just a dogs body developer, mostly making props and stuff...
mrburnette
Posts: 633
Joined: Thu Dec 19, 2019 1:23 am
Answers: 7

Re: Empty Sketch/Program Taking 13.4KB flash...

Post by mrburnette »

Mangy_Dog wrote: Sat Jan 15, 2022 3:37 pm ... I just scored 40 STM32f103C6 chips at a reasonable price (£1 each at least its reasonable in todays market) And the 32KB flash would be fine for many of my smaller projects that I might use a atmega328 for.
...
If you are just doing Arduino small projects that would have/could-be done with an UNO, just use Roger's core! Yes, the STM32 Official core is more mature/modern, but an old monolithic core is just fine for blinking, servos, and A/D stuff.

The F1 core has been updated in 2021


Ray
ag123
Posts: 1655
Joined: Thu Dec 19, 2019 5:30 am
Answers: 24

Re: Empty Sketch/Program Taking 13.4KB flash...

Post by ag123 »

taking more out would likely mean 'disconnecting' the dependencies, and this would likely need changes in the core codes, as you literally need to remove the references and calls. i'd guess it'd be better to just backup the core somewhere while you modify it.

some of the flags that may be worth exploring includes:
-fomit-frame-pointer
-Wl,--gc-sections
-Xlinker --gc-sections
-ffunction-sections -fdata-sections \
-fmessage-length=0 -fsigned-char \
-ffreestanding -fno-move-loop-invariants
--specs=nano.specs

c++ flags:
-fno-rtti -fno-exceptions
-fno-use-cxa-atexit -fno-threadsafe-statics

these are probably in plaatform.txt and some of these may already be there. some of them may literally bloat the codes rather than reduce it.
there are other flags I've tried like
-nostartfiles
-nodefaultlibs
-nostdlib

some of the flags like those no start files, no stdlibs etc would likely break things, so it would take experimenting.
User avatar
fpiSTM
Posts: 1737
Joined: Wed Dec 11, 2019 7:11 pm
Answers: 91
Location: Le Mans
Contact:

Re: Empty Sketch/Program Taking 13.4KB flash...

Post by fpiSTM »

The main change with 2.x.x core version is that all pins are now available in the peripheralPins.c. therefore it's increase size in flash. Those array can be redefined ar sketch level as they are weak. Simply define them with pins required.
Post Reply

Return to “General discussion”