Skip to content

Commit

Permalink
Memfault Firmware SDK 1.6.1 (Build 5829)
Browse files Browse the repository at this point in the history
  • Loading branch information
Memfault Inc committed Jan 29, 2024
1 parent 3d51c80 commit 912f34d
Show file tree
Hide file tree
Showing 49 changed files with 785 additions and 165 deletions.
9 changes: 9 additions & 0 deletions .circleci/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,11 @@ ENV DEBIAN_FRONTEND=noninteractive \
ARG MEMFAULT_SDK_APT_DEPS="\
build-essential \
cpputest \
curl \
gcc-12 \
g++-12 \
git \
gnupg \
python3.10 \
python3.10-venv\
"
Expand Down Expand Up @@ -74,6 +76,13 @@ RUN \
lcov --version && \
genhtml --version

# Install clang-17
RUN \
echo deb http://apt.llvm.org/jammy/ llvm-toolchain-jammy-17 main >> /etc/apt/sources.list.d/llvm.list && \
echo deb-src http://apt.llvm.org/jammy/ llvm-toolchain-jammy-17 main >> /etc/apt/sources.list.d/llvm.list && \
wget -q -O - http://apt.llvm.org/llvm-snapshot.gpg.key|apt-key add - && \
apt-get update && apt-get install -y clang-17 llvm-17

ENV PATH=/home/circleci/lcov-${LCOV_VERSION}/bin:$PATH

USER circleci
Expand Down
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ version: 2.1
executors:
memfault-ci:
docker:
- image: memfault/memfault-firmware-sdk-ci:2023-10-13
- image: memfault/memfault-firmware-sdk-ci:2024-01-19
working_directory: ~/repo

commands:
Expand Down
48 changes: 48 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# Please keep each property in alphabetical order to help compare between the other .clang-format
# files.
# This file is used by code editor formatting plugins
---
BasedOnStyle: Google
---
Language: Cpp

AlignArrayOfStructures: None
AllowShortBlocksOnASingleLine: Empty
AllowShortFunctionsOnASingleLine: Empty
AlwaysBreakBeforeMultilineStrings: false
AttributeMacros:
- 'MEMFAULT_PACKED'
- 'MEMFAULT_PACKED_STRUCT'
- 'MEMFAULT_NORETURN'
- 'MEMFAULT_NAKED_FUNC'
- 'MEMFAULT_UNREACHABLE'
- 'MEMFAULT_NO_OPT'
- 'MEMFAULT_ALIGNED'
- 'MEMFAULT_UNUSED'
- 'MEMFAULT_USED'
- 'MEMFAULT_WEAK'
- 'MEMFAULT_PRINTF_LIKE_FUNC'
- 'MEMFAULT_PUT_IN_SECTION'
BitFieldColonSpacing: None
BreakBeforeBinaryOperators: None
BreakBeforeTernaryOperators: false
ColumnLimit: 100
ContinuationIndentWidth: 2
Cpp11BracedListStyle: false
DerivePointerAlignment: false
FixNamespaceComments: false
ForEachMacros:
- 'MEMFAULT_SHELL_FOR_EACH_COMMAND'
IndentPPDirectives: BeforeHash
IndentWidth: 2
NamespaceIndentation: All
NamespaceMacros:
- 'TEST_GROUP'
- 'TEST'
PointerAlignment: Right
SpaceInEmptyBlock: true
WhitespaceSensitiveMacros:
- 'MEMFAULT_ZEPHYR_INCLUDE'
- 'MEMFAULT_QUOTE'
- 'Pragma'
...
44 changes: 44 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,49 @@
# Memfault Firmware SDK Changelog

## [1.6.1] - 2024-01-29

### :chart_with_upwards_trend: Improvements

- General:

- Add a reboot reason self test, which validates the reboot reason data is
correctly preserved through device reboot. This test first sets a custom
reboot reason, then calls `memfault_platform_reboot()` to reboot the system.
To verify the operation succeeded, the self test is called again to check
the reboot reason was saved. The reboot reason self test can be performed by
passing the appropriate flags when calling the `memfault_self_test_run()`
file (see
[`components/include/memfault/core/self_test.h`](components/include/memfault/core/self_test.h)
for details), and from the demo CLI as
`self_test reboot`/`self_test reboot_verify`.

- Fix a `ti-armcl` compiler warning due to enumeration mismatch in
initialization (`#190-D`).

- Add a compile-time option to enable the self-test module. Enabling the
self-test increases code space utilization, and is usually of use during
set-up and SDK integration testing. The self-test can be enabled by setting
`#define MEMFAULT_SELF_TEST_ENABLED 1` in `memfault_platform_config.h`, or
via `CONFIG_MEMFAULT_CLI_SELF_TEST=y` for ESP-IDF and
`CONFIG_MEMFAULT_SHELL_SELF_TEST=y` for Zephyr.

- ESP-IDF:

- Expose a new function `memfault_esp_port_ota_get_release_url()` for fetching
the OTA release URL without performing a download. This is useful for cases
where the URL is needed for other purposes, such as for fetching a
downstream device OTA artifact. See
[`ports/esp_idf/memfault/include/memfault/esp_port/http_client.h`](ports/esp_idf/memfault/include/memfault/esp_port/http_client.h)
for details.

- nRF-Connect SDK:

- Add support for the new `fota_download_any()` (see documentation
[here](https://github.com/nrfconnect/sdk-nrf/blob/0692684d0e0b924335882969bc7bf474c673ac81/doc/nrf/releases_and_maturity/releases/release-notes-changelog.rst#L847-L848)),
which accepts a list of certificates to use when executing FOTA downloads.
This API is expected to be included in the upcoming nRF-Connect SDK v2.6.0
release.

## [1.6.0] - 2024-01-09

### :chart_with_upwards_trend: Improvements
Expand Down
41 changes: 0 additions & 41 deletions Dockerfile

This file was deleted.

6 changes: 3 additions & 3 deletions VERSION
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
BUILD ID: 5464
GIT COMMIT: 96c12257a
VERSION: 1.6.0
BUILD ID: 5829
GIT COMMIT: 3f3b1b0ae
VERSION: 1.6.1
83 changes: 72 additions & 11 deletions components/core/src/memfault_self_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include "memfault/core/debug_log.h"
#include "memfault/core/event_storage.h"
#include "memfault/core/math.h"
#include "memfault/core/platform/core.h"
#include "memfault/core/platform/device_info.h"
#include "memfault/core/reboot_tracking.h"
#include "memfault/core/self_test.h"
Expand All @@ -24,6 +25,8 @@
#include "memfault/panics/coredump_impl.h"
#include "memfault_self_test_private.h"

#if !defined(MEMFAULT_UNITTEST_SELF_TEST)

typedef enum {
kDeviceInfoField_DeviceSerial = 0,
kDeviceInfoField_SoftwareType,
Expand Down Expand Up @@ -130,8 +133,6 @@ static uint32_t prv_validate_build_id(void) {
}

static void prv_device_info_test_describe(uint32_t results) {
MEMFAULT_SELF_TEST_PRINT_HEADER("Device Info Test");

if (results == 0) {
MEMFAULT_LOG_INFO("All fields valid");
return;
Expand All @@ -144,17 +145,19 @@ static void prv_device_info_test_describe(uint32_t results) {
MEMFAULT_LOG_ERROR("%s invalid", s_device_info_field_names[i]);
}
}
MEMFAULT_LOG_INFO(MEMFAULT_SELF_TEST_END_OUTPUT);
}

uint32_t memfault_self_test_device_info_test(void) {
uint32_t results = 0;
MEMFAULT_SELF_TEST_PRINT_HEADER("Device Info Test");

// Validate the build ID
results |= prv_validate_build_id();
// Valid device info fields
results |= prv_validate_device_info();

prv_device_info_test_describe(results);
MEMFAULT_LOG_INFO(MEMFAULT_SELF_TEST_END_OUTPUT);
return results;
}

Expand Down Expand Up @@ -192,15 +195,24 @@ static const struct {
},
};

void memfault_self_test_component_boot_test(void) {
uint32_t memfault_self_test_component_boot_test(void) {
uint32_t result = 0;
MEMFAULT_SELF_TEST_PRINT_HEADER("Component Boot Test");
MEMFAULT_LOG_INFO("%-16s|%8s|", "Component", "Booted?");
MEMFAULT_LOG_INFO("-----------------------------");
for (size_t i = 0; i < MEMFAULT_ARRAY_SIZE(s_boot_components); i++) {
bool booted = s_boot_components[i].booted();
MEMFAULT_LOG_INFO("%-16s|%8s|", s_boot_components[i].component_name, booted ? "yes" : "no");
if (!booted) {
MEMFAULT_LOG_ERROR("%-16s|%8s|", s_boot_components[i].component_name, "no");
result |= (1 << i);
}
}

if (result == 0) {
MEMFAULT_LOG_INFO("All components booted");
}
MEMFAULT_LOG_INFO(MEMFAULT_SELF_TEST_END_OUTPUT);
return result;
}

void memfault_self_test_data_export_test(void) {
Expand Down Expand Up @@ -271,10 +283,59 @@ uint32_t memfault_self_test_coredump_regions_test(void) {
return result;
}

int memfault_self_test_run(void) {
// Run each test one at a time and return result of all runs OR'd together
memfault_self_test_component_boot_test();
memfault_self_test_data_export_test();
memfault_self_test_coredump_regions_test();
return (memfault_self_test_device_info_test() != 0);
MEMFAULT_NORETURN void memfault_self_test_reboot_reason_test(void) {
// Set a known reason and allow the device to reboot
MEMFAULT_SELF_TEST_PRINT_HEADER("Reboot Reason Test");
MEMFAULT_LOG_INFO("This test will now reboot the device to test reboot reason tracking");
MEMFAULT_LOG_INFO("After the device reboots, please run with reboot_verify argument");
MEMFAULT_LOG_INFO(MEMFAULT_SELF_TEST_END_OUTPUT);
MEMFAULT_REBOOT_MARK_RESET_IMMINENT(kMfltRebootReason_SelfTest);
memfault_platform_reboot();
}

uint32_t memfault_self_test_reboot_reason_test_verify(void) {
// Use explicit initializer to avoid ti-armcl warning
sMfltRebootReason reboot_reason = {
.prior_stored_reason = kMfltRebootReason_Unknown,
.reboot_reg_reason = kMfltRebootReason_Unknown,
};
int result = memfault_reboot_tracking_get_reboot_reason(&reboot_reason);

bool success = (result == 0) && (reboot_reason.prior_stored_reason == kMfltRebootReason_SelfTest);
MEMFAULT_SELF_TEST_PRINT_HEADER("Reboot Reason Test");
if (success) {
MEMFAULT_LOG_INFO("Reboot reason test successful");
} else {
MEMFAULT_LOG_ERROR("Reboot reason test failed:");
MEMFAULT_LOG_ERROR("get_reboot_reason result: %d, "
"prior_stored_reason: 0x%08" PRIx32,
result, (uint32_t)reboot_reason.prior_stored_reason);
}
MEMFAULT_LOG_INFO(MEMFAULT_SELF_TEST_END_OUTPUT);
return success ? 0 : 1;
}

#endif // defined(MEMFAULT_UNITTEST_SELF_TEST)

int memfault_self_test_run(uint32_t run_flags) {
uint32_t result = 0;
if (run_flags & kMemfaultSelfTestFlag_DeviceInfo) {
result |= memfault_self_test_device_info_test();
}
if (run_flags & kMemfaultSelfTestFlag_ComponentBoot) {
result |= memfault_self_test_component_boot_test();
}
if (run_flags & kMemfaultSelfTestFlag_CoredumpRegions) {
result |= memfault_self_test_coredump_regions_test();
}
if (run_flags & kMemfaultSelfTestFlag_DataExport) {
memfault_self_test_data_export_test();
}
if (run_flags & kMemfaultSelfTestFlag_RebootReason) {
memfault_self_test_reboot_reason_test();
}
if (run_flags & kMemfaultSelfTestFlag_RebootReasonVerify) {
result = memfault_self_test_reboot_reason_test_verify();
}
return (result == 0) ? 0 : 1;
}
14 changes: 13 additions & 1 deletion components/core/src/memfault_self_test_private.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
#include <stdbool.h>
#include <stdint.h>

#include "memfault/core/compiler.h"

#ifdef __cplusplus
extern "C" {
#endif
Expand Down Expand Up @@ -36,14 +38,24 @@ bool memfault_self_test_valid_sw_version(unsigned char c);
uint32_t memfault_self_test_device_info_test(void);

//! Runs component boot test
void memfault_self_test_component_boot_test(void);
uint32_t memfault_self_test_component_boot_test(void);

//! Data export test
void memfault_self_test_data_export_test(void);

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

//! Runs reboot reason test
//!
//! This function begins the test by setting a known reboot reason and then rebooting the device
//! After the device reboots, memfault_self_test_reboot_reason_test_verify should be used to verify
//! the test results
MEMFAULT_NORETURN void memfault_self_test_reboot_reason_test(void);

//! Verifies reboot reason test results
uint32_t memfault_self_test_reboot_reason_test_verify(void);

#ifdef __cplusplus
}
#endif
Loading

0 comments on commit 912f34d

Please sign in to comment.