About this library

This .NET Standard 2.1 library will load, parse and compute statistics on an s-record file. It was implemented according to the documentation found in the Ubuntu srec manpage and the Wikipedia SREC (file format) article, as well as other random articles I found with Google searches. (They all ultimately pointed back to these two sources, or some derivation of them.)

Hold on, what’s an s-record file?

It’s a text file that has special lines within that have various binary data specially encoded as hexadecimal digits. Usually the data contained within is what’s called firmware. These types of files are used to load new instructions onto smart devices.

Because they’re text, it makes it possible for a person, tho not easy for a beginner, to read the file and determine if the contents look sufficiently valid.

An example file might look something like the following (taken from the wikipedia page.)

S00F000068656C6C6F202020202000003C
S11F00007C0802A6900100049421FFF07C6C1B787C8C23783C6000003863000026
S11F001C4BFFFFE5398000007D83637880010014382100107C0803A64E800020E9
S111003848656C6C6F20776F726C642E0A0042
S5030003F9
S9030000FC

As you can see each line starts with an S, hence the name s-record.

Uses for this library

  1. Performing a custom firmware upload to a device you’re making.
  2. With some custom logic validate that the file conforms to the S19, S28 or S37 formats. (Statistics classes enable much of this validation.)
  3. Strip out comments before sending the firmware through a stringent firmware uploader.
    • Yes, some people put comments in their s-record files. You’re right, the specification doesn’t mention comments, technically making them invalid. And from what I read they’re not at all consistent.
    • I’ve supported simple end of line comments as a matter of keeping things flexible for others who may not have the want to write their own parser so that their firmware uploader can process a file.
    • For C-style comments, those poor souls may still be able to leverage my SRecordDataParser class. But, they will still need to write custom code to parse those comments, per their own needs. To keep it integrated within this framework, implement ISRecordElementParser and use the custom implementation.

Repository

You can find the source code at: jason-c-daniels/Jcd.SRecord

Obtaining Copy

You can get a copy from nuget.org or your favorite package manager.

Tech Stack

  • OS: Debian 10 and Windows 10
  • Programming Language: C#
  • Editing Software: JetBrains Rider
  • Tool(s): dotnet
  • Version Control: the git command line and Rider IDE integration.