Skip to content

Commit 912f34d

Browse files
author
Memfault Inc
committed
Memfault Firmware SDK 1.6.1 (Build 5829)
1 parent 3d51c80 commit 912f34d

File tree

49 files changed

+785
-165
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+785
-165
lines changed

.circleci/Dockerfile

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,11 @@ ENV DEBIAN_FRONTEND=noninteractive \
2424
ARG MEMFAULT_SDK_APT_DEPS="\
2525
build-essential \
2626
cpputest \
27+
curl \
2728
gcc-12 \
2829
g++-12 \
2930
git \
31+
gnupg \
3032
python3.10 \
3133
python3.10-venv\
3234
"
@@ -74,6 +76,13 @@ RUN \
7476
lcov --version && \
7577
genhtml --version
7678

79+
# Install clang-17
80+
RUN \
81+
echo deb http://apt.llvm.org/jammy/ llvm-toolchain-jammy-17 main >> /etc/apt/sources.list.d/llvm.list && \
82+
echo deb-src http://apt.llvm.org/jammy/ llvm-toolchain-jammy-17 main >> /etc/apt/sources.list.d/llvm.list && \
83+
wget -q -O - http://apt.llvm.org/llvm-snapshot.gpg.key|apt-key add - && \
84+
apt-get update && apt-get install -y clang-17 llvm-17
85+
7786
ENV PATH=/home/circleci/lcov-${LCOV_VERSION}/bin:$PATH
7887

7988
USER circleci

.circleci/config.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ version: 2.1
1515
executors:
1616
memfault-ci:
1717
docker:
18-
- image: memfault/memfault-firmware-sdk-ci:2023-10-13
18+
- image: memfault/memfault-firmware-sdk-ci:2024-01-19
1919
working_directory: ~/repo
2020

2121
commands:

.clang-format

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# Please keep each property in alphabetical order to help compare between the other .clang-format
2+
# files.
3+
# This file is used by code editor formatting plugins
4+
---
5+
BasedOnStyle: Google
6+
---
7+
Language: Cpp
8+
9+
AlignArrayOfStructures: None
10+
AllowShortBlocksOnASingleLine: Empty
11+
AllowShortFunctionsOnASingleLine: Empty
12+
AlwaysBreakBeforeMultilineStrings: false
13+
AttributeMacros:
14+
- 'MEMFAULT_PACKED'
15+
- 'MEMFAULT_PACKED_STRUCT'
16+
- 'MEMFAULT_NORETURN'
17+
- 'MEMFAULT_NAKED_FUNC'
18+
- 'MEMFAULT_UNREACHABLE'
19+
- 'MEMFAULT_NO_OPT'
20+
- 'MEMFAULT_ALIGNED'
21+
- 'MEMFAULT_UNUSED'
22+
- 'MEMFAULT_USED'
23+
- 'MEMFAULT_WEAK'
24+
- 'MEMFAULT_PRINTF_LIKE_FUNC'
25+
- 'MEMFAULT_PUT_IN_SECTION'
26+
BitFieldColonSpacing: None
27+
BreakBeforeBinaryOperators: None
28+
BreakBeforeTernaryOperators: false
29+
ColumnLimit: 100
30+
ContinuationIndentWidth: 2
31+
Cpp11BracedListStyle: false
32+
DerivePointerAlignment: false
33+
FixNamespaceComments: false
34+
ForEachMacros:
35+
- 'MEMFAULT_SHELL_FOR_EACH_COMMAND'
36+
IndentPPDirectives: BeforeHash
37+
IndentWidth: 2
38+
NamespaceIndentation: All
39+
NamespaceMacros:
40+
- 'TEST_GROUP'
41+
- 'TEST'
42+
PointerAlignment: Right
43+
SpaceInEmptyBlock: true
44+
WhitespaceSensitiveMacros:
45+
- 'MEMFAULT_ZEPHYR_INCLUDE'
46+
- 'MEMFAULT_QUOTE'
47+
- 'Pragma'
48+
...

CHANGELOG.md

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

3+
## [1.6.1] - 2024-01-29
4+
5+
### :chart_with_upwards_trend: Improvements
6+
7+
- General:
8+
9+
- Add a reboot reason self test, which validates the reboot reason data is
10+
correctly preserved through device reboot. This test first sets a custom
11+
reboot reason, then calls `memfault_platform_reboot()` to reboot the system.
12+
To verify the operation succeeded, the self test is called again to check
13+
the reboot reason was saved. The reboot reason self test can be performed by
14+
passing the appropriate flags when calling the `memfault_self_test_run()`
15+
file (see
16+
[`components/include/memfault/core/self_test.h`](components/include/memfault/core/self_test.h)
17+
for details), and from the demo CLI as
18+
`self_test reboot`/`self_test reboot_verify`.
19+
20+
- Fix a `ti-armcl` compiler warning due to enumeration mismatch in
21+
initialization (`#190-D`).
22+
23+
- Add a compile-time option to enable the self-test module. Enabling the
24+
self-test increases code space utilization, and is usually of use during
25+
set-up and SDK integration testing. The self-test can be enabled by setting
26+
`#define MEMFAULT_SELF_TEST_ENABLED 1` in `memfault_platform_config.h`, or
27+
via `CONFIG_MEMFAULT_CLI_SELF_TEST=y` for ESP-IDF and
28+
`CONFIG_MEMFAULT_SHELL_SELF_TEST=y` for Zephyr.
29+
30+
- ESP-IDF:
31+
32+
- Expose a new function `memfault_esp_port_ota_get_release_url()` for fetching
33+
the OTA release URL without performing a download. This is useful for cases
34+
where the URL is needed for other purposes, such as for fetching a
35+
downstream device OTA artifact. See
36+
[`ports/esp_idf/memfault/include/memfault/esp_port/http_client.h`](ports/esp_idf/memfault/include/memfault/esp_port/http_client.h)
37+
for details.
38+
39+
- nRF-Connect SDK:
40+
41+
- Add support for the new `fota_download_any()` (see documentation
42+
[here](https://github.com/nrfconnect/sdk-nrf/blob/0692684d0e0b924335882969bc7bf474c673ac81/doc/nrf/releases_and_maturity/releases/release-notes-changelog.rst#L847-L848)),
43+
which accepts a list of certificates to use when executing FOTA downloads.
44+
This API is expected to be included in the upcoming nRF-Connect SDK v2.6.0
45+
release.
46+
347
## [1.6.0] - 2024-01-09
448

549
### :chart_with_upwards_trend: Improvements

Dockerfile

Lines changed: 0 additions & 41 deletions
This file was deleted.

VERSION

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
BUILD ID: 5464
2-
GIT COMMIT: 96c12257a
3-
VERSION: 1.6.0
1+
BUILD ID: 5829
2+
GIT COMMIT: 3f3b1b0ae
3+
VERSION: 1.6.1

components/core/src/memfault_self_test.c

Lines changed: 72 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#include "memfault/core/debug_log.h"
1717
#include "memfault/core/event_storage.h"
1818
#include "memfault/core/math.h"
19+
#include "memfault/core/platform/core.h"
1920
#include "memfault/core/platform/device_info.h"
2021
#include "memfault/core/reboot_tracking.h"
2122
#include "memfault/core/self_test.h"
@@ -24,6 +25,8 @@
2425
#include "memfault/panics/coredump_impl.h"
2526
#include "memfault_self_test_private.h"
2627

28+
#if !defined(MEMFAULT_UNITTEST_SELF_TEST)
29+
2730
typedef enum {
2831
kDeviceInfoField_DeviceSerial = 0,
2932
kDeviceInfoField_SoftwareType,
@@ -130,8 +133,6 @@ static uint32_t prv_validate_build_id(void) {
130133
}
131134

132135
static void prv_device_info_test_describe(uint32_t results) {
133-
MEMFAULT_SELF_TEST_PRINT_HEADER("Device Info Test");
134-
135136
if (results == 0) {
136137
MEMFAULT_LOG_INFO("All fields valid");
137138
return;
@@ -144,17 +145,19 @@ static void prv_device_info_test_describe(uint32_t results) {
144145
MEMFAULT_LOG_ERROR("%s invalid", s_device_info_field_names[i]);
145146
}
146147
}
147-
MEMFAULT_LOG_INFO(MEMFAULT_SELF_TEST_END_OUTPUT);
148148
}
149149

150150
uint32_t memfault_self_test_device_info_test(void) {
151151
uint32_t results = 0;
152+
MEMFAULT_SELF_TEST_PRINT_HEADER("Device Info Test");
153+
152154
// Validate the build ID
153155
results |= prv_validate_build_id();
154156
// Valid device info fields
155157
results |= prv_validate_device_info();
156158

157159
prv_device_info_test_describe(results);
160+
MEMFAULT_LOG_INFO(MEMFAULT_SELF_TEST_END_OUTPUT);
158161
return results;
159162
}
160163

@@ -192,15 +195,24 @@ static const struct {
192195
},
193196
};
194197

195-
void memfault_self_test_component_boot_test(void) {
198+
uint32_t memfault_self_test_component_boot_test(void) {
199+
uint32_t result = 0;
196200
MEMFAULT_SELF_TEST_PRINT_HEADER("Component Boot Test");
197201
MEMFAULT_LOG_INFO("%-16s|%8s|", "Component", "Booted?");
198202
MEMFAULT_LOG_INFO("-----------------------------");
199203
for (size_t i = 0; i < MEMFAULT_ARRAY_SIZE(s_boot_components); i++) {
200204
bool booted = s_boot_components[i].booted();
201-
MEMFAULT_LOG_INFO("%-16s|%8s|", s_boot_components[i].component_name, booted ? "yes" : "no");
205+
if (!booted) {
206+
MEMFAULT_LOG_ERROR("%-16s|%8s|", s_boot_components[i].component_name, "no");
207+
result |= (1 << i);
208+
}
209+
}
210+
211+
if (result == 0) {
212+
MEMFAULT_LOG_INFO("All components booted");
202213
}
203214
MEMFAULT_LOG_INFO(MEMFAULT_SELF_TEST_END_OUTPUT);
215+
return result;
204216
}
205217

206218
void memfault_self_test_data_export_test(void) {
@@ -271,10 +283,59 @@ uint32_t memfault_self_test_coredump_regions_test(void) {
271283
return result;
272284
}
273285

274-
int memfault_self_test_run(void) {
275-
// Run each test one at a time and return result of all runs OR'd together
276-
memfault_self_test_component_boot_test();
277-
memfault_self_test_data_export_test();
278-
memfault_self_test_coredump_regions_test();
279-
return (memfault_self_test_device_info_test() != 0);
286+
MEMFAULT_NORETURN void memfault_self_test_reboot_reason_test(void) {
287+
// Set a known reason and allow the device to reboot
288+
MEMFAULT_SELF_TEST_PRINT_HEADER("Reboot Reason Test");
289+
MEMFAULT_LOG_INFO("This test will now reboot the device to test reboot reason tracking");
290+
MEMFAULT_LOG_INFO("After the device reboots, please run with reboot_verify argument");
291+
MEMFAULT_LOG_INFO(MEMFAULT_SELF_TEST_END_OUTPUT);
292+
MEMFAULT_REBOOT_MARK_RESET_IMMINENT(kMfltRebootReason_SelfTest);
293+
memfault_platform_reboot();
294+
}
295+
296+
uint32_t memfault_self_test_reboot_reason_test_verify(void) {
297+
// Use explicit initializer to avoid ti-armcl warning
298+
sMfltRebootReason reboot_reason = {
299+
.prior_stored_reason = kMfltRebootReason_Unknown,
300+
.reboot_reg_reason = kMfltRebootReason_Unknown,
301+
};
302+
int result = memfault_reboot_tracking_get_reboot_reason(&reboot_reason);
303+
304+
bool success = (result == 0) && (reboot_reason.prior_stored_reason == kMfltRebootReason_SelfTest);
305+
MEMFAULT_SELF_TEST_PRINT_HEADER("Reboot Reason Test");
306+
if (success) {
307+
MEMFAULT_LOG_INFO("Reboot reason test successful");
308+
} else {
309+
MEMFAULT_LOG_ERROR("Reboot reason test failed:");
310+
MEMFAULT_LOG_ERROR("get_reboot_reason result: %d, "
311+
"prior_stored_reason: 0x%08" PRIx32,
312+
result, (uint32_t)reboot_reason.prior_stored_reason);
313+
}
314+
MEMFAULT_LOG_INFO(MEMFAULT_SELF_TEST_END_OUTPUT);
315+
return success ? 0 : 1;
316+
}
317+
318+
#endif // defined(MEMFAULT_UNITTEST_SELF_TEST)
319+
320+
int memfault_self_test_run(uint32_t run_flags) {
321+
uint32_t result = 0;
322+
if (run_flags & kMemfaultSelfTestFlag_DeviceInfo) {
323+
result |= memfault_self_test_device_info_test();
324+
}
325+
if (run_flags & kMemfaultSelfTestFlag_ComponentBoot) {
326+
result |= memfault_self_test_component_boot_test();
327+
}
328+
if (run_flags & kMemfaultSelfTestFlag_CoredumpRegions) {
329+
result |= memfault_self_test_coredump_regions_test();
330+
}
331+
if (run_flags & kMemfaultSelfTestFlag_DataExport) {
332+
memfault_self_test_data_export_test();
333+
}
334+
if (run_flags & kMemfaultSelfTestFlag_RebootReason) {
335+
memfault_self_test_reboot_reason_test();
336+
}
337+
if (run_flags & kMemfaultSelfTestFlag_RebootReasonVerify) {
338+
result = memfault_self_test_reboot_reason_test_verify();
339+
}
340+
return (result == 0) ? 0 : 1;
280341
}

components/core/src/memfault_self_test_private.h

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
#include <stdbool.h>
88
#include <stdint.h>
99

10+
#include "memfault/core/compiler.h"
11+
1012
#ifdef __cplusplus
1113
extern "C" {
1214
#endif
@@ -36,14 +38,24 @@ bool memfault_self_test_valid_sw_version(unsigned char c);
3638
uint32_t memfault_self_test_device_info_test(void);
3739

3840
//! Runs component boot test
39-
void memfault_self_test_component_boot_test(void);
41+
uint32_t memfault_self_test_component_boot_test(void);
4042

4143
//! Data export test
4244
void memfault_self_test_data_export_test(void);
4345

4446
//! Runs coredump regions test
4547
uint32_t memfault_self_test_coredump_regions_test(void);
4648

49+
//! Runs reboot reason test
50+
//!
51+
//! This function begins the test by setting a known reboot reason and then rebooting the device
52+
//! After the device reboots, memfault_self_test_reboot_reason_test_verify should be used to verify
53+
//! the test results
54+
MEMFAULT_NORETURN void memfault_self_test_reboot_reason_test(void);
55+
56+
//! Verifies reboot reason test results
57+
uint32_t memfault_self_test_reboot_reason_test_verify(void);
58+
4759
#ifdef __cplusplus
4860
}
4961
#endif

0 commit comments

Comments
 (0)