mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-06-26 10:30:35 +08:00
BBSRAM: add another partition and store the last ulog path
This commit is contained in:
@@ -38,6 +38,9 @@
|
||||
|
||||
#include <mathlib/mathlib.h>
|
||||
#include <px4_posix.h>
|
||||
#ifdef __PX4_NUTTX
|
||||
#include <systemlib/hardfault_log.h>
|
||||
#endif /* __PX4_NUTTX */
|
||||
|
||||
namespace px4
|
||||
{
|
||||
@@ -87,26 +90,37 @@ void LogWriterFile::start_log(const char *filename)
|
||||
PX4_ERR("Can't open log file %s, errno: %d", filename, errno);
|
||||
_should_run = false;
|
||||
return;
|
||||
}
|
||||
|
||||
} else {
|
||||
if (_buffer == nullptr) {
|
||||
_buffer = new uint8_t[_buffer_size];
|
||||
|
||||
if (_buffer == nullptr) {
|
||||
_buffer = new uint8_t[_buffer_size];
|
||||
|
||||
if (_buffer == nullptr) {
|
||||
PX4_ERR("Can't create log buffer");
|
||||
::close(_fd);
|
||||
_fd = -1;
|
||||
_should_run = false;
|
||||
return;
|
||||
}
|
||||
PX4_ERR("Can't create log buffer");
|
||||
::close(_fd);
|
||||
_fd = -1;
|
||||
_should_run = false;
|
||||
return;
|
||||
}
|
||||
|
||||
PX4_INFO("Opened log file: %s", filename);
|
||||
_should_run = true;
|
||||
_running = true;
|
||||
}
|
||||
|
||||
#ifdef __PX4_NUTTX
|
||||
// register the current file with the hardfault handler: if the system crashes,
|
||||
// the hardfault handler will append the crash log to that file on the next reboot.
|
||||
// Note that we don't deregister it when closing the log, so that crashes after disarming
|
||||
// are appended as well (the same holds for crashes before arming, which can be a bit misleading)
|
||||
int ret = hardfault_store_ulog_filename(filename);
|
||||
|
||||
if (ret) {
|
||||
PX4_ERR("Failed to register ULog file to the hardfault handler (%i)", ret);
|
||||
}
|
||||
|
||||
#endif /* __PX4_NUTTX */
|
||||
|
||||
PX4_INFO("Opened log file: %s", filename);
|
||||
_should_run = true;
|
||||
_running = true;
|
||||
|
||||
// Clear buffer and counters
|
||||
_head = 0;
|
||||
_count = 0;
|
||||
|
||||
@@ -37,20 +37,25 @@
|
||||
****************************************************************************/
|
||||
#include <systemlib/px4_macros.h>
|
||||
#include <stm32_bbsram.h>
|
||||
#include <board_config.h>
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
#define HARDFAULT_FILENO 3
|
||||
#define HARDFAULT_PATH BBSRAM_PATH""STRINGIFY(HARDFAULT_FILENO)
|
||||
#define HARDFAULT_REBOOT_FILENO 0
|
||||
#define HARDFAULT_REBOOT_PATH BBSRAM_PATH""STRINGIFY(HARDFAULT_REBOOT_FILENO)
|
||||
#define HARDFAULT_REBOOT_PATH BBSRAM_PATH "" STRINGIFY(HARDFAULT_REBOOT_FILENO)
|
||||
#define HARDFAULT_ULOG_FILENO 3
|
||||
#define HARDFAULT_ULOG_PATH BBSRAM_PATH "" STRINGIFY(HARDFAULT_ULOG_FILENO)
|
||||
#define HARDFAULT_FILENO 4
|
||||
#define HARDFAULT_PATH BBSRAM_PATH "" STRINGIFY(HARDFAULT_FILENO)
|
||||
|
||||
#define HARDFAULT_MAX_ULOG_FILE_LEN 64 /* must be large enough to store the full path to the log file */
|
||||
|
||||
#define BBSRAM_SIZE_FN0 (sizeof(int))
|
||||
#define BBSRAM_SIZE_FN1 384 /* greater then 2.5 times the size of vehicle_status_s */
|
||||
#define BBSRAM_SIZE_FN2 384 /* greater then 2.5 times the size of vehicle_status_s */
|
||||
#define BBSRAM_SIZE_FN3 -1
|
||||
#define BBSRAM_SIZE_FN3 HARDFAULT_MAX_ULOG_FILE_LEN
|
||||
#define BBSRAM_SIZE_FN4 -1
|
||||
|
||||
/* The following guides in the amount of the user and interrupt stack
|
||||
* data we can save. The amount of storage left will dictate the actual
|
||||
@@ -58,7 +63,7 @@
|
||||
* It will be truncated by the call to stm32_bbsram_savepanic
|
||||
*/
|
||||
#define BBSRAM_HEADER_SIZE 20 /* This is an assumption */
|
||||
#define BBSRAM_USED ((4*BBSRAM_HEADER_SIZE)+(BBSRAM_SIZE_FN0+BBSRAM_SIZE_FN1+BBSRAM_SIZE_FN2))
|
||||
#define BBSRAM_USED ((4*BBSRAM_HEADER_SIZE)+(BBSRAM_SIZE_FN0+BBSRAM_SIZE_FN1+BBSRAM_SIZE_FN2+BBSRAM_SIZE_FN3))
|
||||
#define BBSRAM_REAMINING (PX4_BBSRAM_SIZE-BBSRAM_USED)
|
||||
#if CONFIG_ARCH_INTERRUPTSTACK <= 3
|
||||
# define BBSRAM_NUMBER_STACKS 1
|
||||
@@ -77,8 +82,9 @@
|
||||
#define BSRAM_FILE_SIZES { \
|
||||
BBSRAM_SIZE_FN0, /* For Time stamp only */ \
|
||||
BBSRAM_SIZE_FN1, /* For Current Flight Parameters Copy A */ \
|
||||
BBSRAM_SIZE_FN2, /* For Current Flight Parameters Copy B*/ \
|
||||
BBSRAM_SIZE_FN3, /* For the Panic Log use rest of space */ \
|
||||
BBSRAM_SIZE_FN2, /* For Current Flight Parameters Copy B */ \
|
||||
BBSRAM_SIZE_FN3, /* For the latest ULog file path */ \
|
||||
BBSRAM_SIZE_FN4, /* For the Panic Log use rest of space */ \
|
||||
0 /* End of table marker */ \
|
||||
}
|
||||
|
||||
@@ -350,4 +356,24 @@ int hardfault_rearm(char *caller) weak_function;
|
||||
****************************************************************************/
|
||||
int hardfault_increment_reboot(char *caller, bool reset) weak_function;
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
* Name: hardfault_store_ulog_filename
|
||||
*
|
||||
* Description:
|
||||
* Permanently store the current ulog file name. A crash dump will
|
||||
* be appended to this file (must be ULog).
|
||||
*
|
||||
*
|
||||
* Inputs:
|
||||
* - log_file: full path to the log file
|
||||
*
|
||||
* Returned Value:
|
||||
*
|
||||
* OK or errno
|
||||
*
|
||||
*
|
||||
****************************************************************************/
|
||||
int hardfault_store_ulog_filename(const char *log_file);
|
||||
|
||||
__END_DECLS
|
||||
|
||||
Reference in New Issue
Block a user