Hsu.Formats.Firmware
2026.5.7
.NET 8.0
This package targets .NET 8.0. The package is compatible with this framework or higher.
.NET Standard 2.0
This package targets .NET Standard 2.0. The package is compatible with this framework or higher.
There is a newer version of this package available.
See the version list below for details.
See the version list below for details.
dotnet add package Hsu.Formats.Firmware --version 2026.5.7
NuGet\Install-Package Hsu.Formats.Firmware -Version 2026.5.7
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.5.7" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Hsu.Formats.Firmware" Version="2026.5.7" />
<PackageReference Include="Hsu.Formats.Firmware" />
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.5.7
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Hsu.Formats.Firmware, 2026.5.7"
#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.5.7
#: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.5.7
#tool nuget:?package=Hsu.Formats.Firmware&version=2026.5.7
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
Hsu.Formats.Firmware
Firmware and memory-image format support for the Hsu.Formats library.
Supported Formats
| Format | Extension | Description |
|---|---|---|
| Intel HEX | .hex .ihex |
Record types 00–05, extended linear address, start linear address |
| Motorola S-record | .s19 .srec |
S0–S9 record types, S1/S2/S3 data widths, start address |
| Motorola MOT | .mot |
S-record variant with selectable address width |
| Raw Binary | .bin |
Configurable base address, gap fill byte |
| ELF | .elf |
ELF32 and ELF64, little- and big-endian |
| VBF | .vbf |
Volvo Binary Format |
Features
- AOT-compatible (
IsAotCompatible=trueon net8.0+) HexModel,S19Model,MotModel,BinModel,ElfModel,VbfModelall implementIMemoryImage- Each format ships a dedicated
*Parser(all implementIAsyncFormatParser) and*Writer HexModel.StartLinearAddresspreserves the execution start address through conversionsS19Model/MotModelcarry address-width metadata (16 / 24 / 32-bit)MemorySegmentboundaries are preserved — adjacent segments are never silently mergedPartitionTransferHelper— splits firmware images into fixed-sizeTransferBlockobjects for UDS (ISO 14229 RequestDownload/TransferData) or CCP/XCP transmission workflows; supports address-range filtering, fill-byte padding, and re-assembly viaMergePartitions
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");
Console.WriteLine($"Start linear address: 0x{model.StartLinearAddress:X8}");
Parse a Motorola S-record file
using Hsu.Formats.S19;
using var stream = File.OpenRead("firmware.s19");
var model = (S19Model)new S19Parser().Parse(stream);
foreach (var seg in model.Segments)
Console.WriteLine($"0x{seg.Address:X8} {seg.Data.Length} bytes");
Write Intel HEX
using Hsu.Formats.Hex;
using var writer = new StreamWriter("out.hex");
new HexWriter().Write(model, writer);
Write raw binary (gaps filled with 0xFF)
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");
Split firmware into UDS transfer blocks
using Hsu.Formats.Hex;
using Hsu.Formats;
using var stream = File.OpenRead("firmware.hex");
var model = (HexModel)new HexParser().Parse(stream);
// Split the entire image into 1 KB transfer blocks (0xFF-filled padding on last block)
var blocks = PartitionTransferHelper.SplitImage(model, blockSize: 1024);
foreach (var block in blocks)
{
Console.WriteLine(
$" Block {block.BlockIndex + 1}/{block.TotalBlocks} " +
$"addr=0x{block.Address:X8} len={block.Data.Length}");
// → send block.Data via UDS RequestDownload / TransferData
}
Select specific partitions and split
// Select only the application partition (0x08008000–0x080FFFFF)
var partitions = PartitionTransferHelper.SelectPartitions(
model,
[(0x0800_8000L, 0x0810_0000L)]);
foreach (var seg in partitions)
{
var blocks = PartitionTransferHelper.SplitPartition(seg, blockSize: 512);
// transmit blocks …
}
Reassemble transfer blocks after download
// Receive blocks back from the ECU and verify
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 and support cancellable, non-blocking parsing.
Text-based formats (HEX, S19, MOT) use ReadLineAsync for line-by-line async I/O; binary formats
(ELF, VBF, BIN) offload parsing to the thread pool via Task.Run.
using Hsu.Formats.Hex;
using Hsu.Formats.S19;
using Hsu.Formats.Elf;
// Intel HEX — async line-by-line I/O
using var stream = File.OpenRead("firmware.hex");
var model = (HexModel)await new HexParser().ParseAsync(stream);
// S-record — async line-by-line I/O (CancellationToken supported)
using var cts = new CancellationTokenSource(TimeSpan.FromSeconds(30));
using var s19Stream = File.OpenRead("firmware.s19");
var s19Model = (S19Model)await new S19Parser().ParseAsync(s19Stream, cts.Token);
// ELF — offloads to thread pool
using var elfStream = File.OpenRead("firmware.elf");
var elfModel = (ElfModel)await new ElfParser().ParseAsync(elfStream);
| Product | Versions 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.
-
.NETStandard 2.0
- Hsu.Formats.Abstractions (>= 2026.5.7)
-
net8.0
- Hsu.Formats.Abstractions (>= 2026.5.7)
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 | 211 | 7/13/2026 |
| 2026.5.11-preview.100100 | 91 | 5/11/2026 |
| 2026.5.7 | 163 | 5/7/2026 |
| 2026.4.20 | 171 | 4/20/2026 |