Skip to content

Commit bf7e954

Browse files
author
Memfault Inc
committed
Memfault Firmware SDK 1.1.3 (Build 3171)
1 parent 5d57753 commit bf7e954

25 files changed

+421
-105
lines changed

CHANGES.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,29 @@
1+
### Changes between Memfault SDK 1.1.2 and 1.1.3 - Aug 8, 2023
2+
3+
#### :chart_with_upwards_trend: Improvements
4+
5+
- Set Memfault SDK version in a string metric on device boot, for easier
6+
tracking of SDK versions in the Memfault UI
7+
- Support using a different identifier for the GNU build id symbol (previously
8+
was fixed to `__start_gnu_build_id_start`). Use the
9+
`MEMFAULT_GNU_BUILD_ID_SYMBOL` define in `memfault_platform_config.h` to
10+
override the default. For Zephyr, the Kconfig option
11+
`CONFIG_MEMFAULT_GNU_BUILD_ID_SOURCE_BUILTIN` can be used to override the
12+
builtin section specifier + linker fragment for the GNU build ID. Thanks to
13+
@JordanYates for posting this change in
14+
[#60](https://github.com/memfault/memfault-firmware-sdk/pull/60) 🎉
15+
- Improvements to the ARMv7-R exception handling when the supervisor processor
16+
mode is active
17+
18+
- Zephyr:
19+
- Add an optional mode to create and open the HTTP socket in separate function
20+
calls, if the user needs to set additional socket options before connecting.
21+
See
22+
[ports/zephyr/include/memfault/ports/zephyr/http.h](ports/zephyr/include/memfault/ports/zephyr/http.h)
23+
for details. Fixes
24+
[#52](https://github.com/memfault/memfault-firmware-sdk/issues/52)- thanks
25+
to @anicare-tero for posting this 🎉
26+
127
### Changes between Memfault SDK 1.1.1 and 1.1.2 - July 11, 2023
228

329
#### :chart_with_upwards_trend: Improvements

VERSION

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
BUILD ID: 2861
2-
GIT COMMIT: 3a1297110
1+
BUILD ID: 3171
2+
GIT COMMIT: cd928ad15

components/core/src/memfault_build_id.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,13 @@
1717
#if MEMFAULT_USE_GNU_BUILD_ID
1818

1919
// Note: This variable is emitted by the linker script
20-
extern uint8_t __start_gnu_build_id_start[];
20+
extern uint8_t MEMFAULT_GNU_BUILD_ID_SYMBOL[];
2121

2222
MEMFAULT_BUILD_ID_QUALIFIER sMemfaultBuildIdStorage g_memfault_build_id = {
2323
.type = kMemfaultBuildIdType_GnuBuildIdSha1,
2424
.len = sizeof(sMemfaultElfNoteSection),
2525
.short_len = MEMFAULT_EVENT_INCLUDED_BUILD_ID_SIZE_BYTES,
26-
.storage = __start_gnu_build_id_start,
26+
.storage = MEMFAULT_GNU_BUILD_ID_SYMBOL,
2727
.sdk_version = MEMFAULT_SDK_VERSION,
2828
};
2929
#else

components/core/src/memfault_heap_stats.c

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,19 +81,30 @@ static uint16_t prv_get_previous_entry(uint16_t search_entry_index) {
8181

8282
//! Return the next entry index to write new data to
8383
//!
84-
//! First searches for unused entries
85-
//! If none are found then traverses list to oldest (last) entry
84+
//! First searches for never-used entries, then unused (used + freed) entries.
85+
//! If none are found then traverses list to oldest (last) entry.
8686
static uint16_t prv_get_new_entry_index(void) {
8787
sMfltHeapStatEntry *entry;
88+
uint16_t unused_index = MEMFAULT_HEAP_STATS_LIST_END;
8889

8990
for (uint16_t i = 0; i < MEMFAULT_ARRAY_SIZE(g_memfault_heap_stats_pool); i++) {
9091
entry = &g_memfault_heap_stats_pool[i];
9192

9293
if (!entry->info.in_use) {
93-
return i; // favor unused entries
94+
if (entry->info.size == 0) {
95+
return i; // favor never used entries
96+
}
97+
// save the first inactive entry found
98+
if (unused_index == MEMFAULT_HEAP_STATS_LIST_END) {
99+
unused_index = i;
100+
}
94101
}
95102
}
96103

104+
if (unused_index != MEMFAULT_HEAP_STATS_LIST_END) {
105+
return unused_index;
106+
}
107+
97108
// No unused entry found, return the oldest (entry with next index of
98109
// MEMFAULT_HEAP_STATS_LIST_END)
99110
return prv_get_previous_entry(MEMFAULT_HEAP_STATS_LIST_END);

components/include/memfault/components.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ extern "C" {
6868
#include "memfault/util/crc16_ccitt.h"
6969
#include "memfault/util/rle.h"
7070
#include "memfault/util/varint.h"
71+
#include "memfault/version.h"
7172

7273
#ifdef __cplusplus
7374
}

components/include/memfault/default_config.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,11 @@ extern "C" {
2626
#define MEMFAULT_USE_GNU_BUILD_ID 0
2727
#endif
2828

29+
//! Controls the name used to reference the GNU build ID data
30+
#ifndef MEMFAULT_GNU_BUILD_ID_SYMBOL
31+
#define MEMFAULT_GNU_BUILD_ID_SYMBOL __start_gnu_build_id_start
32+
#endif
33+
2934
//! Allows users to dial in the correct amount of storage for their
3035
//! software version + build ID string.
3136
#ifndef MEMFAULT_UNIQUE_VERSION_MAX_LEN

components/include/memfault/metrics/heartbeat_config.def

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
//! default health statistics for the fleet. All other metrics are provided by the user
33
//! of the sdk via the MEMFAULT_METRICS_USER_HEARTBEAT_DEFS_FILE file
44

5+
// Memfault SDK Version String
6+
#include "memfault/version.h"
7+
MEMFAULT_METRICS_STRING_KEY_DEFINE(MemfaultSdkMetric_sdk_version, sizeof(MEMFAULT_SDK_VERSION_STR) - 1)
58
// The time since the last heartbeat was collected in ms
69
MEMFAULT_METRICS_KEY_DEFINE(MemfaultSdkMetric_IntervalMs, kMemfaultMetricType_Timer)
710
// The number of reboots that have taken place since the last heartbeat was collected

components/include/memfault/version.h

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

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

2425
#ifdef __cplusplus
2526
}

components/metrics/src/memfault_metrics.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -897,6 +897,9 @@ int memfault_metrics_boot(const sMemfaultEventStorageImpl *storage_impl,
897897
return rv;
898898
}
899899

900+
rv = memfault_metrics_heartbeat_set_string(MEMFAULT_METRICS_KEY(MemfaultSdkMetric_sdk_version),
901+
MEMFAULT_SDK_VERSION_STR);
902+
900903
rv = prv_init_unexpected_reboot_metric();
901904
if (rv != 0) {
902905
return rv;

components/panics/src/memfault_fault_handling_armv7_a_r.c

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ bool memfault_arch_is_inside_isr(void) {
7575
// Reference Manual section "B1.3.1 ARM processor modes" for these values.
7676
#define CPSR_MODE_msk 0x1f
7777
#define CPSR_USER_msk 0x10
78+
#define CPSR_SUPERVISOR_msk 0x13
7879
#define CPSR_SYSTEM_msk 0x1f
7980

8081
uint32_t cpsr;
@@ -84,8 +85,9 @@ bool memfault_arch_is_inside_isr(void) {
8485

8586
const bool in_user_mode = (mode == CPSR_USER_msk);
8687
const bool in_system_mode = (mode == CPSR_SYSTEM_msk);
88+
const bool in_supervisor_mode = (mode == CPSR_SUPERVISOR_msk);
8789

88-
return !(in_user_mode || in_system_mode);
90+
return !(in_user_mode || in_system_mode || in_supervisor_mode);
8991
}
9092

9193
#if defined(__GNUC__)
@@ -237,6 +239,9 @@ void memfault_fault_handler(const sMfltRegState *regs, eMemfaultRebootReason rea
237239
// Processor mode values, used when saving LR and SPSR to the appropriate stack.
238240
// From https://developer.arm.com/documentation/dui0801/a/CHDEDCCD
239241
// Defined as strings for macro concatenation below
242+
#define CPU_MODE_FIQ_STR "0x11"
243+
#define CPU_MODE_IRQ_STR "0x12"
244+
#define CPU_MODE_SUPERVISOR_STR "0x13"
240245
#define CPU_MODE_ABORT_STR "0x17"
241246
#define CPU_MODE_UNDEFINED_STR "0x1b"
242247
#define CPU_MODE_SYSTEM_STR "0x1f"
@@ -281,7 +286,28 @@ void memfault_fault_handler(const sMfltRegState *regs, eMemfaultRebootReason rea
281286
/* push user mode regs at point of fault, including sp + lr */ \
282287
"mov r8, r1 \n" \
283288
"mov r1, sp \n" \
289+
/* Save SPSR and mask mode bits */ \
290+
"mrs r9, spsr \n" \
291+
"and r9, #0x1f \n" \
292+
/* Check each applicable mode and set current mode on a match */ \
293+
"cmp r9, #" CPU_MODE_IRQ_STR " \n" \
294+
"bne fiq_mode_%= \n" \
295+
"cps #" CPU_MODE_IRQ_STR " \n" \
296+
"b store_regs_%= \n" \
297+
"fiq_mode_%=: \n" \
298+
"cmp r9, #" CPU_MODE_FIQ_STR " \n" \
299+
"bne supervisor_mode_%= \n" \
300+
"cps #" CPU_MODE_FIQ_STR " \n" \
301+
"b store_regs_%= \n" \
302+
"supervisor_mode_%=: \n" \
303+
"cmp r9, #" CPU_MODE_SUPERVISOR_STR " \n" \
304+
"bne system_mode_%= \n" \
305+
"cps #" CPU_MODE_SUPERVISOR_STR " \n" \
306+
"b store_regs_%= \n" \
307+
/* Fall back to system mode if no match */ \
308+
"system_mode_%=: \n" \
284309
"cps #" CPU_MODE_SYSTEM_STR " \n" \
310+
"store_regs_%=: \n" \
285311
"stmfd r1!, {r8-r12, sp, lr} \n"\
286312
"cps #" _mode_string" \n" \
287313
/* save active registers in exception frame */ \

0 commit comments

Comments
 (0)