/embedded-iot-controls:embedded-security-safety-and-testingfrom embedded-iot-controls
Secures, certifies, tests, and brings up embedded devices.
Ships in embedded-iot-controls. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
Part 4 of 5 of the Embedded Systems & IoT Controls — Deep Technical Reference reference (plugin
embedded-iot-controls), covering §10–§13. Sibling skills:embedded-silicon-and-firmware-models(§0–§2),embedded-languages-realtime-and-patterns(§3–§5),embedded-industrial-control-connectivity-and-cloud(§6–§9),embedded-reference(§14–§19). Section numbers are shared across the set; a reference written as §N →skillpoints into that sibling skill.Currency: Verified August 2026. See §17 →
embedded-referencefor the currency snapshot and what goes stale first.
How to read this. This is a reference, not a tutorial. Sections are independent. Three markers appear throughout:
- [UNIVERSAL] — physics, math, or architecture. True regardless of vendor. Trust it.
- [VENDOR] — specific to a chip, SDK, or toolchain. Verify against the datasheet/errata.
- [CONTESTED] — competent engineers disagree. Both cases are presented. Do not pick a side on the reader's behalf.
⚠️ GOTCHA boxes mark the failure modes that actually burn people. They are the highest-value content in this document.
Attack surfaces, roughly in order of how often they're actually used:
TLS/DTLS on MCUs: mbedTLS (widely integrated, PSA Crypto API), wolfSSL (small,
commercially supported, FIPS options), TinyDTLS (minimal CoAP use). Footprint reality:
a trimmed TLS 1.2/1.3 client with ECDHE-ECDSA-AES128-GCM needs roughly 20–40 KB flash
and 15–30 KB RAM — the RAM is dominated by the record buffer (16 KB max record; use
MBEDTLS_SSL_MAX_CONTENT_LEN and the max-fragment-length extension to cut it).
⚠️ GOTCHA — the certificate validation triad. Devices routinely fail at one of: (a) not validating the chain at all, (b) validating the chain but not the hostname, (c) having no reliable clock, so expiry checks pass anything. All three are common. Fix (c) by getting time from a trusted source before the first TLS handshake, or by using a boot-time-anchored monotonic check plus certificate pinning.
Secure boot chain: immutable ROM verifies the bootloader signature against a public key hash burned into eFuses; the bootloader verifies the application. The root of trust must be immutable — a "secure boot" whose key can be changed by software isn't one.
Debug port lockdown is a lifecycle decision:
TrustZone-M / TF-M: partitions the MCU into Secure and Non-Secure worlds with hardware-enforced boundaries (SAU/IDAU). Trusted Firmware-M provides the reference secure-side implementation with PSA services: Crypto, Internal Trusted Storage, Protected Storage, Initial Attestation. This is the standards-track answer for "keys and secrets isolated from application bugs" on M33/M23.
This section is time-sensitive. Verify before relying on it.
EU Cyber Resilience Act (CRA), Regulation (EU) 2024/2847 — horizontal, applies to essentially every "product with digital elements" placed on the EU market, from any manufacturer worldwide.
EU Radio Equipment Directive (RED) Article 3(3)(d)(e)(f) via Delegated Regulation 2022/30 — mandatory since 1 August 2025 for internet-connectable radio equipment. Harmonised standards EN 18031-1 (network protection → 3.3(d)), EN 18031-2 (privacy and personal data → 3.3(e)), EN 18031-3 (financial fraud → 3.3(f)) were cited in the OJ in January 2025 with restrictions (Implementing Decision (EU) 2025/138). ⚠️ Those restrictions matter: certain clauses (notably around user ability to skip password setup and some parental-control provisions) do not confer presumption of conformity, so products touching them still need a Notified Body. There is no grace period — products non-compliant in August 2025 remain non-compliant now. EN 18031 maps onto ETSI EN 303 645 (the consumer IoT baseline) provisions, and is also the foundation for future CRA harmonised standards.
Other regimes worth knowing:
Minimum bar for a connected product in 2026:
| Standard | Domain | Levels | Notes |
|---|---|---|---|
| IEC 61508 | Generic / industrial (parent standard) | SIL 1–4 | The root from which most others derive |
| ISO 26262 | Automotive | ASIL A–D (+QM) | Adds ASIL decomposition, HARA, item definition |
| IEC 62061 / ISO 13849 | Machinery | SIL CL 1–3 / PL a–e | 13849 uses categories + MTTFd + DC + CCF |
| IEC 61511 | Process industry | SIL 1–3 | Safety Instrumented Systems; sits on 61508 |
| DO-178C | Airborne software | DAL A–E | Objectives-based; MC/DC coverage required at DAL A/B |
| IEC 62304 | Medical device software | Class A/B/C | Lifecycle process standard, not a technique standard |
| EN 50128 / EN 50657 | Rail | SIL 0–4 | Rail-specific software |
| ISO 25119 / ISO 13849 | Agricultural machinery | AgPL |
[UNIVERSAL] These are process standards. They do not tell you how to write good code; they tell you what evidence you must produce that you wrote it deliberately, verified it, and can trace every requirement to a test. The artefacts are the deliverable.
⚠️ GOTCHA — "we'll certify it later." Retrofitting certification onto existing code is typically more expensive than rewriting it. Requirements traceability, a documented development process, and coverage evidence must exist from the start. Deciding at month 18 that the product needs SIL 2 is a schedule catastrophe, not a paperwork exercise.
▲ Field / fleet monitoring (§9.4) ← the ultimate integration test
╱ ╲ HIL — real firmware, real MCU, simulated plant
╱ ╲ On-target integration — real hardware, real peripherals
╱ ╲ Simulation (Renode, QEMU, Wokwi) — full system, no hardware
╱ ╲ Host unit tests with fakes — milliseconds, run on every commit
╱_________╲ Static analysis + compiler warnings — run on every save
[UNIVERSAL] The biggest single productivity lever in embedded software is being able to
run most of your tests on a host machine in under 10 seconds. That requires the
hardware seam from §5.1 → embedded-languages-realtime-and-patterns. Teams without it have a 5-minute flash-and-observe loop and
consequently test far less.
Frameworks: Unity + CMock + Ceedling (C, the classic embedded stack, generates mocks from headers), CppUTest (C/C++, has a memory-leak detector), GoogleTest, Catch2, FFF (Fake Function Framework — header-only C fakes, minimal ceremony).
Dual-target build: the same source compiles for the host (native, with fakes and sanitizers) and for the target. Enables ASan/UBSan/TSan on the host, which find memory bugs that are invisible on the target until they corrupt something three modules away.
/* Host test using FFF — no hardware, no vendor SDK, runs in ~1 ms */
#include "fff.h"
DEFINE_FFF_GLOBALS;
FAKE_VALUE_FUNC(int, i2c_write, void*, uint8_t, const uint8_t*, size_t);
FAKE_VALUE_FUNC(int, i2c_read, void*, uint8_t, uint8_t*, size_t);
static uint8_t canned[3] = { 0x7E, 0x8C, 0x00 }; /* datasheet's worked example */
static int read_canned(void *c, uint8_t a, uint8_t *d, size_t n) {
memcpy(d, canned, n); return 0;
}
void test_temp_matches_datasheet_reference(void) {
i2c_read_fake.custom_fake = read_canned;
bme280_t dev = { .bus = &fake_bus, .addr = 0x76 };
int32_t t;
TEST_ASSERT_EQUAL(0, bme280_read_temp(&dev, &t));
TEST_ASSERT_INT32_WITHIN(50, 25400, t); /* 25.4 °C ± 0.05 */
TEST_ASSERT_EQUAL(1, i2c_write_fake.call_count);
TEST_ASSERT_EQUAL(0xFA, i2c_write_fake.arg2_history[0][0]);
}
What to test on the host: protocol parsers (feed them fuzzed input!), state machines (every transition, including illegal ones), control algorithms (step response against expected), data transformations, checksum/CRC, compensation math, ring buffers, and anything with an if-statement. What you cannot test on the host: timing, ISR interactions, actual peripheral behaviour, and silicon errata.
Fuzzing: compile your protocol parser for the host and run libFuzzer or AFL++ against it. Firmware parsers handle untrusted network input and are almost never fuzzed. This is an unusually high return on a day's work.
Property-based testing (theft, RapidCheck, Hypothesis via a Python harness): assert invariants (e.g. "pushing then popping a ring buffer returns the same bytes in order, for any sequence of operations") and let the tool find the counterexample. Excellent for buffers, encoders, and state machines.
| Tool | Type | Notes |
|---|---|---|
| Compiler warnings | free | -Wall -Wextra -Wconversion -Wshadow -Wundef -Werror. -Wconversion alone catches an enormous amount of integer-promotion breakage. |
| clang-tidy | free | Modernization + bug-prone patterns; integrates with CI |
| Cppcheck | free | Decent, low false-positive rate, MISRA add-on |
| PC-lint Plus / Coverity / Klocwork / Parasoft / LDRA / Axivion | commercial | MISRA/CERT/AUTOSAR rule sets with certification evidence |
| Polyspace | commercial | Abstract interpretation — proves absence of certain runtime errors, not just finds them |
| Frama-C | free | ACSL contracts, deductive verification of C |
| CBMC | free | Bounded model checking; AWS uses it to prove memory safety of FreeRTOS libraries |
| SPARK | commercial | Provable absence of runtime errors in Ada |
| TLA+ / Alloy | free | Model the protocol, not the code — finds distributed-state bugs before implementation |
Coverage: statement → branch → MC/DC (modified condition/decision coverage, required for DO-178C DAL A/B). On-target coverage needs instrumentation (gcov with a retrieval channel) or trace hardware (ETM). Host-based coverage is far easier and catches most logic gaps.
| Tool | Reveals | When |
|---|---|---|
| SWD/JTAG + GDB (OpenOCD, pyOCD, probe-rs, J-Link) | State, breakpoints, memory | Always |
| SEGGER RTT | printf-speed logging with ~µs overhead, no UART pin | Always — vastly better than UART printf |
| defmt (Rust) | Interned format strings; tiny wire format | Rust projects |
| ITM / SWO | Instrumentation trace, printf, timestamps | Cortex-M3+ |
| ETM / ETB | Full instruction trace — reconstruct exactly what executed | Hard bugs, timing analysis; needs trace probe |
| SystemView / Tracealyzer / Percepio | RTOS task/ISR timeline, blocking, priority inversion | Any RTOS timing problem — this is the tool |
| Logic analyzer (Saleae, sigrok) | Protocol decode, timing | Every bus bring-up |
| Oscilloscope | Analog reality: ringing, droop, rise time, glitches | Signal integrity, power |
| GPIO toggle + scope | ISR latency, task jitter, WCET | The universal timing measurement |
| Current probe / Otii / Joulescope | Real energy per operation | Every battery product |
| ftrace / perf / LTTng / eBPF | Linux kernel and userspace latency | Embedded Linux |
The GPIO-toggle technique deserves emphasis: set a pin high on ISR entry, low on exit; scope it. You get latency, duration, jitter, and frequency in one shot, with ~2 cycles of overhead and no tooling. It is the fastest path from "it feels slow" to a number.
⚠️ GOTCHA — printf debugging changes timing. A blocking UART printf at 115200 baud
takes ~87 µs per character. Putting one in an ISR will change the behaviour you're
trying to observe (and often "fix" the bug). Use RTT, defmt, a ring buffer flushed by a
low-priority task, or GPIO toggles.
A pipeline that actually works:
commit
├─ format check (clang-format) + lint (clang-tidy, cppcheck/MISRA)
├─ host unit tests (Unity/CppUTest) + ASan/UBSan ....... < 30 s
├─ build all targets in a pinned container ............. reproducible
├─ size regression gate (flash/RAM vs baseline, fail on >2% growth)
├─ simulation tests (Renode) ........................... minutes
├─ SBOM generation (SPDX/CycloneDX) + CVE scan ......... CRA evidence
├─ artifact signing (HSM-backed) ....................... never a laptop key
└─ nightly: hardware test farm + power-fail-during-OTA + soak
Version everything into the binary: git hash, build date, toolchain version, and a build-type flag, exposed via a diagnostic command. "Which firmware is this device running?" must have a definitive answer from the device itself.
A sequence that saves days, in order. Do not skip ahead.
Hardware/firmware co-development: firmware should review the schematic before layout. The cheap things to catch at that stage: test points on every bus, a debug header that isn't under a connector, no strapping pins used as outputs, LEDs on spare GPIOs for state indication, a way to measure current (a 0 Ω shunt in series with the MCU supply), and pull-ups sized for the actual bus capacitance.
What SKILL.md sets; muted values are Claude Code's defaults
npx claudepluginhub the-vibey-project/vibey --plugin embedded-iot-controls5 skills in this plugin
/embedded-industrial-control-connectivity-and-cloudUse when working on OT/industrial control or connected-device systems: the PLC scan cycle, IEC 61131-3 languages, fieldbus and industrial protocols (Modbus, PROFINET, EtherCAT), OPC UA vs MQTT/Sparkplug and the unified namespace, Purdue/ISA-95 and the IT/OT boundary, TSN; PID done correctly, beyond PID, and motor control; choosing a radio, BLE, Thread and Matter, LoRaWAN, cellular, the application protocols (MQTT, CoAP), edge computing and TinyML; and the cloud, fleet, and lifecycle layer — the platform landscape, identity and provisioning, OTA update, and fleet observability./embedded-languages-realtime-and-patternsUse when writing firmware and deciding how to write it: C and its traps, the safe C++ subset, where Rust in embedded actually stands, real-time taxonomy and critical sections, atomics and memory barriers, the concurrency bug taxonomy, and the working set of firmware patterns — layered architecture, state machines, the lock-free SPSC ring buffer, memory pools instead of malloc, rollover-safe time handling, driver patterns, ISR-to-task handoff, error handling and fault forensics, the supervised watchdog, and the anti-pattern catalogue.Other plugins' skills for the same job