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
SW-148
  • Loading branch information
loki077 committed Apr 8, 2024
1 parent 0cdd353 commit 2f54d47
Show file tree
Hide file tree
Showing 3 changed files with 80 additions and 0 deletions.
26 changes: 26 additions & 0 deletions libraries/AP_BoardConfig/AP_BoardConfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,15 @@ const AP_Param::GroupInfo AP_BoardConfig::var_info[] = {
AP_GROUPINFO("HEAT_LOWMGN", 23, AP_BoardConfig, heater.imu_arming_temperature_margin_low, HAL_IMU_TEMP_MARGIN_LOW_DEFAULT),
#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. The presence of a crash dump means that the firmware currently installed has crashed with a hardfault or watchdog. The crash dump file gives diagnostic information which can help in finding the issue. Please check the ArduPilot documentation for more details.
// @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 @@ -372,7 +381,24 @@ 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 data then clear the crash dump ack.
// This means on subsequent crash-dumps appearing the user must
// re-acknowledge.
if (hal.util->last_crash_dump_size() == 0) {
// no crash dump data
acked.set_and_save_ifchanged(0);
}
}
#endif // AP_CRASHDUMP_ACK_ENABLED

// set default value for BRD_SAFETY_MASK
void AP_BoardConfig::set_default_safety_ignore_mask(uint16_t mask)
Expand Down
13 changes: 13 additions & 0 deletions libraries/AP_BoardConfig/AP_BoardConfig.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#pragma once

#include "AP_BoardConfig_config.h"
#include <AP_HAL/AP_HAL.h>
#include <AP_Common/AP_Common.h>
#include <AP_Param/AP_Param.h>
Expand Down Expand Up @@ -58,6 +59,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 @@ -306,6 +311,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
41 changes: 41 additions & 0 deletions libraries/AP_BoardConfig/AP_BoardConfig_config.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#pragma once

#include <AP_HAL/AP_HAL.h>
#include <AP_Filesystem/AP_Filesystem_config.h>

#ifndef AP_FEATURE_BOARD_DETECT
#if defined(HAL_CHIBIOS_ARCH_FMUV3) || defined(HAL_CHIBIOS_ARCH_FMUV4) || defined(HAL_CHIBIOS_ARCH_FMUV5) || defined(HAL_CHIBIOS_ARCH_MINDPXV2) || defined(HAL_CHIBIOS_ARCH_FMUV4PRO) || defined(HAL_CHIBIOS_ARCH_BRAINV51) || defined(HAL_CHIBIOS_ARCH_BRAINV52) || defined(HAL_CHIBIOS_ARCH_UBRAINV51) || defined(HAL_CHIBIOS_ARCH_COREV10) || defined(HAL_CHIBIOS_ARCH_BRAINV54)
#define AP_FEATURE_BOARD_DETECT 1
#else
#define AP_FEATURE_BOARD_DETECT 0
#endif
#endif

#ifndef AP_FEATURE_RTSCTS
#define AP_FEATURE_RTSCTS 0
#endif

#ifndef AP_FEATURE_SBUS_OUT
#define AP_FEATURE_SBUS_OUT 0
#endif

#ifndef HAL_WATCHDOG_ENABLED_DEFAULT
#define HAL_WATCHDOG_ENABLED_DEFAULT false
#endif

#if HAL_HAVE_IMU_HEATER
#ifndef HAL_IMUHEAT_P_DEFAULT
#define HAL_IMUHEAT_P_DEFAULT 200
#endif
#ifndef HAL_IMUHEAT_I_DEFAULT
#define HAL_IMUHEAT_I_DEFAULT 0.3
#endif
#endif

#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
#endif

0 comments on commit 2f54d47

Please sign in to comment.