Good afternoon,
I am working on a ESP32S3 WROOM 1 module and after writing some part of my firmware,
I see that the code size after compilation is quite big (600Ko).
However, I did not write a lot of code and I have seen some bigger programs on other microcontroller
with a size smaller than the one of my firmware.
I am using Bluetooth with Bluedroid library, I have included the Helix MP3 library and have juste written
some tasks without a lot of instructions inside.
Do you know if there a options or something like that, which can be used in order to optimize the size of the code
after compilation ?
Do you have any ideas please ?
Best regards,
Thomas TRUILHE
ESP32S3 : Possible to optimise the compilation ??
-
- Posts: 229
- Joined: Thu Jul 14, 2022 5:15 am
-
- Posts: 1710
- Joined: Mon Oct 17, 2022 7:38 pm
- Location: Europe, Germany
Re: ESP32S3 : Possible to optimise the compilation ??
Yes, you can choose to compile optimized for speed (-O2), debugging (-Og), or size (-Os), selectable in menuconfig.
However, you probably don't have to worry about code size (yet): There is a huge overhead (a few 100's of kb) for OS, WiFi/Bluetooth binaries, driver code &c. Fortunately, this overhead occurs only once and is independent of your own code. So, when you see 600kb of flash used, it could be quasi-constant 400kb of "system" code and only 200kb of your application code; in other words, if you have 4Mb of flash, and system occupies 10% of that, then your actual application at the moment only consumed 200kb/(4096kb-10%) ~ 5% of what you can use. (Just some rough guestimations, but the point is that once the big chunk of system code is included in your binary the application will go on to grow relatively slowly as you add more of your application code.)
However, you probably don't have to worry about code size (yet): There is a huge overhead (a few 100's of kb) for OS, WiFi/Bluetooth binaries, driver code &c. Fortunately, this overhead occurs only once and is independent of your own code. So, when you see 600kb of flash used, it could be quasi-constant 400kb of "system" code and only 200kb of your application code; in other words, if you have 4Mb of flash, and system occupies 10% of that, then your actual application at the moment only consumed 200kb/(4096kb-10%) ~ 5% of what you can use. (Just some rough guestimations, but the point is that once the big chunk of system code is included in your binary the application will go on to grow relatively slowly as you add more of your application code.)
-
- Posts: 1710
- Joined: Mon Oct 17, 2022 7:38 pm
- Location: Europe, Germany
Re: ESP32S3 : Possible to optimise the compilation ??
I just found out about idf.py size-components which gives you a nice breakdown of static memory usage of the components included in your application
Your main application code is listed as "libmain.a"...
Your main application code is listed as "libmain.a"...
Who is online
Users browsing this forum: No registered users and 66 guests