Command Palette

Search for a command to run...

UnylyUnyly
Назад к скиллам

Embedded OTA / Bootloader Toolkit

БесплатноБез исполняемых скриптовНе проверен

嵌入式 OTA/Bootloader 升级链路检查与打包工具。审计侧静态扫描升级代码的防砖漏洞(每条附可直接粘贴的修复代码):跳转 APP 未重定位中断向量表(VTOR)、跳转前未关中断、未校验 APP 有效性、升级数据无 CRC/哈希、flash…

liujycodeот liujycode169 установок в других каталогах

Об этом скилле

Embedded OTA / Bootloader Upgrade Toolkit

Two tools, one goal: never brick a device during firmware upgrade.

  • ota_audit.py — audit side: statically scans upgrade code and reports brick-vulnerable spots by severity (no compiling, no hardware)
  • ota_tool.py — tool side: CRC, 64-byte image header generation, partition layout, .pkg packing, verification

Platform coverage: the auditor targets the full Cortex-M family (ST STM32 / GD32 / CH32 / APM32 / Nordic nRF5x / NXP / Renesas RA...), RISC-V, and the Arduino / ESP8266 framework layer (ESP32 built with Arduino uses vocabulary entirely different from ESP-IDF — adapted separately). Rule signals recognize ST HAL, GD32 FMC, Nordic nrfx, ESP-IDF, Zephyr, MCUboot, Arduino/ESP8266 and generic naming. The tool side (ota_tool.py) is pure byte arithmetic, completely MCU-agnostic. See "Platform Applicability" below.

When to Use It

  • Dead on first interrupt after upgrade: forgot SCB->VTOR relocation before jumping to APP — all APP interrupts land in the bootloader vector table. Rule 1.
  • Bricked by banked upgrades: jumping with an empty/half-flashed APP partition — instant HardFault. Rule 3.
  • "Boots but misbehaves": received data written to flash without verification — transmission errors became firmware. Rule 4.
  • Watchdog kills upgrade mid-flash: multi-second erase/write without feeding the dog — every failure is another brick chance. Rule 6.
  • "Upgrade succeeded but firmware is broken": NOR flash can only write 1-to-0; writing a page without erasing first corrupts it. Rule 14.
  • Don't know what goes in the header: an industrially adequate 64-byte image header format + generator + verifier.

30-Second Demo

Feed in a realistic IAP jump + upgrade write:

/* bootloader.c */
#define APP_BASE 0x08008000

void iap_load_app(void) {
    typedef void (*app_fn)(void);
    app_fn app = (app_fn)APP_BASE;
    __set_MSP(*(volatile uint32_t *)APP_BASE);
    app();
}

void ota_write_image(uint8_t *buf, uint32_t len) {
    flash_erase(0x08008100);
    flash_write(APP_BASE, buf, len);
    HAL_Delay(100);
}

Audit output (score 49/100, 4 critical, 4 major, 3 minor):

Rule Sev Line Issue
R1 CRIT L7 Vector table not relocated before APP jump (no SCB->VTOR anywhere)
R2 CRIT L7 Interrupts not disabled before jump (no __disable_irq)
R3 CRIT L7 APP validity not checked before jump (no SP/vector sanity)
R4 CRIT L13 Upgrade data has no integrity check (flash write without CRC)
R5 MAJ L12 Erase address 0x08008100 not 1K/2K/4K aligned
R7 MAJ L12 Hardcoded partition address (bare 0x08xxxxxx)
R9 MAJ all No anti-rollback version check
R10 MAJ all Upgrade state not persisted (no resume after power loss)
R11 MIN L13 Flash write return value unchecked
R12 MIN all No progress output in upgrade flow
R13 MIN L14 Hardcoded delay inside upgrade flow

Quick Start

Audit

python ota_audit.py bootloader.c                     # single file
python ota_audit.py bootloader.c high                # critical only
python ota_audit.py sketch.ino                       # Arduino sketch (.ino/.pde)
python ota_audit.py --dir ./boot                     # directory (.c/.h/.cpp/.hpp/.cc/.cxx/.ino/.pde)
python ota_audit.py --dir ./boot --html report.html  # HTML report
python ota_audit.py --dir ./boot --fail-under 80     # CI gate: score < 80 exits 1

Exit codes: 0 = clean, 1 = findings, 2 = usage/internal error (CI friendly; --fail-under N gates by score).

Pack

# 1) CRC
python ota_tool.py crc app.bin

# 2) Partition layout (generates .h with compile-time overflow asserts)
python ota_tool.py layout --flash 256K --align 2K boot:32K app:96K app_bak:96K cfg:8K --out partition.h

# 3) Pack (bin + 64B header), also emits MCU-side header
python ota_tool.py pack app.bin -o app.pkg --addr 0x08008000 --ver 1.2.3 --hw-id 0x0001 --emit-header

# 4) Verify (expected board/address guards against cross-flashing)
python ota_tool.py verify app.pkg --hw-id 0x0001 --addr 0x08008000

Exit codes: 0 = success, 1 = verification failed, 2 = usage error.

What the tools cannot see: references/ota-checklist.md is the manual pre-flight checklist (power-cut / disconnect / wrong-packet fault injections), each item annotated with covering rules ([R1]...[R15]) and what must be tested on real hardware ([HIL]).

End-to-End Path for New Projects

  1. Plan partitions: ota_tool.py layout computes the table and generates partition.h (with compile-time overflow asserts); bootloader and APP both take address macros from it — stop hand-writing bare addresses.
  2. Self-audit after writing upgrade code: ota_audit.py bootloader.c --html report.html; clear criticals to 0 and score >= 80 before flashing. Every finding ships paste-ready fix code.
  3. Package delivery:
Полный SKILL.md на ClawHub

Установить Embedded OTA / Bootloader Toolkit в Claude Code и Claude Desktop

Зарегайся, чтобы установить скилл

Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.

  • Открой команду установки в одну строку
  • Сохраняй скиллы в синхронизируемую библиотеку
  • Уведомления, когда скиллы обновляются
Зарегаться бесплатноУ меня уже есть аккаунт

Разрешённые инструменты

Инструменты, которые скиллу разрешено вызывать.

Без ограничений — скилл может использовать любой инструмент.

FAQ

Что делает скилл Embedded OTA / Bootloader Toolkit?

嵌入式 OTA/Bootloader 升级链路检查与打包工具。审计侧静态扫描升级代码的防砖漏洞(每条附可直接粘贴的修复代码):跳转 APP 未重定位中断向量表(VTOR)、跳转前未关中断、未校验 APP 有效性、升级数据无 CRC/哈希、flash 擦除地址未按页对齐、擦写期间未喂看门狗、分区地址硬编码、接收等待无超时、无防降级版本校验、升级状态未持久化、写入前未擦除、关闭看门狗后未恢复等;工具侧计算 CRC32/CRC16、算分区表并生成 .h、生成 64 字节镜像头、打包升级包 .pkg、校验包完整性。当用户要做 IAP/OTA 升级、bootloader 开发与跳转、固件打包、分区规划、远程或本地固件升级、升级后变砖跑飞死机排查、毕设要做固件升级/远程升级、需检查升级流程安全性时使用;原生支持裸机 Cortex-M/RISC-V 与 Arduino/ESP8266 框架写法(认 ArduinoOTA、Update、ESPhttpUpdate、ESP.wdt*、Serial.*、delay、millis)。已配套 190 项测试(145 审计 + 45 工具)。

Как установить скилл Embedded OTA / Bootloader Toolkit?

Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.

Скилл Embedded OTA / Bootloader Toolkit запускает скрипты?

Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.

Похожие скиллы

Сравнить Embedded OTA / Bootloader Toolkit с