I’m trying out the Electron, and I noticed that the memory usage for some library example projects was pretty high. So I created a new empty file and built it via the web IDE:
void setup() {
}
void loop() {
}
According to the build output, this empty project takes up 83.7% of available flash. Is there something I’m missing here, or is this accurate?
Output of arm-none-eabi-size:
text data bss dec hex
91536 984 9732 102252 18
In a nutshell:
Flash used 92520 / 110592 83.7 %
RAM used 10716 / 20480 52.3 %
Thanks to your screenshot I found the issue–since the last time I used the web IDE, it seems that the active device became deselected (so neither of my Electrons were active). Selecting one of them and recompiling fixed it.
Since I was able to compile (and download) a firmware binary without a device selected, now I’m wondering what the default build target is (not that is actually matters)…
Does that mean that if I have a Spark Core my flash usage will be at least 83.7 %? I have trouble getting more than two libraries on my Core. Here is a screenshot of what I mean.
On the core, all the system code and user code is in the same area in flash. This is called monolithic in the Particle world.
In the example you show above for a Core (not the same as a Photon or an Electron), there are 110592 bytes of flash available, and the system code used 92552 bytes, leaving 18048 for user code. This limit is somewhat easy to reach on a Core and that is one of many reasons the Photon and Electron were designed to have more flash and use a non-monolithic build strategy-lessons learned.
If you are asking instead why the limit is 110k bytes and not the full 120k bytes, some of the flash used for the bootloader and the emergency backup firmware. If you install the local gcc toolchain and compile on your computer, you can program any of these areas, up to the full 120k bytes but you are on your own for fixing problems and recovering from crashes. I recommend not attempting this unless you have a lot of experience in embedded programming on small platforms like this.