Coder Social home page Coder Social logo

simplicity-studio-example's Introduction

Memfault Simplicity Studio Example

This repo contains a simple example of integrating Memfault with Simplicity Studio, the Gecko SDK (v4.3.1 tested), and Micrium. The application aws written for the EFR32MG24 dev kit. The code was adapted from the example bt_soc_thermometer_micriumos_mock. The application contains the following features:

  • Reboot reason tracking
  • Micrium port integration
  • Configurable RAM or Flash-backed coredump storage
  • Logging
  • Demo CLI to trigger faults, metrics collection, reboots, etc
  • Watchdog coredump integration

The source files contained in the Memfault SDK for the SiLabs port can be found at memfault-firmware-sdk/ports/emlib

Integration Code

The source code containing the integration for this example app is located in <project_root>/memfault. The file, memfault_platform_port.c contains the required functions to integrate this application with the Memfault SDK.

Demo CLI

The demo CLI component uses Simplicity Studio's built-in CLI configuration. The CLI defaults to using the serial port of the dev kit. To print command info type mflt into the console. To add the CLI commands to your project you will need to add a few snippets like the following to your project .slcp file:

# In component section
component:
- instance: [example]
  id: cli
# In template_contribution
template_contribution:
- condition: [cli]
  name: cli_group
  priority: 0
  value: {name: mflt}
- condition: [cli]
  name: cli_group
  priority: 0
  value: {name: test, id: mflt_test_root, group: mflt}
- condition: [cli]
  name: cli_command
  priority: 0
  value: {name: export, group: mflt, handler: memfault_emlib_cli_export, help: Export
      data as base64 chunks}
- condition: [cli]
  name: cli_command
  priority: 0
  value: {name: get_core, group: mflt, handler: memfault_emlib_cli_get_core, help: Get
      current coredump state}
- condition: [cli]
  name: cli_command
  priority: 0
  value: {name: clear_core, group: mflt, handler: memfault_emlib_cli_clear_core, help: Clear
      coredump from storage}
- condition: [cli]
  name: cli_command
  priority: 0
  value: {name: get_device_info, group: mflt, handler: memfault_emlib_cli_get_device_info,
    help: Read device info structure}
- condition: [cli]
  name: cli_command
  priority: 0
  value: {name: assert, group: mflt_test_root, handler: memfault_emlib_cli_assert,
    help: Triggers assert to collect a coredump}
- condition: [cli]
  name: cli_command
  priority: 0
  value: {name: busfault, group: mflt_test_root, handler: memfault_emlib_cli_busfault,
    help: Triggers busfault to collect a coredump}
- condition: [cli]
  name: cli_command
  priority: 0
  value: {name: hang, group: mflt_test_root, handler: memfault_emlib_cli_hang, help: Triggers
      hang to collect a coredump}
- condition: [cli]
  name: cli_command
  priority: 0
  value: {name: hardfault, group: mflt_test_root, handler: memfault_emlib_cli_hardfault,
    help: Triggers hardfault to collect a coredump}
- condition: [cli]
  name: cli_command
  priority: 0
  value: {name: memmanage, group: mflt_test_root, handler: memfault_emlib_cli_memmanage,
    help: Triggers memory management fault to collect a coredump}
- condition: [cli]
  name: cli_command
  priority: 0
  value: {name: usagefault, group: mflt_test_root, handler: memfault_emlib_cli_usagefault,
    help: Triggers usage fault to collect a coredump}
- condition: [cli]
  name: cli_command
  priority: 0
  value: {name: reboot, group: mflt_test_root, handler: memfault_emlib_cli_reboot,
    help: Triggers reboot to test reboot reason tracking}
- condition: [cli]
  name: cli_command
  priority: 0
  value: {name: heartbeat, group: mflt_test_root, handler: memfault_emlib_cli_heartbeat,
    help: Trigger capture of heartbeat metrics}
- condition: [cli]
  name: cli_command
  priority: 0
  value: {name: logs, group: mflt_test_root, handler: memfault_emlib_cli_logs, help: Writes
      logs to internal buffers}
- condition: [cli]
  name: cli_command
  priority: 0
  value: {name: log_capture, group: mflt_test_root, handler: memfault_emlib_cli_log_capture,
    help: Serializes current log buffer contents}
- condition: [cli]
  name: cli_command
  priority: 0
  value: {name: trace, group: mflt_test_root, handler: memfault_emlib_cli_trace, help: Captures
      a trace event}

The implementations for the CLI command handlers are located in memfault-firmware-sdk/ports/emlib/cli_demo_commands.c and memfault-firmware-sdk/components/demo/

Linker File Modifications

The linkerfile autogenerated by Simplicity Studio requires modification to add a region for coredump storage and include the Build ID. This must be added to the linkerfile in your project located at <project_root>/autogen/linkerfile.ld. The following snippets should be added:

 MEMORY
{
    FLASH   (rx)  : ORIGIN = 0x8012000, LENGTH = 0x16A000
    RAM     (rwx) : ORIGIN = 0x20000000, LENGTH = 0x40000
    // Add line to define coredump region
    COREDUMP_STORAGE_FLASH (rx) : ORIGIN = 0x817C000, LENGTH = 8K
}
    .note.gnu.build-id : {
        __start_gnu_build_id_start = .;
        KEEP(*(.note.gnu.build-id))
    } > FLASH

    __MemfaultCoreStorageStart = ORIGIN(COREDUMP_STORAGE_FLASH);
    __MemfaultCoreStorageEnd = ORIGIN(COREDUMP_STORAGE_FLASH) + LENGTH(COREDUMP_STORAGE_FLASH);

NOTE: Simplicity Studio may regenerate this file if components of the project change.

simplicity-studio-example's People

Contributors

ejohnso49 avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.