Sketch uses 85056 bytes (76%) of program storage space. Maximum is 110592 bytes.
Global variables use 6272 bytes of dynamic memory.
How can I reduce the program space?
blabla my_variable = new some_fancy_class;http://danieleff.com/stm32/map_analizer/
If you don’t use “new” or think that doesn’t account for all the space difference, get your file from your build folder, upload it, and will help you find what’s taking space. If you have doubts with anything you find there post back to see if someone can give you extra advise.
-fmessage-length=0
-fsigned-char
-ffunction-sections
-fdata-sections
-ffreestanding
-fno-move-loop-invariants
-fno-exceptions
-fno-rtti
-fno-use-cxa-atexit
-fno-threadsafe-statics
-nostdlib
-Xlinker --gc-sections
--specs=nano.specs
blabla my_variable = new some_fancy_class;http://danieleff.com/stm32/map_analizer/
If you don’t use “new” or think that doesn’t account for all the space difference, get your file from your build folder, upload it, and will help you find what’s taking space. If you have doubts with anything you find there post back to see if someone can give you extra advise.
-nostdlib
-Xlinker --gc-sections
-specs=nano.specs
-fno-exceptions
-fno-rtti
-fno-use-cxa-atexit
-fno-threadsafe-statics
https://github.com/rogerclarkmelbourne/ … 2a824d80b7
By the addition of new.cpp
However, it does not seem to work in all circumstances
Someone will need to investigate why the functions in new.cpp are not being called in this case
-nostdlib
-Xlinker --gc-sections
-specs=nano.specs
-fno-exceptions
-fno-rtti
-fno-use-cxa-atexit
-fno-threadsafe-statics
https://github.com/rogerclarkmelbourne/ … 2a824d80b7
By the addition of new.cpp
However, it does not seem to work in all circumstances
Someone will need to investigate why the functions in new.cpp are not being called in this case
all the basic stuff takes up more space than what you see on an arduino, but you have plenty of space to continue working with
all the basic stuff takes up more space than what you see on an arduino, but you have plenty of space to continue working with
Don´t worry, any further added code does not increase the code size proportionally.
Can you also share a map file? Looking to the MAP file you can determine which modules causes the largest code size.
It seems that the code you shared is not all what you are using, there are some libraries missing.
Sketch uses 12876 bytes (19%) of program storage space. Maximum is 65536 bytes.
Global variables use 2816 bytes of dynamic memory.
While this code with UNO is:
Sketch uses 928 bytes (2%) of program storage space. Maximum is 32256 bytes.
Global variables use 9 bytes (0%) of dynamic memory, leaving 2039 bytes for local variables. Maximum is 2048 bytes.
Sketch uses 85056 bytes (76%) of program storage space. Maximum is 110592 bytes.
Global variables use 6272 bytes of dynamic memory.
How can I reduce the program space?
Sketch uses 22124 bytes (4%) of program storage space. Maximum is 524288 bytes.
For grins I tested against my msp430g2553 arduino port:
Sketch uses 808 bytes (4%) of program storage space. Maximum is 16384 bytes.
Global variables use 18 bytes (3%) of dynamic memory, leaving 494 bytes for local variables. Maximum is 512 bytes.
The bottom line, the size of the code depends on the chip architecture, the compiler used, the actual core code, and how you code your program.
e.g. on stm32 there is usb-serial and stm32f1 is a native usb device, uno *don’t do usb and can’t do usb*, stm32 also has many more other resources such as 2 SPI ports, uarts, ADCs, DMA, clocks that can be programmed on the fly, turning on / off clocks to individual peripheral buses, multiple AFIO assignments, low power states etc etc. having support for these hardware may inevitably require more codes to support it hence a somewhat bulkier binary size
hence my guess is when compilers are building for atmega328, things that is ‘not there’ is simply *skipped* as the mcu won’t have the hardware to support them and would result in compile errors if they are built after all
the FastLeds library seemed rather large i’d think, i’m not too sure if it contain ifdefs that perhaps to skip over sections of code that’s not used, otherwise when the library is compiled, all the related objects may be included in the binary hence contributing to binary bloat as well
with STM32F103C8 IC is:
Sketch uses 12876 bytes (19%) of program storage space. Maximum is 65536 bytes.
Global variables use 2816 bytes of dynamic memory.
Sketch uses 85056 bytes (76%) of program storage space. Maximum is 110592 bytes.
Global variables use 6272 bytes of dynamic memory.
How can I reduce the program space?
e.g. on stm32 there is usb-serial and stm32f1 is a native usb device, uno *don’t do usb and can’t do usb*, stm32 also has many more other resources such as 2 SPI ports, uarts, ADCs, DMA, clocks that can be programmed on the fly, turning on / off clocks to individual peripheral buses, multiple AFIO assignments, low power states etc etc. having support for these hardware may inevitably require more codes to support it hence a somewhat bulkier binary size
After a while, and try and error I add
-fno-threadsafe-statics


