Skip to content

Commit

Permalink
Upmerge support for ncs 2.7+
Browse files Browse the repository at this point in the history
  • Loading branch information
noahp committed Sep 12, 2024
1 parent 0fbb820 commit 102286f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
15 changes: 7 additions & 8 deletions ports/zephyr/config/memfault_zephyr_platform_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,15 @@
//! See License.txt for details
//!
//! Zephyr port overrides for the default configuration settings in the memfault-firmware-sdk.
#include <autoconf.h> // For Kconfig settings
#include <version.h> // Zephyr version macros
#include <version.h>

#ifdef __cplusplus
extern "C" {
#endif

// Note that pre-v2.0 Zephyr did not create the section allocation needed to support
// our Gnu build ID usage.
#if KERNEL_VERSION_MAJOR >= 2 && CONFIG_MEMFAULT_USE_GNU_BUILD_ID
#if KERNEL_VERSION_MAJOR >= 2 && defined(CONFIG_MEMFAULT_USE_GNU_BUILD_ID)
// Add a unique identifier to the firmware build
//
// It is very common, especially during development, to not change the firmware
Expand All @@ -40,13 +39,13 @@ extern "C" {
// so no need to save from the SDK
#define MEMFAULT_SDK_LOG_SAVE_DISABLE 1

#if CONFIG_MEMFAULT_CACHE_FAULT_REGS
#if defined(CONFIG_MEMFAULT_CACHE_FAULT_REGS)
// Map Zephyr config to Memfault define so that we can
// collect the HW fault regs before Zephyr modifies them.
#define MEMFAULT_CACHE_FAULT_REGS 1
#endif

#if CONFIG_MEMFAULT_HEAP_STATS
#if defined(CONFIG_MEMFAULT_HEAP_STATS)
// Map Zephyr config to Memfault define to enable heap
// tracing collection.
#define MEMFAULT_COREDUMP_COLLECT_HEAP_STATS 1
Expand All @@ -56,7 +55,7 @@ extern "C" {
#define MEMFAULT_REBOOT_REASON_CUSTOM_ENABLE 1
#endif

#if CONFIG_MEMFAULT_NRF_CONNECT_SDK
#if defined(CONFIG_MEMFAULT_NRF_CONNECT_SDK)

#define MEMFAULT_HTTP_CHUNKS_API_HOST "chunks-nrf.memfault.com"
#define MEMFAULT_HTTP_DEVICE_API_HOST "device-nrf.memfault.com"
Expand Down Expand Up @@ -101,11 +100,11 @@ extern "C" {
#define MEMFAULT_CDR_ENABLE 1
#endif

#if CONFIG_MEMFAULT_USER_CONFIG_ENABLE
#if defined(CONFIG_MEMFAULT_USER_CONFIG_ENABLE)

// Pick up any user configuration overrides. This should be kept at the bottom
// of this file
#if CONFIG_MEMFAULT_USER_CONFIG_SILENT_FAIL
#if defined(CONFIG_MEMFAULT_USER_CONFIG_SILENT_FAIL)

#if __has_include("memfault_platform_config.h")
#include "memfault_platform_config.h"
Expand Down
6 changes: 6 additions & 0 deletions ports/zephyr/v2.4/memfault_fault_handler.c
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,12 @@ extern void sys_arch_reboot(int type);

// Intercept zephyr/kernel/fatal.c:z_fatal_error(). Note that the signature
// changed in zephyr 3.7.
#if defined(CONFIG_MEMFAULT_NRF_CONNECT_SDK)
#define MEMFAULT_NEW_ARCH_ESF_STRUCT MEMFAULT_NCS_VERSION_GT(2, 7)
#else
#define MEMFAULT_NEW_ARCH_ESF_STRUCT MEMFAULT_ZEPHYR_VERSION_GT_STRICT(3, 6)
#endif

#if MEMFAULT_ZEPHYR_VERSION_GT_STRICT(3, 6)
void __wrap_z_fatal_error(unsigned int reason, const struct arch_esf *esf);
void __real_z_fatal_error(unsigned int reason, const struct arch_esf *esf);
Expand Down

0 comments on commit 102286f

Please sign in to comment.