Page 5 of 6

Re: STM32F103C8 and Fast Bootloader

Posted: Thu Jul 16, 2020 8:21 pm
by fpiSTM
No your one has only 64k.
I've built your sketch and it is huge.
I'm compiling with Generic_F103CB to be able to dump all object size.

Result is:

Code: Select all

Sketch uses 69916 bytes (53%) of program storage space. Maximum is 131072 bytes.
Global variables use 3804 bytes (18%) of dynamic memory, leaving 16676 bytes for local variables. Maximum is 20480 bytes.
So you application + the BL: 78k so an overhead of 13k. Hard to decrease... Lot of libraries which use math and fonts.

In attachment the nm result.
To get the size of the functions (and objects with static storage duration):

Code: Select all

arm-none-eabi-nm --print-size --size-sort --radix=d arduino_build_132202/STM32F103C8_ILI9341_TFT_eSPI.ino.elf
The second column shows the size in decimal of function and objects.
The third column is the symbol type, you can find explanation here: https://sourceware.org/binutils/docs/binutils/nm.html

And below the the size of the sections:

Code: Select all

arm-none-eabi-size -A -d arduino_build_132202/STM32F103C8_ILI9341_TFT_eSPI.ino.elf
The second column shows the size in decimal of the sections.

Code: Select all

section              size        addr
.isr_vector           268   134225920
.text               46864   134226188
.rodata             22520   134273052
.ARM                    8   134295572
.init_array            24   134295580
.fini_array             8   134295604
.data                 532   536870912
.bss                 3272   536871444
.noinit                 0   536874716
._user_heap_stack    1540   536874716
.ARM.attributes        41           0
.comment              102           0
.debug_frame         2428           0
Total               77607

Re: STM32F103C8 and Fast Bootloader

Posted: Thu Jul 16, 2020 8:22 pm
by fpiSTM
Your best bet is to change for a F103CB four your custom board.

Re: STM32F103C8 and Fast Bootloader

Posted: Thu Jul 16, 2020 8:28 pm
by GeorgeIoak
@fpiSTM Thank you for providing all the details, I will study it. I know that the libraries are not optimized and I am also using fonts but lucky for me I showed in the last post that using the HID boot loader did seem to work and even leave bit of flash left.

Re: STM32F103C8 and Fast Bootloader

Posted: Thu Jul 16, 2020 8:50 pm
by fpiSTM
With HID you will decrease of 4k, still 9k to find or try with libMaple core.

Re: STM32F103C8 and Fast Bootloader

Posted: Thu Jul 16, 2020 8:53 pm
by GeorgeIoak
No, I just flashed my board and it is working using the HID bootloader. In my previous post I showed that it fits and is "only" using 92% of the flash space. I didn't make any changes to the sketch and I am also enabling the Serial port.

Re: STM32F103C8 and Fast Bootloader

Posted: Thu Jul 16, 2020 10:01 pm
by fpiSTM
Ok, so without USB CDC ;)

Re: STM32F103C8 and Fast Bootloader

Posted: Thu Jul 16, 2020 10:04 pm
by GeorgeIoak
fpiSTM wrote:
Thu Jul 16, 2020 10:01 pm
Ok, so without USB CDC ;)
Correct, at least for now I'm using the HID since it seems to work well

Re: STM32F103C8 and Fast Bootloader

Posted: Fri Jul 17, 2020 7:32 am
by ag123
off-topic
the original leaflabs maple ships with a stm32f103cb
https://www.leaflabs.com/maple
which provides 128k flash, i'd guess the leaflab creators planned ahead for real use cases.
the chinese vendors start shipping with the cheaper stm32f103c8 64k flash with the blue pills
so this 64k limit is rather easy to hit at the edge cases
earlier for some reason, the lucky ones get stm32f103c8 64k but incidentally found out it has 128k, 'extra' 64k of 'free' flash.
but it is not reliable to base on such. it may be possible that back then ST has a surplus of 128k units and ST stamped them with as c8
but since the blue pill manufacturers will order only c8, the 128k ones will soon sell out and more than likely u'd get one that is made to specs 64k
now it seem some manufacturers are getting meaner and some shipped fakes, bad
my guess is if the industry has settled for the 128k cb, we'd have somewhat lower average prices for the 128k ones due to economy of volumes the pins and everything else is identical after all

Re: STM32F103C8 and Fast Bootloader

Posted: Fri Jul 17, 2020 10:42 am
by GeorgeIoak
I did a little poking around on the internet to see if there was a different way to determine if you indeed had extra flash but I didn't see anything. You're correct though that it definitely isn't a reliable solution to buy C8 parts and expect them to be CB unless ST is using the same die and just coding them as different parts. It would be interesting to sacrifice a few parts and decap them to look at the dies and compare a C8 to a CB.

Right now the HID boot loader seems to work just fine. Are they any advantages between the different boot loaders? Since the HID provides the serial port and the ability to flash over USB it serves my initial needs but I'm still interested in learning more.

Re: STM32F103C8 and Fast Bootloader

Posted: Fri Jul 17, 2020 10:58 am
by ag123
i think HID boot loader would also need USB-CDC if you want that 'auto reset' to work.
the workaround is to simply press reset manually while uploading, this is the same with the dfu 3s delay boot loader