chsh-sk-ncs-tc-memfault-log-debug

Diagnoses and fixes Memfault log-upload failures on NCS/Zephyr firmware.

1|Updated Jan 30, 2026
One-click install
npx skills add https://github.com/chshzh/claude --skill chsh-sk-ncs-tc-memfault-log-debug-chshzh
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: chsh-sk-ncs-tc-memfault-log-debug
Source: https://github.com/chshzh/claude/tree/main/skills/chsh-sk-ncs-tc-memfault-log-debug
Command: npx skills add https://github.com/chshzh/claude --skill chsh-sk-ncs-tc-memfault-log-debug-chshzh

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires pyserial, paramiko, and includes scripts (resource) components.

What problem does it solve? Log messages appear on the UART console but are silently missing or truncated in the Memfault cloud after a disconnect/reconnect cycle, and LOG RESTORE markers never show up in downloaded log files. This Skill pinpoints the two known root causes in NCS v3.3.0 and provides verified SDK and application patches. ## Core Features & Use Cases - Root-cause diagnosis: Distinguishes ring-buffer wrap-boundary CBOR corruption (Bug 1) from stale triggered-state drops (Bug 2) using a structured checklist. - Verified code fixes: Provides exact patches for memfault_log_data_source.c and memfault_log_state_restore.c, including the memfault_log_data_source_reset() call before the LOG RESTORE marker. - Cloud verification: Documents the correct Memfault API download URL format (devices/{serial}/log-files/{cid}/download) with a Python snippet for fetching and decompressing gzip NDJSON log files. - Use Case: After a WiFi disconnect/reconnect test on nRF7002DK boards, run the automated end-to-end script to toggle the router AP, monitor UART for the LOG RESTORE marker, and confirm the marker appears in the cloud log file. ## Quick Start Ask Claude to use the chsh-sk-ncs-tc-memfault-log-debug skill to diagnose why a log message visible on UART is missing from the Memfault cloud log file.

Frequently Asked Questions about chsh-sk-ncs-tc-memfault-log-debug

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
Why do Memfault logs appear on UART but not in the cloud?

The message was written via the Zephyr UART backend but silently dropped from the Memfault ring-buffer backend. Two known causes in NCS v3.3.0 are wrap-boundary CBOR corruption and a stale triggered=true flag blocking writes when the 4096-byte ring buffer is full.

How do I fix truncated Memfault log entries in the cloud?

Patch prv_serialize_msg_callback() in memfault_log_data_source.c to handle continuation calls when offset > 0 by appending bytes with memfault_cbor_join, and open the CBOR string using the full entry length iter->entry.len instead of buf_len.

What is the correct Memfault API URL to download log files?

Use GET {BASE}/devices/{serial}/log-files/{cid}/download, which requires the device serial in the path. Omitting the devices/{serial} segment returns a 404 with no useful error message.

Why is the LOG RESTORE marker missing after a reconnect?

A failed Memfault upload before disconnect (DNS error -11 or -101) leaves triggered=true, so prv_try_free_space() refuses to expire old entries and new writes are dropped. Call memfault_log_data_source_reset() just before writing the LOG RESTORE marker.

How do I run an automated Memfault reconnect test on Nordic boards?

Run scripts/log_restore_test.py, which monitors both boards over serial, toggles the router AP via SSH using wl bss down/up, resets the boards with nrfutil, and waits for the LOG RESTORE marker within 90 seconds. It requires pyserial and paramiko.

Which NCS version and hardware does this debugging guide cover?

The fixes were verified on NCS v3.3.0 with firmware 3.2.0.11 on nRF7002DK and nRF54LM20DK+nRF7002EB2 boards. The ring buffer is 4096 bytes and log state persists to an external NOR flash partition.