~24 KB program storage space but expected closer to 64 KB?

Post here first, or if you can't find a relevant section!
Post Reply
Piter_de_Vries
Posts: 14
Joined: Sat Sep 17, 2022 4:12 pm

~24 KB program storage space but expected closer to 64 KB?

Post by Piter_de_Vries »

I'm working on a sketch for a Blue Pill and have selected "Generic STM32F103C6/fake STM32F103C8" in the Arduino IDE 2.0 board menu. After compiling, the result reads:

Code: Select all

Sketch uses 24044 bytes (97%) of program storage space. Maximum is 24576 bytes.
Is that correct? I thought there should be much more program storage space. There's meant to be 64 KB flash. Is an unreasonable amount being taken up by something else?
by ag123 » Mon Sep 19, 2022 2:33 pm
there are quite some "blue pills" that ship with c6
that has a mere 32 k flash and like 6 - 10 k sram
https://www.st.com/en/microcontrollers- ... 103c6.html

it would be a challenge to "squeeze" stm32duino especially the 'official' STM core in it

In the menu you need to specifically select c8 rather than c6 for it to compile correctly. selecting c6 would likely get in all these flash and sram troubles.
And make sure you have a real C8 as trying to run a C8 binary on a C6 would likely just crash without any response. It would look like it "doesn't work", unless you figured out how to use st-link to debug it. it isn't difficult, but you would need to set up st-link / debug and debug away to find why it "hang".
most likely a memory fault - out of memory.
Go to full post
ag123
Posts: 1653
Joined: Thu Dec 19, 2019 5:30 am
Answers: 24

Re: ~24 KB program storage space but expected closer to 64 KB?

Post by ag123 »

there are quite some "blue pills" that ship with c6
that has a mere 32 k flash and like 6 - 10 k sram
https://www.st.com/en/microcontrollers- ... 103c6.html

it would be a challenge to "squeeze" stm32duino especially the 'official' STM core in it

In the menu you need to specifically select c8 rather than c6 for it to compile correctly. selecting c6 would likely get in all these flash and sram troubles.
And make sure you have a real C8 as trying to run a C8 binary on a C6 would likely just crash without any response. It would look like it "doesn't work", unless you figured out how to use st-link to debug it. it isn't difficult, but you would need to set up st-link / debug and debug away to find why it "hang".
most likely a memory fault - out of memory.
ag123
Posts: 1653
Joined: Thu Dec 19, 2019 5:30 am
Answers: 24

Re: ~24 KB program storage space but expected closer to 64 KB?

Post by ag123 »

if you have to buy another board go for stm32f401CCu or f411CEu "pill boards" - so called 'black pill' - but careful, there are stm32f103 ones floating around.
they need to specifically state STM32F401>CC<U (STM32F401CC) or STM32F411>CE<U (STM32F401CE).
Check the specs on ST's web site.
https://stm32-base.org/boards/
https://www.st.com/en/microcontrollers- ... 401cc.html
https://www.st.com/en/microcontrollers- ... 411ce.html

Preferably, just go for Nucleo STM32F401RE or Nucleo STM32F411RE.
Those list among the supported boards - STM32F401RE or F411RE has plenty of resources and pins
https://github.com/stm32duino/Arduino_C ... -64-boards

There are faster chips like the STM32F405RG or STM32F407VE or STM32F407VG boards.
for sure they cost more e.g.
Adafruit Feather STM32F405 Express
https://www.adafruit.com/product/4382
PYboard (with STM32F405RG) - MicroPython
https://store.micropython.org/product/PYBLITEv1.0
Olimex STM32-H405 - note get the original ST one.
https://www.olimex.com/Products/ARM/ST/STM32-H405/
for the STM32F407VE and VG boards, you could try searching in the online "flea markets" alix/amazon/ebay etc. with those part numbers
these are 168 Mhz chips with that 'ART Accelerator' (i.e. on chip cache) and FPU (single precision)

I'd guess it may be possible to "squeeze" stm32duino into a C6, but I'd leave it to you if you want to confront the challenge.
It mostly has to do with selecting the 'right' optimizations e.g. select -Os smallest, and omitting as many peripherals as possible.
e.g. do without usb-serial.
Piter_de_Vries
Posts: 14
Joined: Sat Sep 17, 2022 4:12 pm

Re: ~24 KB program storage space but expected closer to 64 KB?

Post by Piter_de_Vries »

Thanks for the responses. I will try to figure out what I actually have. I bought a few of them a couple of years ago. Hopefully they're not C6s.

Edit: whatever I have seems to give the expected 64 KB. When I try to use "BluePill Diagnostics v1.640", installed via STM32 ST-Link Utility, it seems to crash when I do "test for hidden second 64 KB flash block".

Image

I have to unplug the board and plug it back in again to continue interacting with the menu. At least I have a useable amount of space.
ozcar
Posts: 143
Joined: Wed Apr 29, 2020 9:07 pm
Answers: 5

Re: ~24 KB program storage space but expected closer to 64 KB?

Post by ozcar »

I'm not sure why you would have selected board "Generic STM32F103C6/fake STM32F103C8" in the first place, unless the chip was marked C6.

Fake C8s may have less than 64K, but could well have 64K or 128K, so I think that board name is a bit confusing. However, the fact that you have that as a selection tells me that you are using the "Roger" core, not the "official" STM core. I think the recommendation these days is for beginners to use the "official" STM core, unless you have some good reason not to use that. Reasons for that might include if you were interested in some existing code that is known to not be compatible with the STM core, or if you were very tight for space (the STM core supports many more boards, but the Roger core may produce leaner code for the few boards that it does support).

I'm guessing it was telling you 24K max, rather than 32K because you are using a bootloader. If you are really tight for space, eliminating the bootloader might get you over the line. I always use STLINK, which needs no bootloader, and could be useful down the track for serious debugging.

I've never had the diagnostics fail like that, but then none of my F103 boards have less than 128K flash.
Piter_de_Vries
Posts: 14
Joined: Sat Sep 17, 2022 4:12 pm

Re: ~24 KB program storage space but expected closer to 64 KB?

Post by Piter_de_Vries »

I selected the option I did because I thought that what I have is a fake STM32F103C8. The option does not make it clear that it is for STM32F103C6s which are pretending to be STM32F103C8s. I thought it was for both STM32F103C6s and fake STM32F103C8s.

I will probably only look into how to remove the Roger core and insert the STM official core if my project does not work as intended. I followed some instructions a long time ago on how to get the Blue Pill into the IDE and I don't remember which instructions and I doubt I much understood what I was doing. Still don't, tbh.
Post Reply

Return to “General discussion”