Coder Social home page Coder Social logo

zephyr-esp32-example's Introduction

Memfault Zephyr + ESP32 Example

This sample app is based on the Zephyr samples/net/wifi example. It demonstrates a Zephyr + ESP32 integration with the Memfault SDK. It has been tested on the following boards:

  • esp32c3_devkitm (default board)
  • esp32s3_devkitm

Getting Started

The Memfault Zephyr integration guide is an excellent reference, and documents how the Memfault SDK was added to the base example app:

https://docs.memfault.com/docs/mcu/zephyr-guide

To try out this example app:

  1. Set up the Zephyr prerequisites: https://docs.zephyrproject.org/latest/develop/getting_started/index.html

  2. Create a zephyr workspace and set it up with this project:

    mkdir zephyr-workspace
    cd zephyr-workspace
    west init -m https://github.com/memfault/zephyr-esp32-example
    west update
  3. Build the example app:

    west build zephyr-esp32-example --sysbuild

    --sysbuild will build the MCUboot image as well, which will also get flashed in the following step. To run sysbuild by default, you can configure your workspace with west config --local build.sysbuild True.

  4. Flash the example app:

     west flash
  5. Open a serial console and interact with the sample app shell. For example using PySerial:

    # select the correct serial port for your system
    pyserial-miniterm --raw /dev/serial/by-id/usb-Silicon_Labs_CP2102N_USB_to_UART_Bridge_Controller_1cd857b4d5a0eb11bf35cdacdf749906-if00-port0 115200
    
    uart:~$ mflt get_device_info
    [00:09:21.911,000] <inf> mflt: S/N: DEMOSERIAL
    [00:09:21.911,000] <inf> mflt: SW type: zephyr-app
    [00:09:21.911,000] <inf> mflt: SW version: 0.0.1727a85c
    [00:09:21.911,000] <inf> mflt: HW version: esp32c3_devkitm
    
    # connect wifi
    uart:~$ wifi connect <ssid> <pw>
    
    # test memfault export over uart
    uart:~$ mflt export
    MC:CAKnAgIDAQpqemVwaHlyLWFwcAltMS4wLjArZDU5MmRhOAZvZXNwMzJjM19kZXZraXRtC0Z1sxH2/usEogEABQAISg==:

Testing OTA

The payload to upload to Memfault is:

build/zephyr-esp32-example/zephyr/zephyr.signed.confirmed.bin

This file is set as "confirmed", so it won't revert after 1 boot cycle (not safe against bootloops!). See the Zephyr documentation for details.

Follow the normal Memfault OTA workflow:

  1. build and flash an image with a version like 0.0.1 (see the VERSION file for setting an application version).
  2. rebuild with a newer version, 0.0.2
  3. upload the zephyr.signed.confirmed.bin file to a Memfault Release named 0.0.2.
  4. deploy the 0.0.2 release to the cohort with the device (default unless changed)
  5. on the device shell, connect wifi with wifi connect <ssid> <pw>, and trigger the OTA with mflt get_latest_release
  6. when the device reboots, confirm the new version is set with mflt get_device_info

Note

If this error occurs when applying the new image:

[00:10:07.255,000] <dbg> mflt: memfault_platform_log: Error requesting upgrade, rv=-14
[00:10:07.260,000] <err> mflt: Error upgrading firmware, rv=-1

It may be necessary to run mcuboot erase 2 one time before running the test, to wipe the secondary slot so it's ready to receive the new image.

zephyr-esp32-example's People

Contributors

gminn avatar noahp 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.