IS there a list of error codes somewhere?

Subject says it all. Specifically I am getting the blink flashing red 4 times. pausing, flashing again, and so on.

Thanks.

Unfortunately I don’t believe there is a centralized list - I forked the docs a while back and tried adding them myself, but never made a merge request…

I’m unsure if this has changed since I originally wrote it, but from my notes:

  • 2 Red Flashes/Second - Low Battery Warning
  • 3 Red Flashes/Second - Programming/Code Sharing Error
  • 4 Red Flashes/Second - Stack Overflow

Side note, I’ll see about tidying up my additions and making that merge request this weekend(?).

EDIT: Maybe @bigjosh can verify?

1 Like

If this is current, then I have a stack overflow. Now I wonder how big the stack is… I guess i will have to split some code to do work in smaller functions that return results for other functions to use.

1 Like

These are correct!

Note that…

  • The “low battery” warning comes from the blinkBIOS and can happen any time the battery voltage gets too low. The cure is to replace the low battery (or wait for the voltage on the current one to recover).
  • The “programming error” can only happen during a download cycle. The cure is to press the button to abort the download mode and fail-back to the built-in game. Note that in newer versions of the blinkBIOS and new download can also exit this mode, saving you from having to push the buttons.
  • The “stack overflow error” is generated by the blinklib code and can only happen after you return from loop() and before the next call into loop(). In between each loop() iteration the code checks a special sentinel value stored at the top of memory. If this value has been changed, it indicates that the staack has grown into the memory used for variables and overwritten it. The cure for this is to use less stack space. Things like recursion and allocating big data structures (class,struct, or array) locally use up lots of stack space. It is usually a bad idea to allocate anything bigger than an int on the local stack on this tiny platform.
1 Like

The stack grows down from the top of RAM towards the top of the global variables, so the amount of room is has to grow into before it crashes depends on the amount of space used by all of the global variables…
image
https://www.nongnu.org/avr-libc/user-manual/malloc.html

It is very hard (sometimes impossible) for the compiler to statically calculate how much global stack space a given program needs, so the strategy is to try to leave as wide a safety margin as possible, and then test (with runtime overflow checking on) a lot to try to ensure you are not running out.

1 Like