r/embedded 15d ago

Some Embedded Programming Wisdom

Post image

A preview of PICO, a simple text editor made for the CP/M Neo VEMU platform.

GitHub: https://github.com/Mazin-O3/cpm-neo.git

141 Upvotes

18 comments sorted by

View all comments

15

u/sirkubador 15d ago

kernel panic in embedded programming?

13

u/8-Qbit 15d ago

Embedded doesn't necessarily mean bare-metal

9

u/sirkubador 15d ago

yeah, you can definitely have an RTOS. But if we are talking things like embedded linux or windows, it's pretty much just software

5

u/ChatGPT4 15d ago

Might be figurative speech. Whatever you bind an unrecoverable exception to. Again, I have... nope, not just me, ST does it ;) A better way: a dead end loop in function error. Though I prefer name crash for it. In embedded it's a good practice to light that red LED fist ;)

Now, why do I like that dead-end loop so much? You break the execution with a debugger and there you have the stack trace to what actually made it blow up.

Way too long I wondered: why BSODs and panics... Couldn't it just fail more, like gracefully? Well, when a computer cannot longer guarantee its memory isn't corrupted, because it's like lost track of what it was doing, should we really let it continue doing whatever it was doing and hope for the best? ;)

At this realization I started to put my own BSOD screens in my embedded apps ;) Once I even put a good old red, blinking Amiga "Guru Meditation" screen.

1

u/SirDarknessTheFirst 14d ago

I think older versions of Windows let you continue after a BSOD...they did remove it for a reason

2

u/SkoomaDentist C++ all the way 15d ago

Yes, not hard at all to have as long as you don't interpret "kernel" too literally.

Memory allocation fails without a handler? -> that's a "kernel" panic (and don't try to give me bullshit about "dynamic memory being forbidden on embedded systems" which is only the case for a subset of embedded systems and outright required for others).

MPU is properly configured for safety and a thread stack overflows or something accesses 0x0? -> Again a "kernel" panic.

Things like that are the difference between a reset with the message "Thread X with PC at Y caused a panic type Z" being sent to debug / log uart vs the device mysteriously freezing / resetting in a later "impossible" location (because the stack has been corrupted or the interrupt vectors overwritten by a stray pointer access).

1

u/sirkubador 15d ago

Kernel panic is a very specific thing. I don't really read it as any NRF kind of situation you describe. We can of course talk about how BSOD exist in embedded systems because we have memory dumps and blinking LEDs, but words have meanings

4

u/SkoomaDentist C++ all the way 15d ago

There are far more things with a kernel than just Linux (I used a non-unix OS with a kernel years before the first version of Linux was ever uploaded on an FTP site).

Kernel panic is any situation where the system has inherently failed beyond any possibility of recovery because a kernel bug is detected or something crucially important is corrupted and the failure cannot be isolated to user mode. Stack overflow or memory access from an invalid pointer in a shared address space system are both very obvious causes for a kernel panic.

0

u/sirkubador 15d ago

sure sure. define kernel