Skip to content

Commit dbe84b9

Browse files
author
Memfault Inc
committed
Memfault Firmware SDK 0.37.2 (Build 1352)
1 parent d85d4b2 commit dbe84b9

File tree

13 files changed

+122
-62
lines changed

13 files changed

+122
-62
lines changed

CHANGES.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,22 @@
1+
### Changes between Memfault SDK 0.37.2 and SDK 0.37.1 - Jan 31, 2023
2+
3+
#### :chart_with_upwards_trend: Improvements
4+
5+
- Zephyr:
6+
- Support building with `CONFIG_POSIX_API=y` in the Zephyr port HTTP client
7+
- ESP-IDF:
8+
- Reduce the spamminess of the esp32 example app logging
9+
- Update [`scripts/memfault_gdb.py`](scripts/memfault_gdb.py):
10+
- When explicitly listing a region to insert into the coredump via
11+
`memfault coredump --region x y`, now support parseable GDB expressions for
12+
the range arguments instead of requiring integer values. Thanks to @alvarop
13+
for this patch
14+
[#43](https://github.com/memfault/memfault-firmware-sdk/pull/43) !
15+
- Use the `info all-registers` command when dumping registers, instead of the
16+
deprecated `info registers all` command, which works better on certain
17+
arch/monitor setups. Thanks to @alvarop for this patch
18+
[#44](https://github.com/memfault/memfault-firmware-sdk/pull/44) !
19+
120
### Changes between Memfault SDK 0.37.1 and SDK 0.37.0 - Jan 17, 2023
221

322
#### :chart_with_upwards_trend: Improvements

VERSION

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
BUILD ID: 1184
2-
GIT COMMIT: b60ef08d3
1+
BUILD ID: 1352
2+
GIT COMMIT: a083eca61

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 = 37, .patch = 1 }
22+
#define MEMFAULT_SDK_VERSION { .major = 0, .minor = 37, .patch = 2 }
2323

2424
#ifdef __cplusplus
2525
}

examples/esp32/README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ The Memfault SDK has been tested to be compatible with these versions of
1010
ESP-IDF:
1111

1212
- v3.x release series
13-
- v4.x release series through v4.4.2
13+
- v4.x release series
14+
v5.x release series through v5.0
1415

1516
Other versions may be also be compatible but have not been verified by Memfault.
1617

examples/esp32/apps/memfault_demo_app/main/cmd_wifi.c

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -75,11 +75,11 @@ static void event_handler(void *arg, esp_event_base_t event_base,
7575
if (s_retry_num < EXAMPLE_ESP_MAXIMUM_RETRY) {
7676
esp_wifi_connect();
7777
s_retry_num++;
78-
ESP_LOGI(TAG, "retry to connect to the AP");
78+
ESP_LOGD(TAG, "retry to connect to the AP");
7979
} else {
8080
xEventGroupSetBits(s_wifi_event_group, WIFI_FAIL_BIT);
8181
}
82-
ESP_LOGI(TAG, "connect to the AP fail");
82+
ESP_LOGD(TAG, "connect to the AP fail");
8383
} else if (event_base == IP_EVENT && event_id == IP_EVENT_STA_GOT_IP) {
8484
ip_event_got_ip_t *event = (ip_event_got_ip_t *)event_data;
8585
ESP_LOGI(TAG, "got ip:" IPSTR, IP2STR(&event->ip_info.ip));
@@ -89,23 +89,27 @@ static void event_handler(void *arg, esp_event_base_t event_base,
8989
}
9090

9191
bool wifi_join(const char *ssid, const char *pass) {
92-
s_wifi_event_group = xEventGroupCreate();
92+
static bool one_time_init = false;
93+
if (!one_time_init) {
94+
one_time_init = true;
9395

94-
ESP_ERROR_CHECK(esp_netif_init());
96+
s_wifi_event_group = xEventGroupCreate();
9597

96-
ESP_ERROR_CHECK(esp_event_loop_create_default());
97-
esp_netif_create_default_wifi_sta();
98+
ESP_ERROR_CHECK(esp_netif_init());
9899

99-
wifi_init_config_t cfg = WIFI_INIT_CONFIG_DEFAULT();
100-
ESP_ERROR_CHECK(esp_wifi_init(&cfg));
100+
ESP_ERROR_CHECK(esp_event_loop_create_default());
101+
esp_netif_create_default_wifi_sta();
101102

102-
esp_event_handler_instance_t instance_any_id;
103-
esp_event_handler_instance_t instance_got_ip;
104-
ESP_ERROR_CHECK(esp_event_handler_instance_register(
105-
WIFI_EVENT, ESP_EVENT_ANY_ID, &event_handler, NULL, &instance_any_id));
106-
ESP_ERROR_CHECK(esp_event_handler_instance_register(
107-
IP_EVENT, IP_EVENT_STA_GOT_IP, &event_handler, NULL, &instance_got_ip));
103+
wifi_init_config_t cfg = WIFI_INIT_CONFIG_DEFAULT();
104+
ESP_ERROR_CHECK(esp_wifi_init(&cfg));
108105

106+
esp_event_handler_instance_t instance_any_id;
107+
esp_event_handler_instance_t instance_got_ip;
108+
ESP_ERROR_CHECK(esp_event_handler_instance_register(WIFI_EVENT, ESP_EVENT_ANY_ID,
109+
&event_handler, NULL, &instance_any_id));
110+
ESP_ERROR_CHECK(esp_event_handler_instance_register(IP_EVENT, IP_EVENT_STA_GOT_IP,
111+
&event_handler, NULL, &instance_got_ip));
112+
}
109113
wifi_config_t wifi_config = {
110114
.sta =
111115
{
@@ -124,7 +128,7 @@ bool wifi_join(const char *ssid, const char *pass) {
124128
ESP_ERROR_CHECK(esp_wifi_set_config(WIFI_IF_STA, &wifi_config));
125129
ESP_ERROR_CHECK(esp_wifi_start());
126130

127-
ESP_LOGI(TAG, "wifi_init_sta finished.");
131+
ESP_LOGD(TAG, "wifi_init_sta finished.");
128132

129133
/* Waiting until either the connection is established (WIFI_CONNECTED_BIT) or
130134
* connection failed for the maximum number of re-tries (WIFI_FAIL_BIT). The
@@ -139,7 +143,7 @@ bool wifi_join(const char *ssid, const char *pass) {
139143
ESP_LOGI(TAG, "connected to ap SSID:%s ", ssid);
140144
return true;
141145
} else if (bits & WIFI_FAIL_BIT) {
142-
ESP_LOGI(TAG, "Failed to connect to SSID:%s", pass);
146+
ESP_LOGD(TAG, "Failed to connect to SSID:%s", pass);
143147
} else {
144148
ESP_LOGE(TAG, "UNEXPECTED EVENT");
145149
}

examples/esp32/apps/memfault_demo_app/main/console_example_main.c

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -189,10 +189,10 @@ void memfault_esp_port_wifi_autojoin(void) {
189189
MEMFAULT_LOG_DEBUG("No WiFi credentials found");
190190
return;
191191
}
192-
MEMFAULT_LOG_INFO("Starting WiFi Autojoin ...");
192+
MEMFAULT_LOG_DEBUG("Starting WiFi Autojoin ...");
193193
bool result = wifi_join(ssid, pass);
194194
if (!result) {
195-
MEMFAULT_LOG_ERROR("Failed to join WiFi network");
195+
MEMFAULT_LOG_DEBUG("Failed to join WiFi network");
196196
}
197197
}
198198

@@ -204,16 +204,26 @@ static void prv_poster_task(void *args) {
204204
const TickType_t delay_ms = (1000 * interval_sec) / portTICK_PERIOD_MS;
205205

206206
MEMFAULT_LOG_INFO("Data poster task up and running every %" PRIu32 "s.", interval_sec);
207-
while (true) {
208-
MEMFAULT_LOG_DEBUG("Checking for memfault data to send");
209-
int err = memfault_esp_port_http_client_post_data();
210-
// if the check-in succeeded, set green, otherwise clear.
211-
// gives a quick eyeball check that the app is alive and well
212-
led_set_color((err == 0) ? kLedColor_Green : kLedColor_Red);
213207

208+
while (true) {
209+
// count the number of times this task has run
214210
memfault_metrics_heartbeat_add(MEMFAULT_METRICS_KEY(PosterTaskNumSchedules), 1);
211+
// attempt to autojoin wifi, if configured
215212
memfault_esp_port_wifi_autojoin();
213+
214+
// if connected, post any memfault data
215+
if (memfault_esp_port_wifi_connected()) {
216+
MEMFAULT_LOG_DEBUG("Checking for memfault data to send");
217+
int err = memfault_esp_port_http_client_post_data();
218+
// if the check-in succeeded, set green, otherwise clear.
219+
// gives a quick eyeball check that the app is alive and well
220+
led_set_color((err == 0) ? kLedColor_Green : kLedColor_Red);
221+
}
222+
223+
// check for OTA update
216224
prv_memfault_ota();
225+
226+
// sleep
217227
vTaskDelay(delay_ms);
218228
}
219229
}

ports/esp_idf/memfault/common/memfault_platform_http_client.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,10 @@ sMfltHttpClient *memfault_platform_http_client_create(void) {
123123

124124
int memfault_platform_http_client_destroy(sMfltHttpClient *_client) {
125125
esp_http_client_handle_t client = (esp_http_client_handle_t)_client;
126-
esp_err_t err = esp_http_client_cleanup(client);
126+
esp_err_t err = esp_http_client_close(client);
127+
if (err == ESP_OK) {
128+
err = esp_http_client_cleanup(client);
129+
}
127130
if (err == ESP_OK) {
128131
return 0;
129132
}

ports/zephyr/common/memfault_platform_http.c

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,13 @@
44
//! See License.txt for details
55
//!
66

7-
#include "memfault/ports/zephyr/http.h"
8-
#include "memfault/ports/zephyr/root_cert_storage.h"
9-
107
#include <errno.h>
11-
#include <stdbool.h>
12-
#include <stdio.h>
13-
#include <stdlib.h>
14-
158
#include <init.h>
169
#include <kernel.h>
17-
18-
#include <net/socket.h>
1910
#include <net/tls_credentials.h>
11+
#include <stdbool.h>
12+
#include <stdio.h>
13+
#include <stdlib.h>
2014
#include <zephyr.h>
2115

2216
#include "memfault/core/compiler.h"
@@ -27,6 +21,17 @@
2721
#include "memfault/http/root_certs.h"
2822
#include "memfault/http/utils.h"
2923
#include "memfault/panics/assert.h"
24+
#include "memfault/ports/zephyr/http.h"
25+
#include "memfault/ports/zephyr/root_cert_storage.h"
26+
27+
#if defined(CONFIG_POSIX_API)
28+
#include <posix/netdb.h>
29+
#include <posix/poll.h>
30+
#include <posix/sys/socket.h>
31+
#include <posix/unistd.h>
32+
#else
33+
#include <net/socket.h>
34+
#endif
3035

3136
#if defined(CONFIG_MEMFAULT_HTTP_USES_MBEDTLS)
3237

scripts/fw_build_id.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,9 @@
1818
# Released SDK:
1919
sys.path.insert(0, bundled_mflt_build_id_src_dir)
2020

21-
from mflt_build_id import * # noqa
21+
from mflt_build_id import * # noqa: E402,F401,F403,M900
2222

2323
if __name__ == "__main__":
24-
main() # noqa
24+
from mflt_build_id import main # noqa: M900
25+
26+
main()

scripts/memfault_gdb.py

Lines changed: 31 additions & 18 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 # noqa: I251
64-
from Queue import Queue # noqa: I251
65-
from urlparse import urlparse, urlunparse # noqa: I251
63+
from httplib import HTTPConnection, HTTPSConnection
64+
from Queue import Queue
65+
from urlparse import urlparse, urlunparse
6666
except ImportError:
6767
from http.client import HTTPConnection, HTTPSConnection
6868
from queue import Queue
@@ -145,7 +145,7 @@ def _pc_in_vector_table(register_list, exception_number, analytics_props):
145145
exc_handler, _ = _read_register(0x0 + vtor + (exception_number * 4))
146146
exc_handler &= ~0x1 # Clear thumb bit
147147
return exc_handler == curr_pc
148-
except Exception: # noqa
148+
except Exception:
149149
analytics_props["pc_in_vtor_check_error"] = {"traceback": traceback.format_exc()}
150150
return False
151151

@@ -347,7 +347,7 @@ def get_current_registers(self, gdb_thread, analytics_props):
347347
try:
348348
for core_id in range(0, self.num_cores):
349349
result.append(self._read_registers(core_id, gdb_thread, analytics_props))
350-
except Exception: # noqa
350+
except Exception:
351351
analytics_props["core_reg_collection_error"] = {"traceback": traceback.format_exc()}
352352

353353
return result
@@ -458,15 +458,15 @@ def add_platform_specific_sections(self, cd_writer, inferior, analytics_props):
458458
section.data = inferior.read_memory(section.addr, section.size)
459459
cd_writer.add_section(section)
460460
analytics_props["{}_ok".format(short_name)] = True
461-
except Exception: # noqa
461+
except Exception:
462462
analytics_props["{}_collection_error".format(short_name)] = {
463463
"traceback": traceback.format_exc()
464464
}
465465

466466
try:
467467
cd_writer.armv67_mpu = self._try_collect_mpu_settings()
468468
print("Collected MPU config")
469-
except Exception: # noqa
469+
except Exception:
470470
analytics_props["mpu_collection_error"] = {"traceback": traceback.format_exc()}
471471

472472
def guess_ram_regions(self, elf_sections):
@@ -489,9 +489,19 @@ def get_current_registers(self, gdb_thread, analytics_props):
489489
# best way. Call this, rip out the first element in each row...that's the register name
490490

491491
#
492-
# NOTE: We use the "all" argument below because on some versions of gdb "msp, psp, etc" are not considered part of them
493-
# core set. This will also dump all the fpu registers which we don't collect but thats fine
494-
info_reg_all_list = gdb.execute("info reg all", to_string=True)
492+
# NOTE: Using the 'all-registers' command below, because on some
493+
# versions of gdb "msp, psp, etc" are not considered part of them core
494+
# set. This will also dump all the fpu registers which we don't collect
495+
# but thats fine. 'info all-registers' is the preferred command, where
496+
# 'info reg [all]' is arch-specific, see:
497+
# https://sourceware.org/gdb/onlinedocs/gdb/Registers.html
498+
try:
499+
info_reg_all_list = gdb.execute("info all-registers", to_string=True)
500+
except gdb.error:
501+
# Some versions of gdb don't support 'all' and return an error, fall
502+
# back to 'info reg'
503+
info_reg_all_list = gdb.execute("info reg", to_string=True)
504+
495505
return (lookup_registers_from_list(self, info_reg_all_list, analytics_props),)
496506

497507

@@ -539,7 +549,7 @@ def _try_read_register(arch, frame, lookup_name, register_list, analytics_props,
539549
_add_reg_collection_error_analytic(
540550
arch, analytics_props, lookup_name, "<unavailable> value"
541551
)
542-
except Exception: # noqa
552+
except Exception:
543553
_add_reg_collection_error_analytic(
544554
arch, analytics_props, lookup_name, traceback.format_exc()
545555
)
@@ -600,7 +610,7 @@ def _search_list_for_alt_name(reg, found_registers):
600610
# if we can't patch the registers, we'll just fallback to the active state
601611
try:
602612
check_and_patch_reglist_for_fault(register_list, analytics_props)
603-
except Exception: # noqa
613+
except Exception:
604614
analytics_props["fault_register_recover_error"] = {"traceback": traceback.format_exc()}
605615
pass
606616

@@ -786,7 +796,7 @@ def _http(method, base_uri, path, headers=None, body=None):
786796
body = response.read()
787797
try:
788798
json_body = loads(body)
789-
except Exception: # noqa
799+
except Exception:
790800
json_body = None
791801
conn.close()
792802
return status, reason, json_body
@@ -1063,7 +1073,7 @@ def settings_load():
10631073
try:
10641074
with open(MEMFAULT_CONFIG.json_path, "rb") as f:
10651075
return load(f)
1066-
except Exception: # noqa
1076+
except Exception:
10671077
return {}
10681078

10691079

@@ -1438,7 +1448,10 @@ def parse_args(self, unicode_args, config):
14381448
)
14391449

14401450
def _auto_int(x):
1441-
return int(x, 0)
1451+
try:
1452+
return int(x, 0)
1453+
except ValueError:
1454+
return int(gdb.parse_and_eval(x))
14421455

14431456
parser.add_argument(
14441457
"--region",
@@ -1696,7 +1709,7 @@ def run(self):
16961709
# Throttle a bit
16971710
sleep(0.2)
16981711

1699-
except Exception: # noqa
1712+
except Exception:
17001713
pass # Never fail due to analytics requests erroring out
17011714

17021715

@@ -1711,12 +1724,12 @@ def _track_script_sourced():
17111724
from platform import mac_ver
17121725

17131726
mac_version = mac_ver()[0]
1714-
except Exception: # noqa
1727+
except Exception:
17151728
mac_version = ""
17161729

17171730
try:
17181731
gdb_version = gdb.execute("show version", to_string=True).strip().split("\n")[0]
1719-
except Exception: # noqa
1732+
except Exception:
17201733
gdb_version = ""
17211734

17221735
ANALYTICS.track(

0 commit comments

Comments
 (0)