This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

NRF52 maximum code size exceeded?

Hi,

I know I have been asking quite a lot of questions lately, so I hope Im not too annoying ;)

my application currently runs very stable (no hard faults or whatsoever). but suddenly the application crashed right at start (Cortex hard fault).

So i removed my last changes and the crash was gone.

The strange thing is, these lines of code dont ever get executed before it crashes. I verified it multiple times.

So I assumed it had something to do with my code in general, so I made a test function with just some random stuff in there.

removed the line that caused the hard fault and replaced it with my testfunc -> also crashed(that function never got executed aswell).

next I tried to figure out how big my code actually was, and my compiler tells me:

Memory Usage -> http://bit.ly/pio-memory-usage
DATA:    [===       ]  29.3% (used 19188 bytes from 65536 bytes)
PROGRAM: [=======   ]  72.0% (used 377640 bytes from 524288 bytes)

so there should be left enough space.

However, when I convert the hex file to binary, then the size is close to 512Kb?!

Is there any way I can be 100% sure if the code will fit?

I attached the compiled hex file, maybe one can check it to see if there is something wrong, I think posting sourcecode is not very helpful with this kind of problem.

thanks a lot,

Jonasfirmware.hex

Parents Reply
  • Its definitly due to the code size, as the problem goes away if I compile with -Os

    No, that's not a safe conclusion - you need more evidence!

    How can I get the size?

    Every IDE I've ever used has always given a code size & memory usage summary at the end of the build.

    I've not used Platformio, but I can't imagine that it doesn't have the facility!

    The underlying tools (compiler, link) should generate reports; eg, Linker map file.

    Platformio my code should fit (70%)

    Assuming that you've correctly configured it (ie, it correctly knows the available memory), this also points to the fact that it's not just the pure size.

    You probably need to look at memory placement, stack size, etc ...

    Have you tried debugging the Hard Fault?

    Are the any RTT logs telling you why it's crashing - eg, SoftDevice memory allocation ... ?

Children
No Data
Related