Error: Implement a fault-reset feature

Open
#165 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
30/100
Issue type
Feature
Clarity
Needs clarification
Activity status
Quiet
Tech stack
c
Domain
embedded-iot

Research direction

Start with init/appa/config/Src/stm32h7xx_it.c and the HardFault_Handler() entry point. Investigate whether the MCU can reset and preserve flight_computer_state, the flash address, and the error cause without an EEPROM or dedicated flash block. Done means documenting whether the recovery design is feasible and identifying its storage constraints.

Written by the indexing model from the issue text.

Description

advanced enhancement help wanted

Description

Safety critical systems often have a requirement that the system should not have un-recoverable errors. This is next to impossible to achieve just by building a good software system, as there's always gonna be that one edge case that can still take your system out.

What we can do, however, is make sure that the system recovers when that edge case is hit. Even a segmentation fault is technically recoverable on STM32 because the MCU receives and handles an interrupt signal in this situation (see init/appa/config/Src/stm32h7xx_it.c -> HardFault_Handler()).

We could theoretically force the MCU to reset if we hit an unrecoverable error. This would pop the MCU back up in the idle state with all of the peripherals re-initialized (provided there isn't some kind of error on one of these). If there's some region of non-volatile memory in which we can save the flight_computer_state variable from the error handler, we can then resume execution in the same state as before.

This has a number of its own design challenges. We would have to also store the flash address so we can continue logging at the right point. flight_computer_state would need to sit in a special block of memory that can be readily erased/overwritten (which makes this suited for a new hardware revision with an EEPROM). We would also want to make sure we log the cause of the error somewhere so that hardfaults are debuggable and we don't lose the place where this was hit.

But theoretically, this idea could substantially increase reliability. Recommend investigating this for a while to see if it's feasible without an EEPROM or a flash block that's dedicated to error handling.

Dominant language
C
Stars
8
Forks
6
Avg merge
6d 15h
Merged PRs (30d)
1

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from SunDevilRocketry/Flight-Computer-Firmware

All issues in SunDevilRocketry/Flight-Computer-Firmware

Similar issues

More C issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.