Skip to content

Commit

Permalink
AP_BoardConfig: force user to ack crashdump or get prearm failure
Browse files Browse the repository at this point in the history
  • Loading branch information
peterbarker committed Apr 7, 2024
1 parent f6e58e5 commit 79d5860
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 0 deletions.
29 changes: 29 additions & 0 deletions libraries/AP_BoardConfig/AP_BoardConfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,16 @@ const AP_Param::GroupInfo AP_BoardConfig::var_info[] = {
// @User: Advanced
AP_GROUPINFO("IO_DSHOT", 28, AP_BoardConfig, state.io_dshot, 0),
#endif

#if AP_CRASHDUMP_ACK_ENABLED
// @Param: CRSHDMP_ACK
// @DisplayName: CrashDump Acknowledgement Required
// @Description: Must have value "1" if a crashdump is present on the system, or prearm failure will be raised. Do not set this parameter unless the risks of doing so are fully understood.
// @Values: 0:Crash dump NOT acked,1:Crash dump acked
// @User: Advanced
AP_GROUPINFO("CRSHDMP_ACK", 30, AP_BoardConfig, crashdump_ack.acked, 0),
#endif // AP_CRASHDUMP_ACK_ENABLED

AP_GROUPEND
};

Expand Down Expand Up @@ -418,7 +428,26 @@ void AP_BoardConfig::init()
printf("SDCard failed to start\n");
}
#endif

#if AP_CRASHDUMP_ACK_ENABLED
crashdump_ack.check_reset();
#endif
}

#if AP_CRASHDUMP_ACK_ENABLED
void AP_BoardConfig::CrashDump::check_reset()
{
// if there is no crash_dump.bin then clear the crash dump ack.
// This means on subsequent crash-dumps appearing the user must
// re-acknowledge.
int fd = AP::FS().open("@SYS/crash_dump.bin", O_RDONLY);
if (fd == -1) {
// no (or probably empty) crash_dump.bin, so clear ack:
acked.set_and_save_ifchanged(0);
}
AP::FS().close(fd);
}
#endif // AP_CRASHDUMP_ACK_ENABLED

// set default value for BRD_SAFETY_MASK
void AP_BoardConfig::set_default_safety_ignore_mask(uint32_t mask)
Expand Down
12 changes: 12 additions & 0 deletions libraries/AP_BoardConfig/AP_BoardConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ class AP_BoardConfig {
void init(void);
void init_safety(void);

#if AP_CRASHDUMP_ACK_ENABLED
bool crashdump_acknowledged() const { return crashdump_ack.acked; }
#endif

static const struct AP_Param::GroupInfo var_info[];

// notify user of a fatal startup error related to available sensors.
Expand Down Expand Up @@ -321,6 +325,14 @@ class AP_BoardConfig {
AP_Int32 _options;

AP_Int8 _alt_config;

#if AP_CRASHDUMP_ACK_ENABLED
struct CrashDump {
void check_reset();
AP_Int8 acked;
} crashdump_ack;
#endif // AP_CRASHDUMP_ACK_ENABLED

};

namespace AP {
Expand Down
4 changes: 4 additions & 0 deletions libraries/AP_BoardConfig/AP_BoardConfig_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,7 @@
#ifndef AP_SDCARD_STORAGE_ENABLED
#define AP_SDCARD_STORAGE_ENABLED (HAL_MEM_CLASS >= HAL_MEM_CLASS_1000) && (AP_FILESYSTEM_POSIX_ENABLED || AP_FILESYSTEM_FATFS_ENABLED) && BOARD_FLASH_SIZE > 1024
#endif

#ifndef AP_CRASHDUMP_ACK_ENABLED
#define AP_CRASHDUMP_ACK_ENABLED AP_CRASHDUMP_ENABLED && AP_FILESYSTEM_SYS_ENABLED
#endif

0 comments on commit 79d5860

Please sign in to comment.