### Install and Run cysecuretools for Provisioning Source: https://github.com/memfault/memfault-firmware-sdk/blob/master/examples/cypress/CY8CKIT-064S0S2-4343W/README.md Installs the necessary Python tools and uses them to provision the device for secure boot with a specific policy. Ensure you replace placeholder paths with your actual certificate locations. ```bash # install the cysecuretools python tools ❯ pip install --update cysecuretools # change to the directory in the amazon-freertos tree where we run the provisioning ❯ cd vendors/cypress/MTB/psoc6/psoc64tfm/security # for our provisioning, we need to copy the device + root certs to specific locations ❯ mkdir -p certificates ❯ cp /-certificate.pem.crt certificates/device_cert.pem ❯ cp /AmazonRootCA1.pem certificates/rootCA.pem # init and provision the device (use 're-provision-device' on a previously provisioned board) ❯ cysecuretools --target CY8CKIT-064S0S2-4343W init ❯ cysecuretools --policy ./policy/policy_multi_CM0_CM4_jitp.json --target CY8CKIT-064S0S2-4343W provision-device ``` -------------------------------- ### Memfault Demo CLI Example Source: https://github.com/memfault/memfault-firmware-sdk/blob/master/examples/wiced/README.md An example of the Memfault demo CLI output after attaching the debug console. It shows available commands like 'help', 'get_core', 'clear_core', and 'post_core' for interacting with Memfault's coredump functionality. ```bash invoke wiced.console --- Miniterm on /dev/cu.usbserial-14101 115200,8,N,1 --- --- Quit: Ctrl+] | Menu: Ctrl+T | Help: Ctrl+T followed by Ctrl+H --- help Console Commands: ? help [ []] - Print help message or command example. $ - Print return value of last executed command. get_core - Get coredump info clear_core - Clear an existing coredump post_core - Post coredump to Memfault ... etc ... ``` -------------------------------- ### Start GDB Server Source: https://github.com/memfault/memfault-firmware-sdk/blob/master/examples/zephyr/stm32l4_disco/README.md Start the SEGGER JLink GDB Server for flashing and debugging. ```bash JLinkGDBServer -if swd -device STM32L475VG ``` -------------------------------- ### Build the Project Source: https://github.com/memfault/memfault-firmware-sdk/blob/master/examples/cypress/CY8CKIT-064S0S2-4343W/README.md Compiles the project using the make build command within the example directory. This command initiates the build process after all sources and patches have been applied. ```bash make -C \ libraries/3rdparty/memfault-firmware-sdk/examples/cypress/CY8CKIT-064S0S2-4343W/ build ``` -------------------------------- ### Start ST-Util for Flashing Source: https://github.com/memfault/memfault-firmware-sdk/blob/master/examples/qp/README.md Run st-util in a terminal to prepare for flashing the application via GDB. ```bash $ st-util st-util 1.5.1 2019-12-12T15:22:42 INFO common.c: Loading device parameters.... 2019-12-12T15:22:42 INFO common.c: Device connected is: F4 device, id 0x10076413 [...] ``` -------------------------------- ### Install Memfault as ESP Component Source: https://github.com/memfault/memfault-firmware-sdk/blob/master/CHANGELOG.md Add these lines to your esp-idf project's `idf_component.yml` to install the Memfault SDK as an ESP Component. ```yaml dependencies: memfault/memfault-firmware-sdk: version: "1.12.0" ``` -------------------------------- ### Example Log Messages (ESP-IDF) Source: https://github.com/memfault/memfault-firmware-sdk/blob/master/CHANGELOG.md These are examples of noisy warning/error logs that were emitted on boot and have since been eliminated. ```plaintext E (345) task_wdt: esp_task_wdt_status(765): TWDT was never initialized W (362) mflt_sleep: No log backup data W (372) mflt_sleep: No event storage backup data W (372) mflt_sleep: No metrics backup data ``` -------------------------------- ### Debug the FreeRTOS Application Source: https://github.com/memfault/memfault-firmware-sdk/blob/master/examples/freertos/README.md Run this command from the project directory to start the application in a debuggable state. QEMU will wait for a debugger to attach. ```bash make debug ``` -------------------------------- ### Install CppUTest and lcov on Linux Source: https://github.com/memfault/memfault-firmware-sdk/blob/master/tests/unit/README.md Use this command to install the necessary testing libraries on Linux systems. ```bash sudo apt-get install cpputest lcov ``` -------------------------------- ### Install i386 Build Support on Debian Source: https://github.com/memfault/memfault-firmware-sdk/blob/master/tests/ports/zephyr/README.md On Debian-flavored Linux distributions, install i386 build support using apt to ensure compatibility for Zephyr development. ```bash sudo apt install gcc-multilib ``` -------------------------------- ### Initialize Memfault Platform Source: https://github.com/memfault/memfault-firmware-sdk/blob/master/examples/nrf5/README.md Call this function during project initialization after other setup code. It's essential for Memfault SDK to function correctly. ```c // main.c int main(void) { [... other initialization code ...] memfault_platform_boot(); [... application code ...] } ``` -------------------------------- ### Install Memfault Build ID Utility Source: https://github.com/memfault/memfault-firmware-sdk/blob/master/examples/esp32/README.md Install the Memfault build ID utility using pip. This tool is necessary for integrating Memfault with your build process. ```bash pip install mflt-build-id ``` -------------------------------- ### Initialize Memfault Subsystem on Boot Source: https://github.com/memfault/memfault-firmware-sdk/blob/master/ports/mynewt/README.md Call memfault_platform_boot() in your main routine after system initialization to start the Memfault subsystem. ```c #include "memfault/components.h" int main(int argc, char **argv) { // ... memfault_platform_boot(); // ... } ``` -------------------------------- ### Flash Demo App with pyinvoke Source: https://github.com/memfault/memfault-firmware-sdk/blob/master/examples/nrf5/README.md Flash the compiled demo application to the nRF5 device using pyinvoke after starting a GDB server. ```bash # In one terminal start a gdbserver $ invoke nrf.gdbserver # In another terminal flash the binary $ invoke nrf.flash ``` -------------------------------- ### Memfault FOTA Start Function Source: https://github.com/memfault/memfault-firmware-sdk/blob/master/CHANGELOG.md Initiate a Firmware Over-The-Air (FOTA) update with Memfault. Refer to the header file for detailed usage. ```c ports/nrf-connect-sdk/zephyr/include/memfault/nrfconnect_port/fota.h ``` -------------------------------- ### Build and Run Zephyr QEMU Application Source: https://github.com/memfault/memfault-firmware-sdk/blob/master/examples/zephyr/qemu/README.md Commands to build the Zephyr application for the QEMU target and then run it. This will compile the code and start the emulator. ```shell ❯ west build qemu-app ❯ west build --target run ``` -------------------------------- ### Get Help for eclipse_patch.py Script Source: https://github.com/memfault/memfault-firmware-sdk/blob/master/CHANGELOG.md Run this command to display help information for the eclipse_patch.py utility script, which assists in porting the Memfault Firmware SDK to Eclipse projects. ```bash python scripts/eclipse_patch.py --help ``` -------------------------------- ### Memfault OTA Update Check and Perform (ESP-IDF) Source: https://github.com/memfault/memfault-firmware-sdk/blob/master/CHANGELOG.md Example output demonstrating how Memfault prints the OTA URL when an update is available and during the OTA download process on ESP-IDF devices. ```bash esp32> memfault_ota_check I (98125) mflt: Checking for OTA Update Download URL: https://ota-cdn.memfault.com/2950/9757/19036619757?token=0123456789abcdef&expires=1726192800&v=2 I (98775) mflt: Update available! esp32> memfault_ota_perform I (15515) mflt: Checking for OTA Update Download URL: https://ota-cdn.memfault.com/2950/9757/19036619757?token=0123456789abcdef&expires=1726192800&v=2 I (16205) mflt: Starting OTA download ... ``` -------------------------------- ### Get Reboot Reason Demo Command (Zephyr) Source: https://github.com/memfault/memfault-firmware-sdk/blob/master/CHANGELOG.md A demo CLI command to display the current and prior stored reboot reasons. Example output shown. ```bash uart:~$ mflt get_reboot_reason Current Reboot Reason Reg: 0x0008 Prior Stored Reboot Reason: 0x0002 ``` -------------------------------- ### Build the Memfault Demo App Source: https://github.com/memfault/memfault-firmware-sdk/blob/master/examples/qp/README.md Build the demo application using make, specifying the embedded SDK and QP/C directories. ```bash cd $MEMFAULT_SDK_ROOT/examples/qp/apps/memfault_demo_app EMBEDDED_MFLT_SDK_ROOT=$MEMFAULT_SDK_ROOT QPC_DIR=qpc make ``` -------------------------------- ### Clone Amazon-FreeRTOS and Apply Patch Source: https://github.com/memfault/memfault-firmware-sdk/blob/master/examples/cypress/CY8CKIT-064S0S2-4343W/README.md Clones the Amazon-FreeRTOS repository to a specific tag, adds the Memfault SDK, and applies a patch to integrate the example with the FreeRTOS project. This setup is crucial for the project to function correctly. ```bash # clone the amazon-freertos repo at a known-working tag git clone https://github.com/aws/amazon-freertos.git -b 202107.00 ❯ cd amazon-freertos # add the memfault sdk- you can clone it directly, as below; # or add it as a submodule to the freertos repository; # or symlink from another location, per your preference ❯ git clone https://github.com/memfault/memfault-firmware-sdk.git \ libraries/3rdparty/memfault-firmware-sdk/ # apply the patch to integrate this example with amazon-freertos ❯ git apply \ libraries/3rdparty/memfault-firmware-sdk/examples/cypress/CY8CKIT-064S0S2-4343W/amazon-freertos.patch ``` -------------------------------- ### Build Demo App with Make Source: https://github.com/memfault/memfault-firmware-sdk/blob/master/examples/nrf5/README.md Build the Memfault demo application using Make, ensuring the ARM toolchain is in the PATH. ```bash cd /path/to/examples/nrf5/apps/memfault_demo_app/ $ export GNU_INSTALL_ROOT=/path/to/arm_toolchain_dir && make ``` -------------------------------- ### Enable Compact Log Trace Events Source: https://github.com/memfault/memfault-firmware-sdk/blob/master/CHANGELOG.md Enable compact log support for trace events to reduce space and bandwidth by removing format strings at compile time. Refer to the Memfault guide for setup details. ```c #define MEMFAULT_TRACE_EVENT_WITH_LOG(fmt, ...) ``` -------------------------------- ### Configure and Initialize Memfault SDK Source: https://github.com/memfault/memfault-firmware-sdk/blob/master/examples/wiced/README.md Set up the Memfault HTTP client configuration with your API key and initialize the Memfault platform during application startup. Replace '' with your actual Memfault project key. ```c // main.c // Find your key on https://app.memfault.com/ under 'Settings': sMfltHttpClientConfig g_mflt_http_client_config = { .api_key = "", }; void application_start(void) { wiced_init(); memfault_platform_boot(); ... your code ... } ``` -------------------------------- ### Build Demo App with Invoke Source: https://github.com/memfault/memfault-firmware-sdk/blob/master/examples/esp32/README.md Build the Memfault demo application using the pyinvoke command. ```bash invoke esp32.build ``` -------------------------------- ### Build Demo App with Espressif Command Source: https://github.com/memfault/memfault-firmware-sdk/blob/master/examples/esp32/README.md Build the Memfault demo application using the Espressif IDF command-line tool. ```bash cd examples/esp32/apps/memfault_demo_app && idf.py build ``` -------------------------------- ### Install Python Test Requirements Source: https://github.com/memfault/memfault-firmware-sdk/blob/master/tests/unit/README.md Install required Python packages for running tests using pip. ```bash pip install -r requirements.txt ``` -------------------------------- ### Install CppUTest and lcov on OSX Source: https://github.com/memfault/memfault-firmware-sdk/blob/master/tests/unit/README.md Use this command to install the necessary testing libraries on OSX systems. ```bash brew install cpputest && brew install lcov ``` -------------------------------- ### Build Memfault Demo App with WICED make Source: https://github.com/memfault/memfault-firmware-sdk/blob/master/examples/wiced/README.md Alternatively, build the Memfault demo app by navigating to the WICED SDK directory and using the 'make' command with the specific target for the demo app and board. ```bash cd /path/to/WICED-SDK-6.2.0/43xxx_Wi-Fi/ ./make memfault_demo_app-BCM943364WCD1-SDIO-debug ``` -------------------------------- ### Memfault Demo CLI Help Source: https://github.com/memfault/memfault-firmware-sdk/blob/master/examples/zephyr/stm32l4_disco/README.md Displays the available commands for the Memfault demo CLI. Use this to understand the different functionalities offered by the SDK. ```bash $ miniterm.py /dev/cu.usbmodem* 115200 --raw *** Booting Zephyr OS build zephyr-v2.5.0-56-gec0aa8331a65 *** : GNU Build ID: c20cef04e29e3ae7784002c3650d48f3a0b7b07d : S/N: DEMOSERIAL : SW type: zephyr-app : SW version: 1.0.0+c20cef : HW version: disco_l475_iot1 [00:00:00.578,000] mflt: Memfault Demo App! Board disco_l475_iot1 uart:~$ mflt help Subcommands: clear_core :clear coredump collected export :dump chunks collected by Memfault SDK using https://mflt.io/chunk-data-export get_core :check if coredump is stored and present get_device_info :display device information get_latest_release :checks to see if new ota payload is available post_chunks :Post Memfault data to cloud test :commands to verify memfault data collection (https://mflt.io/mcu-test-commands) post_chunks :Post Memfault data to cloud get_latest_release :checks to see if new ota payload is available ``` -------------------------------- ### Install Zephyr Requirements Source: https://github.com/memfault/memfault-firmware-sdk/blob/master/examples/zephyr/stm32l4_disco/README.md Create a virtual environment and install the necessary Python packages for Zephyr development. ```bash python3 -m venv .venv source .venv/bin/activate pip install -r zephyr/scripts/requirements.txt ``` -------------------------------- ### Configure Memfault Project Key Source: https://github.com/memfault/memfault-firmware-sdk/blob/master/examples/wiced/README.md Paste your Memfault Project Key into the 'apps/memfault_demo_app/memfault_demo_app.c' file to enable communication with Memfault's web services. Replace '' with your actual key. ```c #define MEMFAULT_PROJECT_KEY "" ``` -------------------------------- ### Set HTTP Fragment Size in nRF9160 Example Source: https://github.com/memfault/memfault-firmware-sdk/blob/master/CHANGELOG.md In the Memfault SDK nRF9160 example app, set the Kconfig flag `CONFIG_DOWNLOAD_CLIENT_HTTP_FRAG_SIZE_1024=y` in `prj.conf` for explicit configuration. ```text CONFIG_DOWNLOAD_CLIENT_HTTP_FRAG_SIZE_1024=y ``` -------------------------------- ### Build and Flash Memfault Demo App Source: https://github.com/memfault/memfault-firmware-sdk/blob/master/examples/nrf-connect-sdk/nrf5/README.md Commands to initialize, update, build, and flash the Memfault demo application to an nRF5340-DK. Ensure you replace 'YOUR_PROJECT_KEY' with your actual Memfault project key. ```bash ❯ west init --local memfault_demo_app ❯ west update ❯ west build --sysbuild --pristine=always --board nrf5340dk/nrf5340/cpuapp memfault_demo_app -- \ -DCONFIG_MEMFAULT_NCS_PROJECT_KEY="YOUR_PROJECT_KEY" ❯ west flash ``` -------------------------------- ### Build Demo App with pyinvoke Source: https://github.com/memfault/memfault-firmware-sdk/blob/master/examples/nrf5/README.md Build the Memfault demo application using the pyinvoke tool. ```bash $ invoke nrf.build ``` -------------------------------- ### Build and Flash Demo App with Invoke Source: https://github.com/memfault/memfault-firmware-sdk/blob/master/examples/mbed/README.md Compiles and flashes the demo app to the target device. Ensure the correct USB port is used for flashing. ```bash $ invoke mbed.build --flash ``` -------------------------------- ### Add Memfault Build ID to ESP32 Example App Source: https://github.com/memfault/memfault-firmware-sdk/blob/master/CHANGELOG.md This snippet shows how to add the Memfault Build ID to the ESP32 example app's CMakeLists.txt for reference. ```cmake set(MEMFAULT_BUILD_ID "${GIT_HASH}") set(MEMFAULT_BUILD_ID_STR "${GIT_HASH}") ``` -------------------------------- ### Navigate to Demo App Directory Source: https://github.com/memfault/memfault-firmware-sdk/blob/master/examples/qp/README.md Change to the Memfault demo application directory within the SDK. ```bash cd $MEMFAULT_SDK_ROOT/examples/qp/apps/memfault_demo_app ``` -------------------------------- ### Enable MPU Region Analysis in FreeRTOS QEMU Example Source: https://github.com/memfault/memfault-firmware-sdk/blob/master/CHANGELOG.md Enable the MPU (Memory Protection Unit) in the FreeRTOS QEMU example by setting MEMFAULT_COLLECT_MPU_STATE to 1 in memfault_platform_config.h. This allows Memfault to analyze MPU configurations. ```c #define MEMFAULT_COLLECT_MPU_STATE 1 ``` -------------------------------- ### Build Memfault Demo App with pyinvoke Source: https://github.com/memfault/memfault-firmware-sdk/blob/master/examples/wiced/README.md Navigate to the memfault_sdk directory and use the 'invoke wiced.build' command to build the Memfault demo application for the WICED SDK. ```bash cd memfault_sdk invoke wiced.build ``` -------------------------------- ### Build Memfault Demo App Source: https://github.com/memfault/memfault-firmware-sdk/blob/master/examples/zephyr/stm32l4_disco/README.md Build the Memfault demo application for the STM32L4 Discovery kit using west. ```bash cd $MEMFAULT_SDK/examples/zephyr/ west build -b disco_l475_iot1 apps/memfault_demo_app ``` -------------------------------- ### Update nRF5 example app file paths Source: https://github.com/memfault/memfault-firmware-sdk/blob/master/CHANGELOG.md When migrating projects, update the file paths for nRF5 example app files to reflect the new directory structure. This ensures the build system can locate the necessary platform implementation files. ```diff - ${MEMFAULT_FIRMWARE_SDK}/nrf5/libraries/memfault/platform_reference_impl/memfault_platform_reboot_tracking.c + ${MEMFAULT_FIRMWARE_SDK}/ports/nrf5_sdk/resetreas_reboot_tracking.c - ${MEMFAULT_FIRMWARE_SDK}/nrf5/libraries/memfault/platform_reference_impl/memfault_platform_coredump.c + ${MEMFAULT_FIRMWARE_SDK}/ports/nrf5_sdk/memfault_nrf5_coredump.c ``` -------------------------------- ### Wrap esp_startup_start_app for Boot Time Metrics Source: https://github.com/memfault/memfault-firmware-sdk/blob/master/ports/esp_idf/memfault/CMakeLists.txt Conditionally wraps `esp_startup_start_app` when `CONFIG_MEMFAULT_METRICS_BOOT_TIME` is enabled. This allows Memfault to capture and report application boot time metrics. ```cmake if(CONFIG_MEMFAULT_METRICS_BOOT_TIME) target_link_libraries(${this_component} INTERFACE "-Wl,--wrap=esp_startup_start_app") endif() ``` -------------------------------- ### Memfault Platform Sanitize Address Range Template Source: https://github.com/memfault/memfault-firmware-sdk/blob/master/CHANGELOG.md This is a template example for memfault_platform_sanitize_address_range() which has been fixed. ```c void memfault_platform_sanitize_address_range(uintptr_t *begin, uintptr_t *end); ``` -------------------------------- ### GDB Backtrace after Assert Source: https://github.com/memfault/memfault-firmware-sdk/blob/master/examples/stm32/stm32h743i/README.md Example GDB backtrace showing the call stack when memfault_platform_halt_if_debugging is triggered. ```gdb memfault_platform_halt_if_debugging () at ./memfault-firmware-sdk/examples/stm32/stm32h743i/platform_reference_impl/memfault_platform_core.c:17 17 __asm("bkpt"); (gdb) bt #0 memfault_platform_halt_if_debugging () at ./memfault-firmware-sdk/examples/stm32/stm32h743i/platform_reference_impl/memfault_platform_core.c:17 #1 0x08009af2 in memfault_fault_handling_assert (pc=, lr=lr@entry=0x800034d , extra=extra@entry=0) at ./memfault-firmware-sdk/components/panics/src/memfault_fault_handling_arm.c:162 #2 0x0800967e in main () at main.c:76 ``` -------------------------------- ### Flash Demo App with Make and GDB Source: https://github.com/memfault/memfault-firmware-sdk/blob/master/examples/nrf5/README.md Flash the demo application using Make and GDB, including softdevice flashing and loading the executable. ```bash # In one terminal start a gdb server JLinkGDBServer -if swd -device nRF52840_xxAA -speed auto -port 2331 # In another terminal flash the binary $ cd /path/to/examples/nrf5/apps/memfault_demo_app/ $ make flash_softdevice $ /path/to/arm-none-eabi-gdb[-py] --eval-command="target remote localhost:2331" --ex="mon reset" --ex="load" --ex="mon reset" --se=/path/to/examples/nrf5/apps/memfault_demo_app/build/memfault_demo_app_nrf52840_s140.out ``` -------------------------------- ### Update Path from platforms/ to examples/ Source: https://github.com/memfault/memfault-firmware-sdk/blob/master/CHANGELOG.md This diff shows the change in path from 'platforms' to 'examples' for project integrations. ```diff - + ${MEMFAULT_FIRMWARE_SDK}/examples/ ``` -------------------------------- ### Build Application using Make Source: https://github.com/memfault/memfault-firmware-sdk/blob/master/examples/cypress/CY8CKIT-064S0S2-4343W/README.md Build the application directly from the project's shell directory using the make build command. ```bash make build ``` -------------------------------- ### Run Tests with Invoke Source: https://github.com/memfault/memfault-firmware-sdk/blob/master/tests/unit/README.md Execute all unit tests using the `invoke` command if Python packages are installed. ```bash inv test ``` -------------------------------- ### Build Zephyr Application Source: https://github.com/memfault/memfault-firmware-sdk/blob/master/examples/zephyr/nucleo_wba55cg/README.md Builds the Memfault demo application for the nucleo_wba55cg board using the west tool. ```bash west build --board nucleo_wba55cg memfault_demo_app ``` -------------------------------- ### Get Event Storage Usage Source: https://github.com/memfault/memfault-firmware-sdk/blob/master/CHANGELOG.md Query the number of bytes used in the event storage module with memfault_event_storage_bytes_used(). ```c memfault_event_storage_bytes_used(); ``` -------------------------------- ### Connecting to WiFi Source: https://github.com/memfault/memfault-firmware-sdk/blob/master/examples/zephyr/stm32l4_disco/README.md Demonstrates the command to connect the device to a WiFi network. This is a prerequisite for posting Memfault data over HTTP. ```bash uart:~$ wifi connect 0 Connection requested Connected uart:~$ ``` -------------------------------- ### Attach GDB to the Debugger Source: https://github.com/memfault/memfault-firmware-sdk/blob/master/examples/freertos/README.md From a separate terminal, run this command to attach GDB to the application started with 'make debug'. ```bash make gdb ``` -------------------------------- ### Initialize Memfault SDK Components Source: https://context7.com/memfault/memfault-firmware-sdk/llms.txt Call these initialization functions during system startup in the specified order to connect all SDK components to the shared event storage ring buffer. Ensure platform implementation of device identity and allocation of a NOINIT region for reboot tracking. ```c #include "memfault/components.h" #include "memfault/core/platform/device_info.h" // ── platform/memfault_platform_port.c ───────────────────────────────────── // 1. Platform must implement device identity void memfault_platform_get_device_info(sMemfaultDeviceInfo *info) { *info = (sMemfaultDeviceInfo){ .device_serial = "SN-AABBCCDD", // unique per device .software_type = "main-app", .software_version = "1.4.2", .hardware_version = "evt3", }; } // 2. Allocate a NOINIT region so reboot tracking survives warm resets #include "memfault/core/compiler.h" MEMFAULT_PUT_IN_SECTION(".mflt_reboot_info") static uint8_t s_reboot_tracking[MEMFAULT_REBOOT_TRACKING_REGION_SIZE]; // ── application main ────────────────────────────────────────────────────── void app_boot(void) { // a) Reboot tracking — must be first; reads NOINIT region sResetBootupInfo reset_info = { .reset_reason_reg = read_hardware_reset_register(), // MCU-specific .reset_reason = kMfltRebootReason_Unknown, }; memfault_reboot_tracking_boot(s_reboot_tracking, &reset_info); // b) Event storage — shared ring buffer for metrics, trace events, reboots static uint8_t s_event_storage[512]; const sMemfaultEventStorageImpl *evt_storage = memfault_events_storage_boot(s_event_storage, sizeof(s_event_storage)); // c) Trace event module memfault_trace_event_boot(evt_storage); // d) Collect reboot reason from the reboot tracking module memfault_reboot_tracking_collect_reset_info(evt_storage); // e) Metrics / heartbeat (starts the periodic timer) sMemfaultMetricBootInfo metric_boot = { .unexpected_reboot_count = memfault_reboot_tracking_get_crash_count(), }; memfault_metrics_boot(evt_storage, &metric_boot); // f) RAM log buffer — captured in coredump and sent to cloud on demand static uint8_t s_log_buffer[512]; memfault_log_boot(s_log_buffer, sizeof(s_log_buffer)); // g) Configure HTTP client with your project key (from app.memfault.com) g_mflt_http_client_config.api_key = "YOUR_PROJECT_KEY"; } ``` -------------------------------- ### Perform OTA Update Source: https://github.com/memfault/memfault-firmware-sdk/blob/master/examples/esp32/README.md Initiate the OTA update process. The device will download the new release, install it, and reboot. ```bash esp32> memfault_ota_perform D (1455118) mflt: Checking for OTA Update D (1456618) mflt: OTA Update Available I (1456628) mflt: Starting OTA download ... I (1457798) esp_https_ota: Starting OTA... I (1457798) esp_https_ota: Writing to partition subtype 16 at offset 0x1e0000 I (1476958) esp_https_ota: Connection closed ... I (1477758) mflt: OTA Update Complete, Rebooting System ... Rebooting... ... ``` -------------------------------- ### Add Demo Component Source Files Source: https://github.com/memfault/memfault-firmware-sdk/blob/master/CHANGELOG.md New source files need to be added to the demo component if not using the provided build system helpers. ```bash Add: $(MEMFAULT_SDK_ROOT)/components/demo/src/memfault_demo_core.c Add: $(MEMFAULT_SDK_ROOT)/components/demo/src/http/memfault_demo_http.c ``` -------------------------------- ### Build the FreeRTOS Application Source: https://github.com/memfault/memfault-firmware-sdk/blob/master/examples/freertos/README.md Run this command from the project directory to build the application. ```bash make ``` -------------------------------- ### Memfault Port Templates Directory Source: https://github.com/memfault/memfault-firmware-sdk/blob/master/CHANGELOG.md A directory containing templates that can be copied into a project to serve as a starting point for a Memfault port. ```c ports/templates ``` -------------------------------- ### Connect to Demo App Console Source: https://github.com/memfault/memfault-firmware-sdk/blob/master/examples/qp/README.md Connect to the demo application's console using miniterm.py to interact with the Memfault demo CLI. ```bash $ miniterm.py --raw /dev/cu.usbserial* 115200 --- Miniterm on /dev/cu.usbserial-1420 115200,8,N,1 --- --- Quit: Ctrl+] | Menu: Ctrl+T | Help: Ctrl+T followed by Ctrl+H --- Memfault QP demo app started... mflt> help get_core: Get coredump info clear_core: Clear an existing coredump export: Export base64-encoded chunks. To upload data see https://mflt.io/chunk-data-export get_device_info: Get device info help: Lists all commands ``` -------------------------------- ### Flash .elf using GDB Source: https://github.com/memfault/memfault-firmware-sdk/blob/master/examples/qp/README.md Use arm-none-eabi-gdb to flash the compiled .elf file to the target board after starting st-util. ```bash $ arm-none-eabi-gdb --eval-command="target remote localhost:4242" --ex="mon reset" --ex="load" --ex="mon reset" \ --se=$MEMFAULT_SDK_ROOT/examples/qp/apps/memfault_demo_app/build/memfault_demo_app.elf --batch Generating /path/to/memfault-sdk/examples/qp/apps/memfault_demo_app/build/memfault_demo_app.elf ``` -------------------------------- ### Get Device Info Source: https://github.com/memfault/memfault-firmware-sdk/blob/master/examples/wiced/README.md Request device information from the debug console. This is useful for verifying device configuration and serial number. ```bash > get_device_info S/N: 00A0507510F0 SW type: wiced-main SW version: 1.0.0 HW version: wiced-proto ``` -------------------------------- ### Flash Memfault Demo App with WICED make Source: https://github.com/memfault/memfault-firmware-sdk/blob/master/examples/wiced/README.md Flash the Memfault demo app using the WICED SDK's make system. This involves navigating to the SDK directory and executing a series of make commands to download and run the application. Ensure to cycle power after flashing to clear the DEBUGEN bit. ```bash cd /path/to/WICED-SDK-6.2.0/43xxx_Wi-Fi/ ./make memfault_demo_app-BCM943364WCD1-SDIO-debug download download_apps run ``` -------------------------------- ### Access Demo App Console with Invoke Source: https://github.com/memfault/memfault-firmware-sdk/blob/master/examples/mbed/README.md Opens a serial console to interact with the demo app. Press enter to see the 'mflt>' prompt and use 'help' for available commands. ```bash $ invoke mbed.console ``` -------------------------------- ### Get Device Info Source: https://github.com/memfault/memfault-firmware-sdk/blob/master/examples/nrf5/README.md Retrieve device information from the debug console. This is useful for sanity checks and verifying device configuration. ```bash > get_device_info app: MFLT: S/N: C9DB1227DEAE6A52 app: MFLT: SW type: nrf-main app: MFLT: SW version: 1.0.0 app: MFLT: HW version: nrf-proto ```