Core Firmware SOS Panic Codes

Are you getting a red flashing LED after running your code on your Spark core? You may be getting a panic code, telling you what went wrong!

The panic code is a red LED blinking out SOS (… — …) followed by N flashes, followed by another SOS.

Here are the meanings of the N flashes, but #8, out of heap, is the most common:

#1 Hard fault
#2 Non-maskable interrupt fault
#3 Memory Manager fault
#4 Bus fault
#5 Usage fault
#6 Invalid length
#7 Exit
#8 Out of heap memory
#9 SPI over-run
#10 Assertion failure
#11 Invalid case
#12 Pure virtual call
#13 Stack Overflow
11 Likes

Very helpful! I find myself coming to this page quite often. The overview is nice.

Not being a computer scientist, it would be cool to know what a hard fault is, or an assertion failure Probably they are fixable, but it is unclear from the short list. Who feels like extending it with more detailed explanations / next steps for individual codes?

1 Like

This in the doc troubleshooting section now. I would check there.

What does “hard fault” means and how to deal with it?

2 Likes

Hi,

I do some external logging for my electron devices. In 0.6.0-rc2 you can use System.resetReason() and System.resetReasonData() for panic codes. While I found the values for resetReasons quite easy in the git-repository, I didn’t find the resetReasonCodes.

If you’re looking for the translation of the resetCodes and Panic-Codes - here they are:

System.resetReason():

RESET_REASON_NONE = 0,
RESET_REASON_UNKNOWN = 10, // Unspecified reason
// Hardware
RESET_REASON_PIN_RESET = 20, // Reset from the NRST pin
RESET_REASON_POWER_MANAGEMENT = 30, // Low-power management reset
RESET_REASON_POWER_DOWN = 40, // Power-down reset
RESET_REASON_POWER_BROWNOUT = 50, // Brownout reset
RESET_REASON_WATCHDOG = 60, // Watchdog reset
// Software
RESET_REASON_UPDATE = 70, // Successful firmware update
RESET_REASON_UPDATE_ERROR = 80, // Generic update error
RESET_REASON_UPDATE_TIMEOUT = 90, // Update timeout
RESET_REASON_FACTORY_RESET = 100, // Factory reset requested
RESET_REASON_SAFE_MODE = 110, // Safe mode requested
RESET_REASON_DFU_MODE = 120, // DFU mode requested
RESET_REASON_PANIC = 130, // System panic (additional data may contain panic code)
RESET_REASON_USER = 140 // User-requested reset

System.resetReasonData:

HardFault: 1
MemManage: 3
BusFault: 4
UsageFault: 5
OutOfHeap: 8
AssertionFailure: 10
StackOverflow: 13
3 Likes