Hsu.Formats.Firmware 2026.7.13

dotnet add package Hsu.Formats.Firmware --version 2026.7.13
                    
NuGet\Install-Package Hsu.Formats.Firmware -Version 2026.7.13
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Hsu.Formats.Firmware" Version="2026.7.13" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Hsu.Formats.Firmware" Version="2026.7.13" />
                    
Directory.Packages.props
<PackageReference Include="Hsu.Formats.Firmware" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Hsu.Formats.Firmware --version 2026.7.13
                    
#r "nuget: Hsu.Formats.Firmware, 2026.7.13"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Hsu.Formats.Firmware@2026.7.13
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Hsu.Formats.Firmware&version=2026.7.13
                    
Install as a Cake Addin
#tool nuget:?package=Hsu.Formats.Firmware&version=2026.7.13
                    
Install as a Cake Tool

Hsu.Formats.Firmware

NuGet .NET Standard 2.0 .NET 8.0+ AOT Compatible Intel HEX S19 / SREC MOT BIN ELF VBF

Firmware and memory-image format support for the Hsu.Formats library.

Supported Formats

Format Extension Description
Intel HEX .hex .ihex Intel HEX with extended linear/start linear records
Motorola S-record .s19 .srec S0–S9 record families with S1/S2/S3 data widths
Motorola MOT .mot S-record variant with selectable address width
Raw Binary .bin Memory image with configurable base address and fill behavior
ELF .elf ELF32 and ELF64, little- and big-endian
VBF .vbf Volvo Binary Format

Features

  • AOT-compatible (IsAotCompatible=true on net8.0+)
  • All primary models implement IMemoryImage
  • Dedicated parser/writer pairs per format
  • HexModel.StartLinearAddress preserves execution start address metadata
  • S19Model and MotModel preserve address-width intent (16 / 24 / 32-bit)
  • MemorySegment address arithmetic uses 64-bit (long) addressing through the shared abstractions
  • PartitionTransferHelper supports firmware splitting/merging workflows for UDS / CCP / XCP style transfer scenarios

Quick Start

Parse an Intel HEX file

using Hsu.Formats.Hex;

using var stream = File.OpenRead("firmware.hex");
var model = (HexModel)new HexParser().Parse(stream);

foreach (var seg in model.Segments)
    Console.WriteLine($"0x{seg.Address:X8}  {seg.Data.Length} bytes");

Parse a Motorola S-record file

using Hsu.Formats.S19;

using var stream = File.OpenRead("firmware.s19");
var model = (S19Model)new S19Parser().Parse(stream);

Write Intel HEX

using Hsu.Formats.Hex;

using var writer = new StreamWriter("out.hex");
new HexWriter().Write(model, writer);

Write raw binary with gap fill

using Hsu.Formats.Bin;

using var stream = File.Create("out.bin");
new BinWriter(fillByte: 0xFF).Write(model, stream);

Parse an ELF binary

using Hsu.Formats.Elf;

using var stream = File.OpenRead("firmware.elf");
var model = (ElfModel)new ElfParser().Parse(stream);

foreach (var seg in model.Segments)
    Console.WriteLine($"0x{seg.Address:X8}  {seg.Data.Length} bytes");

Partition Transfer Helpers

PartitionTransferHelper supports slicing memory images into fixed-size transfer blocks and reassembling them later.

Typical use cases:

  • UDS RequestDownload / TransferData
  • CCP / XCP style segmented download flows
  • offline chunking for updater pipelines

Split a firmware image into transfer blocks

using Hsu.Formats.Hex;
using Hsu.Formats;

using var stream = File.OpenRead("firmware.hex");
var model = (HexModel)new HexParser().Parse(stream);

var blocks = PartitionTransferHelper.SplitImage(model, blockSize: 1024);

foreach (var block in blocks)
    Console.WriteLine($"Block {block.BlockIndex + 1}/{block.TotalBlocks} @ 0x{block.Address:X8}");

Reassemble transfer blocks

var reconstructed = PartitionTransferHelper.MergePartitions(receivedBlocks);

foreach (var seg in reconstructed)
    Console.WriteLine($"0x{seg.Address:X8}  {seg.Data.Length} bytes");

Async Parsing

All firmware parsers implement IAsyncFormatParser.

  • Text-based formats such as HEX/S19/MOT use async line-oriented parsing patterns
  • Binary formats such as ELF/VBF/BIN expose async entry points for callers and offload CPU-oriented work appropriately
using Hsu.Formats.Hex;
using Hsu.Formats.Elf;

using var hexStream = File.OpenRead("firmware.hex");
var hexModel = (HexModel)await new HexParser().ParseAsync(hexStream);

using var elfStream = File.OpenRead("firmware.elf");
var elfModel = (ElfModel)await new ElfParser().ParseAsync(elfStream);

Documentation

  • Standard format specifications, when present, are documented in the project repository.
  • Project-level architecture and feature design notes are documented in the project repository.
Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on Hsu.Formats.Firmware:

Package Downloads
Hsu.Formats.Converters.Firmware

Firmware format converters for Hsu.Formats (S19↔HEX↔BIN, ELF→S19/HEX/BIN, MOT→BIN/HEX).

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
2026.7.13 148 7/13/2026
2026.5.11-preview.100100 73 5/11/2026
2026.5.7 147 5/7/2026
2026.4.20 158 4/20/2026