Skip to content

Commit dde2145

Browse files
author
Memfault Inc
committed
Memfault Firmware SDK 0.27.1 (Build 327008)
1 parent 24f2c26 commit dde2145

File tree

14 files changed

+117
-15
lines changed

14 files changed

+117
-15
lines changed

CHANGES.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
1+
### Changes between Memfault SDK 0.27.1 and SDK 0.27.0 - Oct 11, 2021
2+
3+
#### :chart_with_upwards_trend: Improvements
4+
5+
- Extended mynewt RTOS port to capture coredumps via a
6+
[`os_coredump_cb`](ports/mynewt/src/memfault_platform_port.c) implementation
7+
when `MEMFAULT_COREDUMP_CB=1`
8+
9+
#### :house: Internal
10+
11+
- Fixed a few compiler warnings emitted when compiling with clang
12+
- Improved documentation for
13+
[coredump config with nRF5 SDK](ports/nrf5_sdk/nrf5_coredump_regions.c)
14+
115
### Changes between Memfault SDK 0.27.0 and SDK 0.26.1 - Oct 5, 2021
216

317
#### :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: 325530
2-
GIT COMMIT: d622ced50
1+
BUILD ID: 327008
2+
GIT COMMIT: 0b4bb4c57

components/core/src/memfault_log.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,7 @@ static void prv_log_save(eMemfaultPlatformLogLevel level,
322322
memfault_lock();
323323
{
324324
sMfltCircularBuffer *circ_bufp = &s_memfault_ram_logger.circ_buffer;
325-
const bool space_free = prv_try_free_space(circ_bufp, bytes_needed);
325+
const bool space_free = prv_try_free_space(circ_bufp, (int)bytes_needed);
326326
if (space_free) {
327327
sMfltRamLogEntry entry = {
328328
.len = (uint8_t)truncated_log_len,

components/http/src/memfault_http_utils.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ static int prv_str_to_dec(const char *buf, size_t buf_len, int *value_out) {
262262
}
263263

264264
*value_out = result;
265-
return idx;
265+
return (int)idx;
266266
}
267267

268268
//! @return true if parsing was successful, false if a parse error occurred
@@ -456,7 +456,7 @@ static bool prv_find_first_occurrence(const char *line, size_t total_len,
456456

457457
static bool prv_find_last_occurrence(const char *line, size_t total_len,
458458
char c, size_t *offset_out) {
459-
for (int offset = total_len - 1; offset >= 0; offset--) {
459+
for (int offset = (int)total_len - 1; offset >= 0; offset--) {
460460
if (line[offset] == c) {
461461
*offset_out = (size_t)offset;
462462
return true;

components/include/memfault/version.h

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

22-
#define MEMFAULT_SDK_VERSION { .major = 0, .minor = 27, .patch = 0 }
22+
#define MEMFAULT_SDK_VERSION { .major = 0, .minor = 27, .patch = 1 }
2323

2424
#ifdef __cplusplus
2525
}

components/util/src/memfault_rle.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ static void prv_handle_rle_change(sMemfaultRleCtx *ctx) {
2626
.write_len = repeated_pattern ? 1 : ctx->seq_count,
2727
};
2828

29-
int32_t rle_size = repeated_pattern ? ctx->seq_count : -ctx->seq_count;
29+
int32_t rle_size = (int)(repeated_pattern ? ctx->seq_count : -ctx->seq_count);
3030

3131
ctx->write_info.header_len = memfault_encode_varint_si32(rle_size, &ctx->write_info.header[0]);
3232

ports/mynewt/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@ section of your `syscfg.yml` file:
2323

2424
```yaml
2525
syscfg.vals:
26-
[...]
27-
MEMFAULT_COREDUMP_CB: 1
26+
[...]
2827
MEMFAULT_ENABLE: 1
28+
MEMFAULT_COREDUMP_CB: 1
2929
OS_COREDUMP: 1
3030
OS_COREDUMP_CB: 1
3131
```

ports/mynewt/pkg.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ pkg.deps:
1010
- "@apache-mynewt-core/sys/flash_map"
1111
- "@apache-mynewt-core/hw/hal"
1212
- "@apache-mynewt-core/mgmt/imgmgr"
13-
- "@apache-mynewt-core/util/memfault_sdk"
1413
- "@mcuboot/boot/bootutil"
1514

1615
pkg.ign_dirs:

ports/mynewt/src/memfault_platform_flash_backed_coredump.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
#include "memfault/components.h"
1919

20-
20+
#if MYNEWT_VAL(MEMFAULT_ENABLE)
2121

2222
const sMfltCoredumpRegion *
2323
memfault_platform_coredump_get_regions(const sCoredumpCrashInfo *crash_info,
@@ -146,3 +146,5 @@ void memfault_platform_coredump_storage_clear(void) {
146146
const uint8_t clear_byte = 0x0;
147147
memfault_platform_coredump_storage_write(0, &clear_byte, sizeof(clear_byte));
148148
}
149+
150+
#endif /* MYNEWT_VAL(MEMFAULT_ENABLE) */

ports/mynewt/src/memfault_platform_port.c

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
#include "memfault/components.h"
1717
#include "memfault/ports/reboot_reason.h"
1818

19+
#if MYNEWT_VAL(MEMFAULT_ENABLE)
20+
1921
void memfault_platform_get_device_info(sMemfaultDeviceInfo *info) {
2022
*info = (sMemfaultDeviceInfo) {
2123
// Note: serial number will be recovered from route used when posting
@@ -165,3 +167,47 @@ void memfault_platform_reboot_tracking_boot(void) {
165167
memfault_reboot_reason_get(&reset_info);
166168
memfault_reboot_tracking_boot(s_reboot_tracking, &reset_info);
167169
}
170+
171+
#if MYNEWT_VAL(MEMFAULT_COREDUMP_CB)
172+
173+
174+
static eMemfaultRebootReason s_reboot_reason = kMfltRebootReason_UnknownError;
175+
176+
#if MYNEWT_VAL(MEMFAULT_ASSERT_CB)
177+
void os_assert_cb(void) {
178+
s_reboot_reason = kMfltRebootReason_Assert;
179+
}
180+
#endif
181+
182+
static eMemfaultRebootReason prv_resolve_reason_from_active_isr(void) {
183+
// ARM Cortex-M have a standard set of exception numbers used for faults.
184+
//
185+
// The bottom byte of the XPSR register tells us which interrupt we are running from.
186+
// See https://mflt.io/cortex-m-exc-numbering
187+
uint32_t vect_active = __get_xPSR() & 0xff;
188+
switch (vect_active) {
189+
case 2:
190+
return kMfltRebootReason_Nmi;
191+
case 3:
192+
return kMfltRebootReason_HardFault;
193+
case 4:
194+
return kMfltRebootReason_MemFault;
195+
case 5:
196+
return kMfltRebootReason_BusFault;
197+
case 6:
198+
return kMfltRebootReason_UsageFault;
199+
default:
200+
return kMfltRebootReason_HardFault;
201+
}
202+
}
203+
204+
void os_coredump_cb(void *tf) {
205+
if (s_reboot_reason == kMfltRebootReason_UnknownError) {
206+
s_reboot_reason = prv_resolve_reason_from_active_isr();
207+
}
208+
209+
memfault_fault_handler(tf, s_reboot_reason);
210+
}
211+
#endif /* MYNEWT_VAL(MEMFAULT_COREDUMP_CB) */
212+
213+
#endif /* MYNEWT_VAL(MEMFAULT_ENABLE) */

0 commit comments

Comments
 (0)