Skip to main content

memview

PyPI - Version PyPI - Python Version PyPI - License PyPI - Wheel PyPI - Downloads

Inspect and visualize binary memory layouts from multiple input formats (Intel HEX, S-Record, hexdumps, and raw BIN).
Define a layout once (TOML/YAML), then decode typed fields, verify expectations, and export reports (text/JSON/CSV).

Highlights

  • Unified sparse memory model over HEX/SREC/hexdumps/BIN
  • Declarative layout: segments, typed fields, expectations
  • Typed decoders: u8/u16/u32/u64, bytes(size), bitfield, addr, str(size, encoding)
  • Bitfields with configurable bit order: lsb (default) or msb
  • Clean CLI: inspect → text/JSON/CSV
  • Minimal dependencies; install-anywhere

Installation

Requirements

  • Python 3.11+

Install

pip install memview

If you’re developing locally with a src/ layout:

pip install -e .

Input formats

  • Intel HEX (.hex) — parsed with addresses
  • S-Record (.srec, .s19, .mot) — parsed with addresses
  • Hex dump (xxd / hexdump -C style) — parsed with addresses
  • Raw BIN — no addresses; you must pass --base

CLI

Inspect a file (layout-aware)

memview inspect fw.hex --layout fw.toml

Choose output format

memview inspect fw.hex --layout fw.toml --format text
memview inspect fw.hex --layout fw.toml --format json
memview inspect fw.hex --layout fw.toml --format csv

BIN requires a base address

memview inspect fw.bin --layout fw.toml --base 0x08000000

Bitfield bit order override (lsb by default)

memview inspect fw.hex --layout fw.toml --bit-order msb

Exit codes

  • 0 — success
  • 2 — success with issues (e.g., missing bytes, expectation failures)
  • 1 — error

Layout files

Layouts can be TOML (recommended) or YAML (if PyYAML is installed).

Minimal TOML example

[memory]
fill = 0xFF
# Optional default bit order for bitfields; defaults to "lsb" if omitted
# bit_order = "lsb"  # or "msb"

[[segments]]
name = "header"
base = 0x08000000
size = 64

[[segments]]
name = "app"
base = 0x08000040
size = 0x70000

[[layout]]
name   = "magic"
at     = "header+0x00"
type   = "u32"
endian = "be"

[[layout]]
name = "flags"
at   = "header+0x04"
type = "bitfield"
# field-level override (optional): bit_order = "msb"
bits = [
  { name = "secure", bit = 0 },
  { name = "debug",  bit = 1 },
  { name = "valid",  bit = 7 }
]

[[layout]]
name   = "length"
at     = "header+0x06"
type   = "u16"
endian = "le"

[[layout]]
name   = "entry_point"
at     = "header+0x08"
type   = "addr"
endian = "le"

[[layout]]
name   = "name"
at     = "header+0x0C"
type   = "str"
size   = 8
encoding = "ascii"

[[layout]]
name   = "payload"
at     = "app+0x00"
type   = "bytes"
size   = 256

Address syntax

  • Absolute: 0x08000000
  • Segment + offset: segmentName+0x04

Types (current)

  • Scalars: u8, u16, u32, u64 (with endian = "le" | "be")
  • bytes(size = N)
  • bitfield with bits = [{name, bit}]
    • Bit numbering is LSB-first by default.
    • Control via memory.bit_order = "lsb"|"msb" or per-field bit_order.
  • addr (4 bytes, endianness controllable)
  • str(size = N, encoding = "ascii" | "utf8") (trailing NULs trimmed)

Expectations

For integer-like fields you can set expect:

[[layout]]
name   = "magic"
at     = "header+0x00"
type   = "u32"
endian = "be"
expect = 0xABCD1234

If an expectation fails (or bytes are missing), the CLI returns 2 and lists issues.


Examples

Intel HEX

memview inspect firmware.hex --layout fw.toml

S-Record

memview inspect firmware.srec --layout fw.toml --format json

Hex dump (xxd / hexdump -C)

memview inspect dump.txt --layout fw.toml --format csv

BIN with explicit base

memview inspect firmware.bin --layout fw.toml --base 0x08000000

Output samples

Text

Field              Addr       Type       Value
magic              0x08000000 u32(be)    0xABCD1234
flags              0x08000004 bitfield   {debug=0, secure=1, valid=1}
length             0x08000006 u16(le)    0x0020
entry_point        0x08000008 addr(le)   0x08000040
name               0x0800000C str        TEST
payload            0x08000040 bytes      [256 bytes] sha256=2f5b7b8e2a7f2a8c…

JSON (excerpt)

{
  "fields": [
    {"name":"magic","address":134217728,"type":"u32","value":2882343476,"meta":{"endian":"be"}},
    {"name":"payload","address":134217792,"type":"bytes","value":{"kind":"bytes","len":256,"sha256":"..."},"meta":{"size":256}}
  ],
  "issues": []
}

CSV (first rows)

name,address,type,value,meta
magic,0x08000000,u32,0xABCD1234,{"endian":"be"}
flags,0x08000004,bitfield,{debug=0, secure=1, valid=1},{}
...

Programmatic API (preview)

from memview.loaders import load_from_path
from memview.layout import load_layout, inspect

layout = load_layout("fw.toml")
mem, kind = load_from_path("firmware.hex", fill=0xFF)
report = inspect(layout, mem, default_bit_order="lsb")
for f in report.fields:
    print(f.name, hex(f.address), f.type, f.value)

Behavior and guarantees

  • No base address in layout for BIN. For raw binaries, the start address must be provided on the command line via --base.
  • Gaps are filled with --fill during normalization; attempts to read missing bytes for a field are reported as issues.
  • Overlapping segments on ingest are rejected.
  • Bitfield default is lsb. Precedence:
    1. field-level bit_order
    2. CLI --bit-order
    3. layout memory.bit_order
    4. implicit default lsb

License

MIT © Ioannis D. (devcoons)

Metadata

Release files for memview 0.1.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for memview 0.1.3
File Size Uploaded Provenance Actions
memview-0.1.3.tar.gz 17.1 kB Without provenance Details for memview-0.1.3.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for memview 0.1.3
File Interpreter ABI Platform Actions
memview-0.1.3-py3-none-any.whl Python 3 none any Details for memview-0.1.3-py3-none-any.whl

Total release size: 35.7 kB

Release files / memview-0.1.3.tar.gz

Download URL memview-0.1.3.tar.gz
Size 17.1 kB
Tags Source
SHA-256 checksum
How to use checksums
decf3f5b0e04da4f7b1e935495c55ce97b5115f569653a21541e70228b063865
BLAKE2b-256 checksum
How to use checksums
bb86417377631929f96d085d1ef5e017edc8da76e3403ec58cfcc55a37f6a1b1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.9.24

Release files / memview-0.1.3-py3-none-any.whl

Download URL memview-0.1.3-py3-none-any.whl
Size 18.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
98164b9f3a8837af52421c23dae0963ee36ecf4bfe85cd5505f76a310308717f
BLAKE2b-256 checksum
How to use checksums
ba6a643bd1744c99d0de2f2534d9344175468fc3e6b9df819853ab57143f89d5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.9.24

Security for memview 0.1.3

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.3 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page