AP_HAL_ChibiOS: do not gate AP_CRASHDUMP_ENABLED on bootloader

Also rename from HAL_CRASHDUMP_ENABLE

Removes code based on define rather than creating empty functions.  Makes it clearer what's going on in the callers.
This commit is contained in:
Peter Barker 2022-08-15 17:22:48 +10:00 committed by Andrew Tridgell
parent 680d158f59
commit 4ca0f35943
4 changed files with 7 additions and 14 deletions

View File

@ -722,10 +722,9 @@ void Util::log_stack_info(void)
#endif
}
#if !defined(HAL_BOOTLOADER_BUILD)
#if AP_CRASHDUMP_ENABLED
size_t Util::last_crash_dump_size() const
{
#if HAL_CRASHDUMP_ENABLE
// get dump size
uint32_t size = stm32_crash_dump_size();
char* dump_start = (char*)stm32_crash_dump_addr();
@ -738,22 +737,16 @@ size_t Util::last_crash_dump_size() const
size = stm32_crash_dump_max_size();
}
return size;
#endif
return 0;
}
void* Util::last_crash_dump_ptr() const
{
#if HAL_CRASHDUMP_ENABLE
if (last_crash_dump_size() == 0) {
return nullptr;
}
return (void*)stm32_crash_dump_addr();
#else
return nullptr;
#endif
}
#endif // HAL_BOOTLOADER_BUILD
#endif // AP_CRASHDUMP_ENABLED
// set armed state
void Util::set_soft_armed(const bool b)

View File

@ -146,7 +146,7 @@ private:
// log info on stack usage
void log_stack_info(void) override;
#if !defined(HAL_BOOTLOADER_BUILD)
#if AP_CRASHDUMP_ENABLED
// get last crash dump
size_t last_crash_dump_size() const override;
void* last_crash_dump_ptr() const override;

View File

@ -972,10 +972,10 @@ def write_mcu_config(f):
if flash_size >= 2048 and not args.bootloader:
# lets pick a flash sector for Crash log
f.write('#define HAL_CRASHDUMP_ENABLE 1\n')
f.write('#define AP_CRASHDUMP_ENABLED 1\n')
env_vars['ENABLE_CRASHDUMP'] = 1
else:
f.write('#define HAL_CRASHDUMP_ENABLE 0\n')
f.write('#define AP_CRASHDUMP_ENABLED 0\n')
env_vars['ENABLE_CRASHDUMP'] = 0
if args.bootloader:

View File

@ -23,7 +23,7 @@
#include "hwdef/common/watchdog.h"
#include "hwdef/common/stm32_util.h"
#include <AP_Vehicle/AP_Vehicle_Type.h>
#if HAL_CRASHDUMP_ENABLE
#if AP_CRASHDUMP_ENABLED
#include <CrashCatcher.h>
#endif
#include <ch.h>
@ -52,7 +52,7 @@ extern "C"
{
#define bkpt() __asm volatile("BKPT #0\n")
#if !HAL_CRASHDUMP_ENABLE
#if !AP_CRASHDUMP_ENABLED
// do legacy hardfault handling
void HardFault_Handler(void);
void HardFault_Handler(void) {