Skip to content

Commit ae5b690

Browse files
author
Memfault Inc
committed
Memfault Firmware SDK 0.31.3 (Build 474047)
1 parent 73fab86 commit ae5b690

File tree

13 files changed

+155
-26
lines changed

13 files changed

+155
-26
lines changed

.circleci/Dockerfile

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
FROM ubuntu:22.04
2+
3+
# Some details based on this Dockerfile:
4+
# https://github.com/CircleCI-Public/cimg-base/blob/2b2cc9584c5ce2256d0781106218ff4158c790a0/22.04/Dockerfile
5+
6+
SHELL ["/bin/bash", "-exo", "pipefail", "-c"]
7+
8+
ENV DEBIAN_FRONTEND=noninteractive \
9+
TERM=dumb \
10+
PAGER=cat
11+
12+
13+
ARG MEMFAULT_SDK_APT_DEPS="\
14+
build-essential \
15+
cpputest \
16+
git \
17+
python3.10 \
18+
python3.10-venv\
19+
"
20+
21+
# Run commands and tests as circleci user
22+
RUN echo 'APT::Get::Assume-Yes "true";' > /etc/apt/apt.conf.d/90circleci && \
23+
echo 'DPkg::Options "--force-confnew";' >> /etc/apt/apt.conf.d/90circleci && \
24+
apt-get update && apt-get install -y \
25+
locales \
26+
sudo \
27+
wget \
28+
${MEMFAULT_SDK_APT_DEPS} \
29+
&& \
30+
locale-gen en_US.UTF-8 && \
31+
rm -rf /var/lib/apt/lists/* && \
32+
# create the circlci user
33+
useradd --uid=3434 --user-group --create-home circleci && \
34+
echo 'circleci ALL=NOPASSWD: ALL' >> /etc/sudoers.d/50-circleci && \
35+
echo 'Defaults env_keep += "DEBIAN_FRONTEND"' >> /etc/sudoers.d/env_keep && \
36+
sudo -u circleci mkdir /home/circleci/project && \
37+
sudo -u circleci mkdir /home/circleci/bin
38+
39+
ENV PATH=/home/circleci/bin:/home/circleci/.local/bin:$PATH \
40+
LANG=en_US.UTF-8 \
41+
LANGUAGE=en_US:en \
42+
LC_ALL=en_US.UTF-8
43+
44+
USER circleci
45+
46+
# Match the default CircleCI working directory
47+
WORKDIR /home/circleci/project
48+
49+
# Create the virtualenv
50+
RUN python3 -m venv ~/venv
51+
52+
# Install lcov and add to PATH
53+
ARG LCOV_VERSION=1.14
54+
ARG LCOV_SHA256SUM=14995699187440e0ae4da57fe3a64adc0a3c5cf14feab971f8db38fb7d8f071a
55+
RUN \
56+
cd ~ && \
57+
wget https://github.com/linux-test-project/lcov/releases/download/v${LCOV_VERSION}/lcov-${LCOV_VERSION}.tar.gz -O ~/lcov.tar.gz && \
58+
echo "${LCOV_SHA256SUM} ${HOME}/lcov.tar.gz" | shasum --algorithm=256 --check && \
59+
cd ~ && tar zvxf ~/lcov.tar.gz && \
60+
rm ~/lcov.tar.gz
61+
62+
ENV PATH=/home/circleci/lcov-${LCOV_VERSION}/bin:$PATH
63+
64+
# Auto-activate the virtualenv in the container
65+
RUN sudo mkdir -p /circleci/ && \
66+
sudo bash -c "echo 'source ~/venv/bin/activate' >> /circleci/.bashrc_circleci" && \
67+
echo 'source /circleci/.bashrc_circleci' >> ~/.bashrc
68+
69+
ENTRYPOINT ["bash"]

.circleci/config.yml

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,7 @@ version: 2.1
1515
executors:
1616
memfault-ci:
1717
docker:
18-
# TODO: create separate docker image + public Dockerfile
19-
- image: memfault/ci:3.2.3
18+
- image: memfault/memfault-firmware-sdk-ci:0.0.1
2019
working_directory: ~/repo
2120

2221
commands:
@@ -26,7 +25,6 @@ commands:
2625
name: Set environment variables and source virtualenv
2726
command: |
2827
if [ -f /circleci/.bashrc_circleci ]; then
29-
touch .nvmrc
3028
cat /circleci/.bashrc_circleci >> $BASH_ENV
3129
fi
3230
@@ -43,21 +41,9 @@ commands:
4341
- ~/venv
4442
key: v3-pip-dependencies-{{ checksum "requirements.txt" }}
4543

46-
# TODO: move into Dockerfile
47-
lcov_install:
48-
steps:
49-
- run:
50-
name: Install lcov 1.14
51-
command: |
52-
LCOV_SHA256SUM=14995699187440e0ae4da57fe3a64adc0a3c5cf14feab971f8db38fb7d8f071a
53-
wget https://github.com/linux-test-project/lcov/releases/download/v1.14/lcov-1.14.tar.gz -O ~/lcov.tar.gz
54-
echo "${LCOV_SHA256SUM} ${HOME}/lcov.tar.gz" | shasum --algorithm=256 --check
55-
cd ~ && tar zvxf ~/lcov.tar.gz
56-
5744
prepare:
5845
steps:
5946
- checkout
60-
- lcov_install
6147
- virtualenv_activate
6248
- pip_install
6349

@@ -67,7 +53,12 @@ jobs:
6753
executor: memfault-ci
6854
steps:
6955
- prepare
70-
- run: PATH=~/lcov-1.14/bin:$PATH inv test --coverage
56+
# run the tests with the sanitizer enabled first
57+
- run: inv -e test --coverage
58+
# now clean, and re-run with the sanitizer disabled- it adds extra
59+
# branches that cannot be hit in a normal run, impacting coverage statistics
60+
- run: git clean -dxff
61+
- run: MEMFAULT_DISABLE_ASAN=1 inv -e test --coverage
7162
- run: curl -s https://codecov.io/bash | bash -s -- -t ${CODECOV_TOKEN} -n ${CIRCLE_BUILD_NUM} -Z || echo 'Codecov upload failed'
7263

7364
workflows:

.circleci/runas.sh

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#!/usr/bin/env bash
2+
3+
# This script can be used (on a Linux host, at least) to set up a docker
4+
# container to be able to write on a hosted volume, by using an overlay mount
5+
# inside the container.
6+
#
7+
# It requires running docker with the --priviledged flag. An example:
8+
#
9+
# ❯docker run --privileged --rm -i -t -v"$PWD":/hostdir memfault/memfault-firmware-sdk-ci /hostdir/.circleci/runas.sh
10+
11+
12+
set -euo pipefail
13+
14+
BASE_DIR=/hostdir
15+
FINAL_DIR=/memfault-firmware-sdk
16+
USER=${USER-$(whoami)}
17+
18+
mkdir -p /tmp/overlay/
19+
sudo mount -t tmpfs tmpfs /tmp/overlay
20+
mkdir /tmp/overlay/{up,work}
21+
sudo mkdir "$FINAL_DIR"
22+
sudo mount -t overlay overlay \
23+
-o lowerdir="$BASE_DIR,upperdir=/tmp/overlay/up/,workdir=/tmp/overlay/work/" \
24+
"$FINAL_DIR"
25+
sudo chown -R "$USER:$USER $FINAL_DIR"
26+
27+
exec bash

CHANGES.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,19 @@
1+
### Changes between Memfault SDK 0.31.3 and SDK 0.31.2 - July 8, 2022
2+
3+
#### :chart_with_upwards_trend: Improvements
4+
5+
- Support Zephyr v3.1+ by conditionally compiling out Logger v1 code, thanks to
6+
@tejlmand for the patch!
7+
18
### Changes between Memfault SDK 0.31.2 and SDK 0.31.1 - June 24, 2022
29

310
#### :chart_with_upwards_trend: Improvements
411

512
- Fixed a :bug: in the
613
[Zephyr port HTTP implementation](ports/zephyr/common/memfault_platform_http.c),
714
where a socket file descriptor was leaked. This caused every HTTP operation
8-
after the first to fail on Zephyr platforms.
15+
after the first to fail on Zephyr platforms. Thanks to @rerickson1 for the
16+
fix!
917
- Added an update to improve the quality of stack traces when using
1018
`MEMFAULT_ASSERT` with the TI ARM Clang Compiler
1119

VERSION

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
BUILD ID: 464682
2-
GIT COMMIT: 5b8557d55
1+
BUILD ID: 474047
2+
GIT COMMIT: 74c12c38c

components/include/memfault/version.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ typedef struct {
1919
uint8_t patch;
2020
} sMfltSdkVersion;
2121

22-
#define MEMFAULT_SDK_VERSION { .major = 0, .minor = 31, .patch = 2 }
22+
#define MEMFAULT_SDK_VERSION { .major = 0, .minor = 31, .patch = 3 }
2323

2424
#ifdef __cplusplus
2525
}

examples/esp32/README.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,19 @@
11
# Memfault for ESP32
22

3-
This example application shows an integration with the ESP-IDF v3.3.5 SDK where
3+
This example application shows an integration with the ESP-IDF v4.2.2 SDK where
44
a saved coredump is posted to the Memfault cloud for analysis.
55

66
If you already have an ESP-IDF project based on the v4.x or v3.x SDK, a step by
77
step getting started guide can be found [here](https://mflt.io/esp-tutorial).
88

9+
The Memfault SDK has been tested to be compatible with these versions of
10+
ESP-IDF:
11+
12+
- v3.x release series
13+
- v4.x release series through v4.4.1
14+
15+
Other versions may be also be compatible but have not been verified by Memfault.
16+
917
The memfault SDK hooks into the pre-existing mechanism for
1018
[saving coredumps](https://docs.espressif.com/projects/esp-idf/en/latest/api-guides/core_dump.html).
1119
We save the Memfault coredump data in the exact same coredump partition the

ports/zephyr/common/memfault_logging.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,12 @@ static const uint32_t g_flags = IS_ENABLED(CONFIG_LOG_BACKEND_FORMAT_TIMESTAMP)
4141

4242
// Construct our backend API object. Might need to check how/if we want to support
4343
// put_sync_string() & dropped().
44+
#if !MEMFAULT_ZEPHYR_VERSION_GT(3, 1)
4445
static void prv_log_put(const struct log_backend *const backend, struct log_msg *msg);
4546
static void prv_log_put_sync_string(const struct log_backend *const backend,
4647
struct log_msg_ids src_level, uint32_t timestamp,
4748
const char *fmt, va_list ap);
49+
#endif
4850
static void prv_log_panic(struct log_backend const *const backend);
4951

5052

@@ -67,10 +69,12 @@ const struct log_backend_api log_backend_mflt_api = {
6769
#if MEMFAULT_ZEPHYR_VERSION_GT(2, 5)
6870
.process = IS_ENABLED(CONFIG_LOG2) ? prv_log_process : NULL,
6971
#endif
72+
#if !MEMFAULT_ZEPHYR_VERSION_GT(3, 1)
7073
.put = IS_ENABLED(CONFIG_LOG_IMMEDIATE) ? NULL : prv_log_put,
7174
.put_sync_string = IS_ENABLED(CONFIG_LOG_IMMEDIATE) ? prv_log_put_sync_string : NULL,
7275
// Note: We don't want to clutter Memfault circular buffer with hex dumps
7376
.put_sync_hexdump = NULL,
77+
#endif
7478
.panic = prv_log_panic,
7579
.init = prv_log_init,
7680
.dropped = IS_ENABLED(CONFIG_LOG_IMMEDIATE) ? NULL : prv_log_dropped,
@@ -89,17 +93,20 @@ static int prv_log_out(uint8_t *data, size_t length, void *ctx) {
8993
return (int) length;
9094
}
9195

96+
#if !MEMFAULT_ZEPHYR_VERSION_GT(3, 1)
9297
static eMemfaultPlatformLogLevel prv_map_zephyr_level_to_memfault(uint32_t zephyr_level) {
9398
// Map From To
9499
return zephyr_level == LOG_LEVEL_ERR ? kMemfaultPlatformLogLevel_Error
95100
: zephyr_level == LOG_LEVEL_WRN ? kMemfaultPlatformLogLevel_Warning
96101
: zephyr_level == LOG_LEVEL_INF ? kMemfaultPlatformLogLevel_Info
97102
: /* LOG_LEVEL_DBG */kMemfaultPlatformLogLevel_Debug;
98103
}
104+
#endif
99105

100106
// *** Below are the implementations for the Zephyr backend API ***
101107

102108
// Zephyr API function. I'm assuming <msg> has been validated by the time put() is called.
109+
#if !MEMFAULT_ZEPHYR_VERSION_GT(3, 1)
103110
static void prv_log_put(const struct log_backend *const backend, struct log_msg *msg) {
104111
// Acquire, process (eventually calls prv_data_out()) and release the message.
105112
log_msg_get(msg);
@@ -127,6 +134,7 @@ static void prv_log_put_sync_string(const struct log_backend *const backend,
127134
eMemfaultPlatformLogLevel memfault_level = prv_map_zephyr_level_to_memfault(src_level.level);
128135
memfault_vlog_save(memfault_level, fmt, ap);
129136
}
137+
#endif
130138

131139
static void prv_log_panic(struct log_backend const *const backend) {
132140
log_output_flush(&s_log_output_mflt);

requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@ mbed-cli==1.10.1
44
pyftdi==0.29.4
55
west==0.6.2
66
colorama==0.4.3
7+
fastcov==1.14

scripts/memfault_gdb.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,9 @@
6060
# Note: not using `requests` but using the built-in http.client instead, so
6161
# there will be no additional dependencies other than Python itself.
6262
try:
63-
from httplib import HTTPConnection, HTTPSConnection
64-
from Queue import Queue
65-
from urlparse import urlparse, urlunparse
63+
from httplib import HTTPConnection, HTTPSConnection # noqa: I251
64+
from Queue import Queue # noqa: I251
65+
from urlparse import urlparse, urlunparse # noqa: I251
6666
except ImportError:
6767
from http.client import HTTPConnection, HTTPSConnection
6868
from queue import Queue

0 commit comments

Comments
 (0)