Skip to content

Commit 9f1addb

Browse files
author
Memfault Inc
committed
Memfault Firmware SDK 1.3.2 (Build 3642)
1 parent 38e0ca9 commit 9f1addb

File tree

21 files changed

+298
-120
lines changed

21 files changed

+298
-120
lines changed

CHANGES.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,30 @@
11
# Memfault Firmware SDK Changelog
22

3+
## 1.3.2 - Sept 26, 2023
4+
5+
### :chart_with_upwards_trend: Improvements
6+
7+
- Zephyr:
8+
9+
- use `<cmsis_core.h>` instead of `<nmi.h>`. Thanks @kmeihar for this change!
10+
(see [#64](https://github.com/memfault/memfault-firmware-sdk/pull/64))
11+
12+
- nRF Connect SDK:
13+
14+
- Add missing Kconfig flags `CONFIG_FLASH_MAP=y` + `CONFIG_STREAM_FLASH=y` for
15+
the [`examples/nrf-connect-sdk/nrf5/`](examples/nrf-connect-sdk/nrf5/)
16+
example app, for compatibility with nRF Connect SDK v2.4.1+. This was
17+
required due to an
18+
[upstream Zephyr change](https://github.com/zephyrproject-rtos/zephyr/commit/1b4b979f8789af6087f877c0daad0a660c1b9b28).
19+
20+
- General:
21+
- Add support for Memfault Compact Logs for C++ source files (previously only
22+
supported in C source files). Compact logging can be enabled by setting
23+
`MEMFAULT_LOG_COMPACT_ENABLE=1` in `memfault_platform_config.h`. See
24+
[the docs](https://docs.memfault.com/docs/mcu/debugging/compact-logs) for
25+
more details.
26+
- Fix a missing include of `<intrinsics.h>` required by the IAR compiler
27+
328
## 1.3.1 - Sept 21, 2023
429

530
### :chart_with_upwards_trend: Improvements

VERSION

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
BUILD ID: 3608
2-
GIT COMMIT: 4124d24ad
3-
VERSION: 1.3.1
1+
BUILD ID: 3642
2+
GIT COMMIT: 5eb9f7b6a
3+
VERSION: 1.3.2

components/include/memfault/components.h

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,6 @@
1313
//! #include memfault/components.h
1414
//!
1515

16-
#ifdef __cplusplus
17-
extern "C" {
18-
#endif
19-
2016
#include "memfault/config.h"
2117
#include "memfault/core/arch.h"
2218
#include "memfault/core/batched_events.h"
@@ -69,7 +65,3 @@ extern "C" {
6965
#include "memfault/util/rle.h"
7066
#include "memfault/util/varint.h"
7167
#include "memfault/version.h"
72-
73-
#ifdef __cplusplus
74-
}
75-
#endif

components/include/memfault/core/compact_log_helpers.h

Lines changed: 49 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,6 @@
2727

2828
#include "memfault/config.h"
2929

30-
#ifdef __cplusplus
31-
extern "C" {
32-
#endif
33-
3430
#if MEMFAULT_COMPACT_LOG_ENABLE
3531

3632
#include "memfault/core/compiler.h"
@@ -43,16 +39,52 @@ extern "C" {
4339

4440
#ifdef __cplusplus
4541

42+
// C++ implementation of the type promotion logic
43+
//
44+
// Note: the C++ implementation requires the use of C++11 features and the GNU
45+
// "##" variadic arg extension. Memfault Compact Logs in C++ require the
46+
// compiler flag '--std=gnu++-11' or newer.
4647

47-
#ifdef MEMFAULT_UNITTEST
48-
//! Note: For trace_event Memfault CppUTest tests, we pick up this header but do not actually use
49-
//! the helpers defined so let's silence the warning generated
50-
#else
51-
# error "Compact logs not yet available when using CPP"
52-
#endif
48+
#include <type_traits>
5349

54-
#else // C Code implementation
50+
// Default integer type is int64
51+
template <typename T, typename E = void>
52+
struct MemfaultLogArgPromotionType
53+
: std::integral_constant<int, MEMFAULT_LOG_ARG_PROMOTED_TO_INT64> {};
54+
55+
// If sizeof(T) <= 32, then it's int32
56+
template <typename T>
57+
struct MemfaultLogArgPromotionType<
58+
T, typename std::enable_if<sizeof(T) <= 4>::type>
59+
: std::integral_constant<int, MEMFAULT_LOG_ARG_PROMOTED_TO_INT32> {};
60+
61+
// More specific types
62+
template <>
63+
struct MemfaultLogArgPromotionType<float>
64+
: std::integral_constant<int, MEMFAULT_LOG_ARG_PROMOTED_TO_DOUBLE> {};
65+
66+
template <>
67+
struct MemfaultLogArgPromotionType<double>
68+
: std::integral_constant<int, MEMFAULT_LOG_ARG_PROMOTED_TO_DOUBLE> {};
69+
70+
template <>
71+
struct MemfaultLogArgPromotionType<long double>
72+
: std::integral_constant<int, MEMFAULT_LOG_ARG_PROMOTED_TO_DOUBLE> {};
73+
74+
template <>
75+
struct MemfaultLogArgPromotionType<char *>
76+
: std::integral_constant<int, MEMFAULT_LOG_ARG_PROMOTED_TO_STR> {};
5577

78+
template <>
79+
struct MemfaultLogArgPromotionType<const char *>
80+
: std::integral_constant<int, MEMFAULT_LOG_ARG_PROMOTED_TO_STR> {};
81+
82+
// When expressing the final type via the template parameter expansion, operate
83+
// on (arg) + 0 to force integer promotion
84+
#define _MEMFAULT_LOG_ARG_PROMOTION_TYPE(arg) \
85+
MemfaultLogArgPromotionType<decltype((arg) + 0)>::value
86+
87+
#else // C Code implementation
5688

5789
//! Preprocessor macro to encode promotion type info about each va_arg in a uint32_t
5890
//!
@@ -94,6 +126,10 @@ extern "C" {
94126
default: sizeof((arg) + 0) <= sizeof(int) ? \
95127
MEMFAULT_LOG_ARG_PROMOTED_TO_INT32 : MEMFAULT_LOG_ARG_PROMOTED_TO_INT64) \
96128

129+
#endif // __cplusplus
130+
131+
#ifdef __cplusplus
132+
extern "C" {
97133
#endif
98134

99135
#define _MF_FMT_0(fmt_op) 0
@@ -176,8 +212,8 @@ typedef struct MemfaultLogFmtElfSectionHeader {
176212
177213
extern const sMemfaultLogFmtElfSectionHeader g_memfault_log_fmt_elf_section_hdr;
178214
179-
#endif /* MEMFAULT_COMPACT_LOG_ENABLE */
180-
181215
#ifdef __cplusplus
182216
}
183217
#endif
218+
219+
#endif /* MEMFAULT_COMPACT_LOG_ENABLE */

components/include/memfault/core/compiler_iar.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
extern "C" {
1616
#endif
1717

18+
#include "intrinsics.h"
19+
1820
#define MEMFAULT_PACKED __packed
1921
#define MEMFAULT_PACKED_STRUCT MEMFAULT_PACKED struct
2022
#define MEMFAULT_NORETURN __noreturn

components/include/memfault/version.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ typedef struct {
1919
uint8_t patch;
2020
} sMfltSdkVersion;
2121

22-
#define MEMFAULT_SDK_VERSION { .major = 1, .minor = 3, .patch = 1 }
23-
#define MEMFAULT_SDK_VERSION_STR "1.3.1"
22+
#define MEMFAULT_SDK_VERSION { .major = 1, .minor = 3, .patch = 2 }
23+
#define MEMFAULT_SDK_VERSION_STR "1.3.2"
2424

2525
#ifdef __cplusplus
2626
}

examples/freertos/Makefile

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,17 @@ BUILD_DIR := build/$(BOARD)
2020
ELF = $(BUILD_DIR)/main.elf
2121

2222
ARM_CC ?= arm-none-eabi-gcc
23+
ARM_CXX ?= arm-none-eabi-g++
2324
# if cc isn't set by the user, set it to ARM_CC
2425
ifeq ($(origin CC),default)
2526
CC := $(ARM_CC)
27+
CXX := $(ARM_CXX)
2628
endif
2729
# use ccache if available
2830
CCACHE := $(shell command -v ccache 2> /dev/null)
2931
ifdef CCACHE
3032
CC := ccache $(CC)
33+
CXX := ccache $(CXX)
3134
endif
3235
OBJCOPY ?= $(shell $(CC) -print-prog-name=objcopy)
3336

@@ -59,6 +62,7 @@ FREERTOS_SRCS = \
5962
# Add application sources
6063
SRCS += \
6164
main.c \
65+
compact_log.cpp \
6266
$(BOARD_DIR)/startup.c \
6367
console.c \
6468
$(BOARD_DIR)/memfault_platform_impl.c \
@@ -79,7 +83,7 @@ SRCS += \
7983
$(MEMFAULT_SDK_ROOT)/ports/panics/src/memfault_platform_ram_backed_coredump.c \
8084

8185
# Fixup build path for objects of the Memfault SDK, all build output kept within build/
82-
OBJS := $(subst $(MEMFAULT_SDK_ROOT),memfault-firmware-sdk,$(SRCS:%.c=$(BUILD_DIR)/%.o))
86+
OBJS := $(subst $(MEMFAULT_SDK_ROOT),memfault-firmware-sdk,$(SRCS:%=$(BUILD_DIR)/%.o))
8387

8488
INCLUDE_PATHS += \
8589
-I$(FREERTOS_DIR)/include \
@@ -102,8 +106,10 @@ CFLAGS += \
102106
-Og \
103107
-MD \
104108

109+
LINKER_SCRIPT = $(BOARD_DIR)/linker.ld
110+
105111
LDFLAGS += \
106-
-Wl,-T$(BOARD_DIR)/linker.ld \
112+
-Wl,-T$(LINKER_SCRIPT) \
107113
-Wl,--gc-sections \
108114
--specs=nano.specs \
109115
--specs=rdimon.specs \
@@ -119,17 +125,22 @@ all: $(ELF)
119125
$(SRCS): $(FREERTOS_DIR)/.clonedone
120126

121127
# Add rules for patched build objects from SDK
122-
$(BUILD_DIR)/memfault-firmware-sdk/%.o: $(MEMFAULT_SDK_ROOT)/%.c
128+
$(BUILD_DIR)/memfault-firmware-sdk/%.c.o: $(MEMFAULT_SDK_ROOT)/%.c
123129
mkdir -p $(dir $@)
124130
$(info Compiling $<)
125131
$(CC) $(CFLAGS) $(INCLUDE_PATHS) -c $< -o $@
126132

127-
$(BUILD_DIR)/%.o: %.c
133+
$(BUILD_DIR)/%.c.o: %.c
128134
mkdir -p $(dir $@)
129135
$(info Compiling $<)
130136
$(CC) $(CFLAGS) $(INCLUDE_PATHS) -c $< -o $@
131137

132-
$(ELF).uncompressed: $(OBJS)
138+
$(BUILD_DIR)/%.cpp.o: %.cpp
139+
mkdir -p $(dir $@)
140+
$(info Compiling $<)
141+
$(CXX) -std=gnu++11 $(CFLAGS) $(INCLUDE_PATHS) -c $< -o $@
142+
143+
$(ELF).uncompressed: $(OBJS) $(LINKER_SCRIPT)
133144
$(info Linking $@)
134145
$(CC) $(CFLAGS) $(LDFLAGS) $(OBJS) -o $@
135146

examples/freertos/boards/qemu_mps2_an385/Makefile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,7 @@ RUN_COMMAND = qemu-system-arm -machine mps2-an385 -monitor null -semihosting \
1111

1212
DEBUG_COMMAND = $(RUN_COMMAND) $(ATTACH_DEBUGGER)
1313

14+
# Permit overriding the gdb executable
15+
GDB ?= gdb
1416
GDB_COMMAND = \
15-
gdb --ex 'target extended-remote :1234' $(ELF)
17+
$(GDB) --ex 'target extended-remote :1234' $(ELF)

examples/freertos/boards/qemu_mps2_an385/linker.ld

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,12 @@ SECTIONS
119119
__StackLimit = __StackTop - _Min_Stack_Size;
120120
PROVIDE(__stack = __StackTop);
121121

122+
log_fmt 0xF0000000 (INFO):
123+
{
124+
KEEP(*(*.log_fmt_hdr))
125+
KEEP(*(log_fmt))
126+
}
127+
122128
/* Check if data + heap + stack exceeds RAM limit */
123129
ASSERT(__StackLimit >= _heap_top, "region RAM overflowed with stack")
124130
}

examples/freertos/compact_log.cpp

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
//! @file
2+
//!
3+
//! Small example showcasing the use of compact logs from C++.
4+
5+
#include "compact_log.h"
6+
7+
#include <inttypes.h>
8+
9+
#include "memfault/components.h"
10+
11+
void compact_log_cpp_example(void) {
12+
#if MEMFAULT_COMPACT_LOG_ENABLE
13+
MEMFAULT_COMPACT_LOG_SAVE(kMemfaultPlatformLogLevel_Info,
14+
"This is a compact log example from c++ "
15+
// clang-format off
16+
"%d" " %" PRIu64 " %f" " %f" " %s",
17+
1234, (uint64_t)0x7, 1.0f, 2.0, "1212"
18+
// ^int ^uint64_t ^float ^double ^string
19+
// clang-format on
20+
);
21+
#endif
22+
}

0 commit comments

Comments
 (0)