What causes a "Usage Fault" SOS error?

The documentation at https://docs.particle.io/guide/getting-started/modes/photon/#red-flash-sos is helpful, thanks much.

My question is, what causes that "Usage Fault" SOS error? I've seen this question posted before but not in a generic sense. Are there classes of programming errors that cause it - for example, div-by-zero, attempt to assign out-of-range value, invalid memory address, etc? Alternatively, is there a link to source and the method call for this SOS error so I could search its references in the repo myself?

EDIT: I found this post from BDub:

Which is also helpful, but what do "unaligned memory access for load/store multiple" and "other unaligned memory accesses" mean?

I'm not sure if there is a link to a method reference for this question, but it would help if somebody knows where the particle/photon firmware detects this STM32 condition and calls the SOS, that would be great.

These conditions raise an interrupt that is handled via the interrupt table.

I'll try to find the file where these interrupts are "translated" into the SOS signals (I've stumbled over it just a few days ago).
The files in connection with the SOS panic codes are here
https://github.com/spark/firmware/blob/develop/hal/src/stm32f2xx/core_hal_stm32f2xx.c
https://github.com/spark/firmware/blob/develop/services/src/panic.c
https://github.com/spark/firmware/tree/develop/services/inc

Since this is a 32bit chip instructions and multi byte memory access has to be alligned to 4 byte address boundaries and instructions can also only be executed from mem locations suitable for code.

1 Like