BluePill: why such a huge code size?

Post here first, or if you can't find a relevant section!
Post Reply
User avatar
ogogon
Posts: 7
Joined: Fri Jan 24, 2020 6:24 pm

BluePill: why such a huge code size?

Post by ogogon »

Colleagues, tell me, please, why I get such a huge code?

I'm compiling the classic Blink program for BluePill (F103C8). USB support is disabled. Optimize is Smallest.
The built code takes up 10752 KB, 16% of the total memory for the program. Global variables use 836 bytes.

The program in five lines reads and writes only one port.
For God's sake, what does the compiler put in there?

Ogogon.
"'But oh, beamish nephew, beware of the day, If your Snark be a Boojum! For then
You will softly and suddenly vanish away, And never be met with again!"
User avatar
fpiSTM
Posts: 1738
Joined: Wed Dec 11, 2019 7:11 pm
Answers: 91
Location: Le Mans
Contact:

Re: BluePill: why such a huge code size?

Post by fpiSTM »

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

Re: BluePill: why such a huge code size?

Post by ag123 »

if you use USB (CDC) serial, that one consumes quite a bit of flash. then ADC etc. For what is worth, the codes isn't catering to a simple 'Uno' type scenario, but practically across the swatch of stm32 series.
get an mcu with more flash and ram e.g. stm32f401/f411 ce or better f401re,ve/f411re,ve/f405re,ve. Those have plenty of flash and ram and can easilly fit lots of codes and data. stm32duino is more than just bare metal programming, it is a little os in itself.
dannyf
Posts: 447
Joined: Sat Jul 04, 2020 7:46 pm

Re: BluePill: why such a huge code size?

Post by dannyf »

10k is not bad. It has time keeping, various tables, interrupts, constants, ...

I think the bare minimum is somewhere around 2k. And then you pay a price for 32bit code density...

I think the 8bit Arduino compiles to around 10k as well.
User avatar
fpiSTM
Posts: 1738
Joined: Wed Dec 11, 2019 7:11 pm
Answers: 91
Location: Le Mans
Contact:

Re: BluePill: why such a huge code size?

Post by fpiSTM »

Re-do the test by doing customization:
Sketch uses 4320 bytes (6%) of program storage space. Maximum is 65536 bytes.
Global variables use 72 bytes (0%) of dynamic memory, leaving 20408 bytes for local variables. Maximum is 20480 bytes.
with Serial disabled, USB disabled and hal_conf_extra.h:

Code: Select all

#define HAL_ADC_MODULE_DISABLED
#define HAL_I2C_MODULE_DISABLED
#define HAL_RTC_MODULE_DISABLED
#define HAL_SPI_MODULE_DISABLED
#define HAL_TIM_MODULE_DISABLED
#define HAL_DAC_MODULE_DISABLED
#define HAL_EXTI_MODULE_DISABLED
#define HAL_OSPI_MODULE_DISABLED
arpruss
Posts: 83
Joined: Sat Dec 21, 2019 10:06 pm

Re: BluePill: why such a huge code size?

Post by arpruss »

I bet it's a bit smaller if you use the libmaple core, too.
nahihua535
Posts: 1
Joined: Sat Mar 25, 2023 6:43 am

Re: BluePill: why such a huge code size?

Post by nahihua535 »

Ah ok. Thanks. That's crazy markup. A lot of these chips (tens of thousands?) could fit in a box that could ship from china for $10. I can see how this is very lucrative for Digikey. netgear login

pikashow.ltd
Last edited by nahihua535 on Tue Apr 04, 2023 4:12 pm, edited 1 time in total.
dannyf
Posts: 447
Joined: Sat Jul 04, 2020 7:46 pm

Re: BluePill: why such a huge code size?

Post by dannyf »

That's crazy markup. A lot of these chips (tens of thousands?) could fit in a box that could ship from china for $10.
ic smuggling is a big business.

Code: Select all

 I can see how this is very lucrative for Digikey.
I think digikey did a buy-out ~15 years or so ago. lots of interesting things there. I would suggest two things (not absolutely correct but directionally correct):
1. they make little money for large quantity orders (aka 10K chips)
2. they make lots of money for small quantity orders (aka 10 resistors).

so you can think of their pricing on 1K chips as basically their cost basis. the large quantity pricing is so you place an order for your entire bom with them.
Post Reply

Return to “General discussion”