Code size

Post here first, or if you can't find a relevant section!
dannyf
Posts: 447
Joined: Sat Jul 04, 2020 7:46 pm

Re: Code size

Post by dannyf »

it lets you 'swap libraries' with the same api.
I have been doing that for a long time.

I started with Luminary chips and their stellaris library. however, I didn't use their libraries directly. Instead, I put a middle layer on top of it which my code accesses, with the goal that in the future, I could swap out the luminary library with my own code.

when ST's SPL came out, I did the same. this approach allowed me to get up to speed on a chip quickly, and then I can get rid of the vendor library.

A broader approach is also taken with me maintaining almost identical middle ware of my own from chip to chip. I can basically write to a PIC and then port it to a TM4C, with minimum changes to the user code.

An approach I would recommend to anyone.
dannyf
Posts: 447
Joined: Sat Jul 04, 2020 7:46 pm

Re: Code size

Post by dannyf »

as to my chips for development, I use mostly PIC24 or PIC32 nowadays. More resources than I know how to use :)
dannyf
Posts: 447
Joined: Sat Jul 04, 2020 7:46 pm

Re: Code size

Post by dannyf »

re. code size:

for my own port on a Cortex-M0 (STM32F030):

1. if I have an empty setup() and loop(), i consume about 2k (code + data). That includes the ISRs, port definitions, F_CPU, ...
2. a minimum implementation (flip led on a pin, uart, and some timing), I consume about 2.5k (code + data).

Similar numbers on a Cortex-M3 (STM32F103).

So I think if you get wildly different numbers than that, you should question your compiler / compiler settings.
herbk
Posts: 4
Joined: Sun Sep 04, 2022 10:06 am

Re: Code size

Post by herbk »

dannyf wrote: Sat Sep 17, 2022 3:14 pm So I think if you get wildly different numbers than that, you should question your compiler / compiler settings.
For an empty sketch i get about 6,5k for the STM32F103.
OK, because i'm new to the "STM World" i leave the Settings as they are, so may be this makes the different...
ag123
Posts: 1655
Joined: Thu Dec 19, 2019 5:30 am
Answers: 24

Re: Code size

Post by ag123 »

If you used libmaple ('rogers') core, it is likely more compact, it is specifically made / written to run only and only on stm32f103c8 and stm32f103cb.
that comes from the "old" maple mini, where it started.
libmaple ('rogers') core is deemed 'for experts' these days, it is nearly a 'from scratch' stm32duino core handcrafted to work on a specific processor (stm32f103c8 and stm32f103cb.) - lean and maybe *fast*
for the 'official' core, the attempt is to 'cross series', this is one of the biggest difference, it uses STM32 Cube HAL and attempts to run on many different boards.
As such, you get a large board list there
https://github.com/stm32duino/Arduino_C ... ted-boards

valuable if you (may) intend to 'cross series' e.g. to simply use a different board. There is a chance a sketch written for (i.e. source code level) stm32f103 c8 'just works' on say stm32f4xx and even 'higher' chips. Though not necessarily all the time. There are some (hardware) architecture differences between stm32f103xx series vs the stm32f4xx series.
That may work if you can stick to the arduino API and the 'official' stm32duino API.
https://github.com/stm32duino/wiki/wiki/API
i.e. you may be able to 'cross series' by simply using that same API, but no promises though.

oh and 'play' with the settings optimizations e.g. -Os optimize size, smallest, there is this "LTO" link time optimization - earlier compilers actually removed too much codes and cause some apps to crash, current compilers may have solved it, I'd not know, but if you are 'testing' after all, i'd guess you could try it.
"LTO" etc are mainly there for the 'official' core only. the old 'libmaple' core don't have all these as they are based on even earlier 'prehistoric' compilers. Though it'd just build with new compilers as well.
Post Reply

Return to “General discussion”