From 1b88521c5f736a4acd57e7e75e859a69deb9d845 Mon Sep 17 00:00:00 2001 From: Memfault Inc Date: Mon, 9 Aug 2021 22:26:34 -0400 Subject: [PATCH] Memfault Firmware SDK 0.24.1 (Build 290406) --- CHANGES.md | 50 +++++++++++++++---- VERSION | 4 +- .../demo/src/memfault_demo_shell_commands.c | 8 +++ components/include/memfault/demo/cli.h | 4 ++ .../nrf9160/memfault_demo_app/README.md | 5 +- ports/zephyr/Kconfig | 6 +-- ports/zephyr/common/memfault_logging.c | 10 +++- .../common/memfault_software_watchdog.c | 2 +- ports/zephyr/ncs/Kconfig | 4 +- 9 files changed, 72 insertions(+), 21 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 79ee7bc75..ef9811cdc 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,25 +1,55 @@ +### Changes between Memfault SDK 0.24.1 and SDK 0.24.0 - August 9, 2021 + +#### :chart_with_upwards_trend: Improvements + +- Applied suggestions from @elliot-wdtl for the Zephyr ports + ([#15](https://github.com/memfault/memfault-firmware-sdk/pull/15)): + - Updated software watchdog port to make use of `MEMFAULT_SOFTWARE_WATCHDOG` + macro +- Applied suggestions from @ioannisg & @mbolivar-nordic in + ([#14](https://github.com/memfault/memfault-firmware-sdk/pull/14)) to change + the KConfig options used to select `CONFIG_MEMFAULT_HTTP_ENABLE` & + `CONFIG_MEMFAULT_ROOT_CERT_STORAGE_NRF9160_MODEM` & + `CONFIG_MEMFAULT_NRF_CONNECT_SDK` when using nRF91 targets. + +#### :house: Internal + +- Added `export` command to the demo cli to better mirror + [our suggested integration test commands](https://mflt.io/mcu-test-commands) + +#### :boom: Breaking Changes + +- If you are were using a custom nRF91 based board config (i.e neither + `BOARD_NRF9160DK_NRF9160NS` or `BOARD_THINGY91_NRF9160NS`), the following + KConfig options will now be enabled by default. The following can be added to + your `prj.conf` to restore the original behavior: + - `CONFIG_MEMFAULT_HTTP_ENABLE=n` + - `CONFIG_MEMFAULT_NRF_CONNECT_SDK=n` + - `CONFIG_MEMFAULT_ROOT_CERT_STORAGE_TLS_CREDENTIAL_STORAGE=y` + ### Changes between Memfault SDK 0.24.0 and SDK 0.23.0 - July 27, 2021 #### :chart_with_upwards_trend: Improvements -- Added "compact log" support to trace events. When enabled, the format string will be removed at - compile time from calls to `MEMFAULT_TRACE_EVENT_WITH_LOG` and an integer along with arguments - will be serialized instead. The actual string will recovered and formatted when it arrives in the - Memfault cloud. This leads to a massive reduction in space & bandwidth needed to send trace +- Added "compact log" support to trace events. When enabled, the format string + will be removed at compile time from calls to `MEMFAULT_TRACE_EVENT_WITH_LOG` + and an integer along with arguments will be serialized instead. The actual + string will recovered and formatted when it arrives in the Memfault cloud. + This leads to a massive reduction in space & bandwidth needed to send trace events. For more details about how to set up, [check out this guide!](https://mflt.io/compact-logs) - Fixed a `-Wshadow` compiler error that would arise in -[`memfault_coredump_regions_armv7.c`](components/panics/src/memfault_coredump_regions_armv7.c) when -`MEMFAULT_COLLECT_MPU_STATE` was enabled + [`memfault_coredump_regions_armv7.c`](components/panics/src/memfault_coredump_regions_armv7.c) + when `MEMFAULT_COLLECT_MPU_STATE` was enabled - Updated debug print utility in - [`memfault_coredump_storage_debug.c`](components/panics/src/memfault_coredump_storage_debug.c) to - guard against potentially printing an uninitialized string. + [`memfault_coredump_storage_debug.c`](components/panics/src/memfault_coredump_storage_debug.c) + to guard against potentially printing an uninitialized string. - Removed unnecessary extra argument from `MEMFAULT_SOFTWARE_WATCHDOG` #### :boom: Breaking Changes -- If you were already using `MEMFAULT_SOFTWARE_WATCHDOG`, you will need to update your call site -invocations to remove the argument being passed. i.e +- If you were already using `MEMFAULT_SOFTWARE_WATCHDOG`, you will need to + update your call site invocations to remove the argument being passed. i.e ```diff - MEMFAULT_SOFTWARE_WATCHDOG(0); diff --git a/VERSION b/VERSION index 051cd5814..7a99753ed 100644 --- a/VERSION +++ b/VERSION @@ -1,2 +1,2 @@ -BUILD ID: 283912 -GIT COMMIT: 7f6c0b54c +BUILD ID: 290406 +GIT COMMIT: e752751b3 diff --git a/components/demo/src/memfault_demo_shell_commands.c b/components/demo/src/memfault_demo_shell_commands.c index a421acf14..8452f3ecb 100644 --- a/components/demo/src/memfault_demo_shell_commands.c +++ b/components/demo/src/memfault_demo_shell_commands.c @@ -14,6 +14,7 @@ #include "memfault/core/math.h" #include "memfault/demo/cli.h" #include "memfault/core/compiler.h" +#include "memfault/core/data_export.h" static int prv_panics_component_required(void) { MEMFAULT_LOG_RAW("Disabled. panics component integration required"); @@ -35,6 +36,12 @@ int memfault_demo_cli_cmd_crash(MEMFAULT_UNUSED int argc, MEMFAULT_UNUSED char * return prv_panics_component_required(); } +int memfault_demo_cli_cmd_export(MEMFAULT_UNUSED int argc, MEMFAULT_UNUSED char *argv[]) { + memfault_data_export_dump_chunks(); + + return 0; +} + static const sMemfaultShellCommand s_memfault_shell_commands[] = { {"get_core", memfault_demo_cli_cmd_get_core, "Get coredump info"}, {"clear_core", memfault_demo_cli_cmd_clear_core, "Clear an existing coredump"}, @@ -44,6 +51,7 @@ static const sMemfaultShellCommand s_memfault_shell_commands[] = { {"trace", memfault_demo_cli_cmd_trace_event_capture, "Capture an example trace event"}, {"get_device_info", memfault_demo_cli_cmd_get_device_info, "Get device info"}, {"reboot", memfault_demo_cli_cmd_system_reboot, "Reboot system and tracks it with a trace event"}, + {"export", memfault_demo_cli_cmd_export, "Export base64-encoded chunks. To upload data see https://mflt.io/chunk-data-export"}, {"help", memfault_shell_help_handler, "Lists all commands"}, }; diff --git a/components/include/memfault/demo/cli.h b/components/include/memfault/demo/cli.h index 97e94f08c..feeb625c3 100644 --- a/components/include/memfault/demo/cli.h +++ b/components/include/memfault/demo/cli.h @@ -76,6 +76,10 @@ int memfault_demo_cli_cmd_system_reboot(int argc, char *argv[]); int memfault_demo_drain_chunk_data(int argc, char *argv[]); void user_transport_send_chunk_data(void *chunk_data, size_t chunk_data_len); +//! Output base64 encoded chunks. Chunks can be uploaded via the Memfault CLI or +//! manually via the Chunks Debug in the UI. +int memfault_demo_cli_cmd_export(int argc, char *argv[]); + #ifdef __cplusplus } #endif diff --git a/examples/nrf-connect-sdk/nrf9160/memfault_demo_app/README.md b/examples/nrf-connect-sdk/nrf9160/memfault_demo_app/README.md index 82475f6cc..67ad4c54d 100644 --- a/examples/nrf-connect-sdk/nrf9160/memfault_demo_app/README.md +++ b/examples/nrf-connect-sdk/nrf9160/memfault_demo_app/README.md @@ -19,11 +19,14 @@ targetting the nRF52 PDK would look like: ```bash $ west init -l memfault_demo_app $ west update -$ west build -b nrf9160dk_nrf9160ns memfault_demo_app +$ west build -b nrf9160dk_nrf9160_ns memfault_demo_app ... [181/181] Linking C executable zephyr/zephyr.elf ``` +Note that you will need to use `nrf9160dk_nrf9160ns` instead on +versions of NCS based on Zephyr 2.6 and earlier. + ## Testing the Integration Commands to test the integration are exposed under the `mflt` submenu in the CLI diff --git a/ports/zephyr/Kconfig b/ports/zephyr/Kconfig index 7abde6d49..6f2d0204c 100644 --- a/ports/zephyr/Kconfig +++ b/ports/zephyr/Kconfig @@ -76,7 +76,7 @@ config MEMFAULT_SHELL config MEMFAULT_HTTP_ENABLE bool "Enables support for using Memfault's HTTP APIs" - default y if BOARD_NRF9160DK_NRF9160NS || BOARD_THINGY91_NRF9160NS + default y if SOC_SERIES_NRF91X && TRUSTED_EXECUTION_NONSECURE help Enables support for querying the Memfault API for OTA updates and posting Memfault chunks @@ -103,7 +103,7 @@ endif # MEMFAULT_LOGGING_ENABLE choice bool "Implementation used to store Memfault Root certificates" - default MEMFAULT_ROOT_CERT_STORAGE_NRF9160_MODEM if BOARD_NRF9160DK_NRF9160NS || BOARD_THINGY91_NRF9160NS + default MEMFAULT_ROOT_CERT_STORAGE_NRF9160_MODEM if SOC_SERIES_NRF91X && TRUSTED_EXECUTION_NONSECURE default MEMFAULT_ROOT_CERT_STORAGE_TLS_CREDENTIAL_STORAGE config MEMFAULT_ROOT_CERT_STORAGE_NRF9160_MODEM @@ -260,4 +260,4 @@ config MEMFAULT_SOFTWARE_WATCHDOG_TIMEOUT_SECS rsource "ncs/Kconfig" -endif # MEMFAULT \ No newline at end of file +endif # MEMFAULT diff --git a/ports/zephyr/common/memfault_logging.c b/ports/zephyr/common/memfault_logging.c index b912495f3..7833dbbb1 100644 --- a/ports/zephyr/common/memfault_logging.c +++ b/ports/zephyr/common/memfault_logging.c @@ -40,7 +40,13 @@ static void prv_log_put_sync_string(const struct log_backend *const backend, struct log_msg_ids src_level, uint32_t timestamp, const char *fmt, va_list ap); static void prv_log_panic(struct log_backend const *const backend); -static void prv_log_init(void); + + +// The function signature for struct log_backend_api init changed between Zephyr 2.5 and Zephyr 2.6 +// and we don't use any of the parameters so we leave the parameter list empty to mitigate +// -Wincompatible-pointer-types between versions +static void prv_log_init(); + static void prv_log_dropped(const struct log_backend *const backend, uint32_t cnt); const struct log_backend_api log_backend_mflt_api = { .put = IS_ENABLED(CONFIG_LOG_IMMEDIATE) ? NULL : prv_log_put, @@ -115,7 +121,7 @@ static void prv_log_panic(struct log_backend const *const backend) { } // Zephyr will call our init function so we can establish some storage. -static void prv_log_init(void) { +static void prv_log_init() { // static RAM storage where logs will be stored. Storage can be any size // you want but you will want it to be able to hold at least a couple logs. static uint8_t s_mflt_log_buf_storage[CONFIG_MEMFAULT_LOGGING_RAM_SIZE]; diff --git a/ports/zephyr/common/memfault_software_watchdog.c b/ports/zephyr/common/memfault_software_watchdog.c index 4117be2e3..7a0b35fbb 100644 --- a/ports/zephyr/common/memfault_software_watchdog.c +++ b/ports/zephyr/common/memfault_software_watchdog.c @@ -14,7 +14,7 @@ #include static void prv_software_watchdog_timeout(struct k_timer *dummy) { - MEMFAULT_ASSERT(0); + MEMFAULT_SOFTWARE_WATCHDOG(); } K_TIMER_DEFINE(s_watchdog_timer, prv_software_watchdog_timeout, NULL); diff --git a/ports/zephyr/ncs/Kconfig b/ports/zephyr/ncs/Kconfig index 7df73e852..46a70445e 100644 --- a/ports/zephyr/ncs/Kconfig +++ b/ports/zephyr/ncs/Kconfig @@ -1,6 +1,6 @@ config MEMFAULT_NRF_CONNECT_SDK bool "nRF Connect SDK extensions" - default y if BOARD_NRF9160DK_NRF9160NS || BOARD_THINGY91_NRF9160NS + default y if SOC_SERIES_NRF91X && TRUSTED_EXECUTION_NONSECURE select MEMFAULT_REBOOT_REASON_GET_CUSTOM if MEMFAULT_NRF_CONNECT_SDK @@ -44,4 +44,4 @@ config MEMFAULT_FOTA_DOWNLOAD_CALLBACK_CUSTOM endif # MEMFAULT_FOTA -endif # MEMFAULT_NRF_CONNECT_SDK \ No newline at end of file +endif # MEMFAULT_NRF_CONNECT_SDK