[SOLVED] Why is my app allowed to be bigger than the maximum size stipulated in the Electron memory map allows

Hey all,

Wondering why my app is allowed to be bigger than the 128 kB that is stipulated in the memory map in the Electron datasheet?

I’m using po-util to compile locally. @nrobinson2000 Is this just a feature of po-util? Does it have implications for the other two 128 kB memory sectors (i.e. Factory backup, OTA backup sectors) ?

Is this why I can’t compile using Particle-CLI?

Could this be the reason that I occasionally see a stack overflow or a panic reset when OTA flashing a device?


As per the responses below, it would appear that the app size numbers that po-util outputs are a bit off.

For example, an “empty app” (i.e. main.cpp only has empty setup() and loop() functions ) compiles to about 3.25 kB (3332 bytes to be exact) using po-util and spark firmware branch release/v0.6.1 (see the screenshot, below)

po-util’s upper limit of 125,000 bytes is supposed to discount this empty app overhead, but it does not.

So, the maximum app size using po-util is actually 131,072 bytes (128 kB), which would read 104.86% flash used.

1 Like

The numbers I use in po-util were found in this thread.

1 Like

@jaza_tom, the 125KB is based on an observed 3KB “overhead” imposed on the user app. Regardless, the “real” amount of flash is 128KB or 131,072 byte if a 1024 byte kilobyte is used.

The stack overflow issues would be related to how you use RAM, not flash, though your code is clearly on the edge of the boundary. Have you looked at how you allocate local variables in functions and the depth of your calls? Are you using String types which are known to create heap fragmentation? A lot of factors can lead to those faults.


All of my big data consumers of RAM are allocated statically. I am not using strings, only char arrays.

I also do not (to my knowledge) have any recursion happening. I suppose I should probably reduce my statically allocated RAM however.

The overflow issue only ever presents itself during OTA flash, and even then it only presents itself sometimes.

What do you mean by 3 KB “overhead” ? Is this 3KB of overhead used used for anything, or is it just reserved (i.e. sitting unused/blank on the silicon)? Are you saying that even though I can compile/flash/run my program when it is 130,000+ bytes in size that I should really be reducing my program size in order to comply with the overhead allowance?

I’m not entirely sure whether this is what @peekay123 meant but I’d assume he means the minimum amount even an “empty” sketch would consume due to the “framework” to accommodate void setup() { } and void loop() {}.


@jaza_tom, the 3KB is as @ScruffR describes it. PO-Util’s output includes that in its numbers. There are a number of reasons you could be getting a stack overflow including Software Timers and over allocation of (stack allocated) variables in functions.


OK thanks. I’ll edit the original post with the answer and mark this thread as solved.