Jump to content
Setting up an AI agent? ReverseEngineering.wiki skill (works from the command line, no configuration): https://reverseengineering.wiki/skill/rewiki/SKILL.md · setup for every client, including MCP: https://reverseengineering.wiki/llms.txt · REWiki:Connect

Format:OpenWrt fwtool trailer

From ReverseEngineering.wiki
Format
Magic 46 57 78 30 ("FWx0") at 16 bytes before the end of each trailer
Endianness big
On this wiki Facts · Code · Notes · Topics

The metadata and signature trailers OpenWrt appends to firmware images: 16-byte trailers with magic "FWx0" (46 57 78 30), a CRC-32 chained over the whole file, a type (signature or info) and a size, read from the end of the file backwards.

Trailer structure

From openwrt/fwtool fwimage.h (lines 18-37) and fwtool.c:

struct fwimage_header  { u32 version; u32 flags; char data[]; }   // info payload header, both 0
struct fwimage_trailer { u32 magic; u32 crc32; u8 type; u8 pad[3]; u32 size; }  // 16 bytes
enum fwimage_type { FWIMAGE_SIGNATURE = 0, FWIMAGE_INFO = 1 };

The magic is FWIMAGE_MAGIC 0x46577830 ("FWx0"); the trailer is written with big-endian fields (cpu_to_be32, fwtool.c lines 137-143 and 192). Only FWx0 occurs in the fwtool sources read; no FWx1 magic was found there.

A trailer sits at the very end of the file and describes the data directly before it:

[firmware][fwimage_header 8 bytes + metadata][trailer type=INFO][signature data][trailer type=SIGNATURE]

size includes the 16-byte trailer itself (and for the info type the 8-byte header): data_len = size - 16 (extract_data, lines 340-350). Limits: metadata at most 30 KiB, signature at most 1 KiB (lines 25-26).

CRC rule

CRC-32 table loop with initial value 0xFFFFFFFF and no final inversion (crc32.h lines 39-48). The crc32 field of a trailer is the running value over every byte before the trailer's own crc32 field was set: the firmware, the earlier payloads and, for a second trailer, the first trailer including its stored CRC (lines 109-112, 142, 187-215). The reader walks from the end: read the last 16 bytes, check the magic, compare the stored CRC with the CRC of the file up to that point, strip the data, and repeat for an earlier trailer (lines 325-395). A missing magic simply means that the file has no trailer ("Data not found").

What is inside

Info payload: JSON written by the image build (include/image-commands.mk, metadata_json, lines 76-92, appended with fwtool -I in append-metadata, lines 94-103). It holds metadata_version ("1.1"), compat_version, optional compat_message, supported_devices (or new_supported_devices when compat_version is not 1.0) and a version object with dist, version, revision, target and board. The supported_devices list is what sysupgrade compares against the running board.

Signature payload: with CONFIG_SIGN_FIRMWARE the build signs the image with usign, wraps it in a ucert chain and appends it with fwtool -S (lines 97-103). It authenticates the image for sysupgrade only; recognising the block is enough for analysis.

Use

To analyse an OpenWrt image, test the last 16 bytes for FWx0, strip trailers with the CRC check, and read the JSON for the exact target, board and compatible devices. fwtool -t truncates the trailers (platform.sh lines 44-58 call it with -s /dev/null and -i /dev/null). Related: Format:OpenWrt sysupgrade tar.

Sources: openwrt/fwtool (GPL-2.0), openwrt/openwrt.

Code & repositories

  • https://github.com/openwrt/fwtool @ 04cd252e4e9394ffacd51f56f1f124abc534f715 · license: GPL-2.0-only (declared by the contributor; GitHub's detector did not recognize a license file)
    fwtool: appends and strips the FWx0 metadata and signature trailers of OpenWrt images
    Tested on: source read, not run: source read, not built · checked 2026-10-19; last activity 2025-10-03