Skip to content

Commit 0c0f78a

Browse files
author
Memfault Inc
committed
Memfault Firmware SDK 0.29.0 (Build 400378)
1 parent 2fe5ba1 commit 0c0f78a

File tree

31 files changed

+1500
-21
lines changed

31 files changed

+1500
-21
lines changed

CHANGES.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,37 @@
1+
### Changes between Memfault SDK 0.29.0 and SDK 0.28.2 - Feb 28, 2022
2+
3+
#### :rocket: New Features
4+
5+
- Added a port to Particle's Device OS. More details can be found in
6+
[`ports/particle/README.md`](ports/particle/README.md).
7+
- Added several more
8+
[reboot reason options](components/include/memfault/core/reboot_reason_types.h#L16):
9+
- `kMfltRebootReason_KernelPanic` for explicitly tracking fatal resets from
10+
within a OS or RTOS
11+
- `kMfltRebootReason_FirmwareUpdateError` for explicitly tracking resets due
12+
to firmware update failures or rollbacks
13+
14+
#### :chart_with_upwards_trend: Improvements
15+
16+
- Added a convenience utility function for base64 encoding data in place. See
17+
[`memfault_base64_encode_inplace`](components/include/memfault/util/base64.h#L35)
18+
for more details!
19+
- Fixed compiler error in ESP-IDF port when compiling for ESP32-S2 targets
20+
21+
#### :house: Internal
22+
23+
- Added configuration option,
24+
[`MEMFAULT_COREDUMP_INCLUDE_BUILD_ID`](components/include/memfault/default_config.h#L1),
25+
which can be used to disable storing the Build Id in a coredump.
26+
- Fixed stale link in Mbed example app [`README`](examples/mbed/README.md).
27+
- Added [utility script](scripts/create_arduino_library.py) that can be used to
28+
"arduino-ify" the code in this repo.
29+
- Fixed linter errors in python scripts after addition of flake8-bugbear linter
30+
in CI.
31+
- Fixed compiler error in
32+
[nRF91 sample test app](examples/nrf-connect-sdk/nrf9160/memfault_demo_app)
33+
when compiling with the nRF Connect SDK 1.2 release
34+
135
### Changes between Memfault SDK 0.28.2 and SDK 0.28.1 - Feb 1, 2022
236

337
#### :house: Internal

VERSION

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
BUILD ID: 384364
2-
GIT COMMIT: 73cde73c3
1+
BUILD ID: 400378
2+
GIT COMMIT: b015b1226

components/include/memfault/core/reboot_reason_types.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,14 @@ typedef enum MfltResetReason {
5757
// for example, if power to the clock is cut or the lock for the PLL is lost.
5858
kMfltRebootReason_ClockFailure = 0x8007,
5959

60+
// A software reset triggered when the OS or RTOS end-user code is running on top of identifies
61+
// a fatal error condition.
62+
kMfltRebootReason_KernelPanic = 0x8008,
63+
64+
// A reset triggered when an attempt to upgrade to a new OTA image has failed and a rollback
65+
// to a previous version was initiated
66+
kMfltRebootReason_FirmwareUpdateError = 0x8009,
67+
6068
// Resets from Arm Faults
6169
kMfltRebootReason_BusFault = 0x9100,
6270
kMfltRebootReason_MemFault = 0x9200,

components/include/memfault/default_config.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,15 @@ extern "C" {
6464
#define MEMFAULT_EVENT_INCLUDE_BUILD_ID 1
6565
#endif
6666

67+
//! Controls whether or not the Build Id is encoded in coredumps
68+
//!
69+
//! The Build Id can be used by Memfault to reliably find the corresponding
70+
//! symbol file while processing a coredump. When disabled, the software version & type
71+
//! are used instead to find the symbol file.
72+
#ifndef MEMFAULT_COREDUMP_INCLUDE_BUILD_ID
73+
#define MEMFAULT_COREDUMP_INCLUDE_BUILD_ID 1
74+
#endif
75+
6776
//! Controls the truncation of the Build Id that is encoded in events
6877
//!
6978
//! The full Build Id hash is 20 bytes, but is truncated by default to save space. The

components/include/memfault/util/base64.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ extern "C" {
1818
//! using base64
1919
#define MEMFAULT_BASE64_ENCODE_LEN(bin_len) (4 * (((bin_len) + 2) / 3))
2020

21+
//! Computes the maximum size a base64 binary blob will wind up being when decoded back into binary
22+
//! (It is possible the actual size is up to 2 bytes less in length if padding bytes were added)
23+
#define MEMFAULT_BASE64_MAX_DECODE_LEN(base64_len) ((3 * (base64_len)) / 4)
24+
2125
//! Base64 encode a given binary buffer
2226
//!
2327
//! @note Uses the standard base64 alphabet from https://tools.ietf.org/html/rfc4648#section-4
@@ -28,6 +32,16 @@ extern "C" {
2832
//! be >= MEMFAULT_BASE64_ENCODE_LEN(bin_len) bytes
2933
void memfault_base64_encode(const void *buf, size_t buf_len, void *base64_out);
3034

35+
//! Base64 encode a given binary buffer in place
36+
//!
37+
//! @note Uses the standard base64 alphabet from https://tools.ietf.org/html/rfc4648#section-4
38+
//!
39+
//! @param[in, out] buf Pointer to the binary buffer to base64 encode. The total length of the
40+
//! buffer must be >= MEMFAULT_BASE64_ENCODE_LEN(bin_len) bytes since we will be encoding in
41+
//! place
42+
//! @param[in] bin_len Length of the binary data starting at buf[0] to be base64 encoded.
43+
void memfault_base64_encode_inplace(void *buf, size_t bin_len);
44+
3145
#ifdef __cplusplus
3246
}
3347
#endif

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 = 28, .patch = 2 }
22+
#define MEMFAULT_SDK_VERSION { .major = 0, .minor = 29, .patch = 0 }
2323

2424
#ifdef __cplusplus
2525
}

components/panics/src/memfault_coredump.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,13 +243,15 @@ static bool prv_write_device_info_blocks(sMfltCoredumpWriteCtx *ctx) {
243243
struct MemfaultDeviceInfo info;
244244
memfault_platform_get_device_info(&info);
245245

246+
#if MEMFAULT_COREDUMP_INCLUDE_BUILD_ID
246247
sMemfaultBuildInfo build_info;
247248
if (memfault_build_info_read(&build_info)) {
248249
if (!prv_write_non_memory_block(kMfltCoredumpRegionType_BuildId,
249250
build_info.build_id, sizeof(build_info.build_id), ctx)) {
250251
return false;
251252
}
252253
}
254+
#endif
253255

254256
if (info.device_serial) {
255257
if (!prv_write_non_memory_block(kMfltCoredumpRegionType_DeviceSerial,

components/util/src/memfault_base64.c

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,32 @@ void memfault_base64_encode(const void *buf, size_t buf_len, void *base64_out) {
3333
out_bufp[curr_idx++] = ((bin_idx + 2) < buf_len) ? prv_get_char_from_word(triple, 0) : '=';
3434
}
3535
}
36+
37+
void memfault_base64_encode_inplace(void *buf, size_t bin_len) {
38+
// When encoding with base64, every 3 bytes is represented as 4 characters. If the input binary
39+
// blob is not a multiple of 3, we will need to use the "=" padding character. Here we determine
40+
// what index to start encoding at that will end on a multiple of 3 boundary
41+
const size_t remainder = bin_len % 3;
42+
const size_t start_idx = (remainder == 0) ? bin_len - 3 : bin_len - remainder;
43+
44+
// The index to write the base64 character conversion into starting with the last location
45+
const size_t encoded_len = MEMFAULT_BASE64_ENCODE_LEN(bin_len);
46+
int curr_idx = (int)encoded_len - 1;
47+
48+
const uint8_t *bin_inp = (const uint8_t *)buf;
49+
char *out_bufp = (char *)buf;
50+
51+
// NB: By encoding from last set of 3 bytes to first set, we can edit the buffer inplace
52+
// without clobbering the input data we need to determine the encoding
53+
for (int bin_idx = (int)start_idx; bin_idx >= 0; bin_idx -= 3) {
54+
const uint32_t byte0 = bin_inp[bin_idx];
55+
const uint32_t byte1 = ((bin_idx + 1) < (int)bin_len) ? bin_inp[bin_idx + 1] : 0;
56+
const uint32_t byte2 = ((bin_idx + 2) < (int)bin_len) ? bin_inp[bin_idx + 2] : 0;
57+
const uint32_t triple = (byte0 << 16) + (byte1 << 8) + byte2;
58+
59+
out_bufp[curr_idx--] = ((bin_idx + 2) < (int)bin_len) ? prv_get_char_from_word(triple, 0) : '=';
60+
out_bufp[curr_idx--] = ((bin_idx + 1) < (int)bin_len) ? prv_get_char_from_word(triple, 1) : '=';
61+
out_bufp[curr_idx--] = prv_get_char_from_word(triple, 2);
62+
out_bufp[curr_idx--] = prv_get_char_from_word(triple, 3);
63+
}
64+
}

examples/esp32/apps/memfault_demo_app/sdkconfig.defaults

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,5 @@ CONFIG_ESPTOOLPY_FLASHSIZE_4MB=y
2222
# https://github.com/espressif/esp-idf/issues/7631#issuecomment-934212224
2323
# We only need the typical root certs, so this works for our app.
2424
CONFIG_MBEDTLS_CERTIFICATE_BUNDLE_DEFAULT_CMN=y
25+
26+
CONFIG_ESP32_ENABLE_COREDUMP_TO_FLASH=y

examples/mbed/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ SDK and performed the installation steps that are mentioned there.
1919
You must have the
2020
[GCC ARM](https://developer.arm.com/tools-and-software/open-source-software/developer-tools/gnu-toolchain/gnu-rm/downloads)
2121
toolchain and the
22-
[Mbed command line tools](https://os.mbed.com/docs/mbed-os/v5.14/tools/developing-mbed-cli.html)
22+
[Mbed command line tools](https://os.mbed.com/docs/mbed-os/v5.15/tools/developing-mbed-cli.html)
2323
installed before you begin.
2424

2525
### Downloading the demo app dependencies

0 commit comments

Comments
 (0)