S→01

PRIVATE BROWSER TOOL

Convert Motorola S-record to binary

All data records are mapped by absolute address before conversion. The reported base address is required when programming the raw binary.

01

Inputs

● Local processing — this file never leaves your browser.
02

Results

S→01

Run the tool to see a structured report here.

ON THIS DEVICE

Recent history

Your latest 10 runs will appear here on this device.

HOW IT WORKS

Method and formulas

S1, S2 and S3 record data is assembled at its absolute addresses. Unmapped positions between minimum and maximum addresses receive the chosen fill value.

Accuracy note

Always compare generated firmware with the target device’s memory map, linker output and programming documentation before flashing.

GUIDE

What This Tool Does and When to Use It

The SREC to BIN converter assembles Motorola S-record files (S19, S28, S37 or MOT) into a single contiguous binary image. It reads S1, S2 and S3 data records, places each byte at its absolute address, and fills any gaps between the lowest and highest addresses with a user-specified value. The resulting BIN file is suitable for direct flashing to microcontrollers, EEPROM programmers or bootloaders that expect raw binary rather than record-based formats.

Engineers use this conversion when migrating legacy firmware from development tools that output SREC into production programmers that accept only BIN images. The process preserves exact address mapping while removing record overhead, checksums and type indicators. Because all parsing occurs inside the browser, no firmware data leaves the local machine. The converter supports mixed record types within one file and automatically determines address width from the record type byte. Output files contain no metadata, allowing immediate use with flash utilities that perform sector erases before programming.

Worked Example with Realistic Numbers

Consider a 16 KiB flash region starting at 0x0000. An SREC file contains three S1 records: S11300004142434445464748494A4B4C4D4E4F50 followed by S11300105152535455565758595A5B5C5D5E5F60 and S11300206162636465666768696A6B6C6D6E6F70. After conversion with base address 0x0000 and fill value 0xFF, the output BIN contains the three 16-byte blocks at offsets 0x0000, 0x0010 and 0x0020. All remaining 16256 bytes are set to 0xFF.

RecordAddressData LengthFirst ByteLast Byte
S10x0000160x410x50
S10x0010160x510x60
S10x0020160x610x70

The minimum address detected is 0x0000 and the maximum is 0x002F, producing a 48-byte image before gap filling expands it to the full 16384 bytes when a higher end address is supplied.

Second Worked Example

A second file mixes S2 and S3 records targeting a 32-bit address space for a larger microcontroller. Records begin at 0x08000000 with 24 bytes of data, followed by an S3 record at 0x08001000 containing 32 bytes. Using fill value 0x00 and no explicit base address yields a 4097-byte image. When an end address of 0x08002000 is supplied, the output grows to 8192 bytes with all unmapped locations set to zero. This demonstrates how explicit bounds control final size for bootloaders that validate fixed-length images.

Formula and Method Table

Output size = (max address − min address) + 1. Each unmapped byte receives the chosen fill value. Address ranges are calculated from the 16-bit, 24-bit or 32-bit fields inside S1, S2 and S3 records respectively.
InputUnitOutputUnit
S1/S2/S3 address fieldhexadecimalbyte offset in BINdecimal
Record data bytes0–255binary image bytes0–255
Gap fill value0–255unmapped positions0–255
Explicit base addresshexadecimalstarting offsetdecimal
Explicit end addresshexadecimalfinal image lengthdecimal bytes
Record countintegerprocessed data bytesdecimal

Units and Conversions Notes

S-record addresses are always expressed in hexadecimal. The converter interprets S1 addresses as 16-bit, S2 as 24-bit and S3 as 32-bit values. Resulting BIN offsets remain byte-granular; no scaling or endian conversion is applied to the payload. When an explicit base address lower than the first record address is supplied, leading bytes are filled with the gap value. File length is reported in decimal bytes while addresses continue to display in hexadecimal for readability with common memory-map documentation. Hexadecimal input accepts both uppercase and lowercase digits; output addresses in diagnostic messages use lowercase for consistency with most debugger output.

Limitations

The tool rejects files containing S4, S5, S6, S7, S8 or S9 termination records that carry no data. Overlapping address ranges produce an error rather than merging data. Maximum supported address span is 32 MiB to keep browser memory usage reasonable. S0 header records are ignored and never influence the output image. No automatic padding to power-of-two boundaries occurs; the user must supply an explicit end address if a larger image is required. Files exceeding 50 000 records are rejected to prevent excessive processing time in the browser. Only printable ASCII characters are accepted; binary or UTF-8 content triggers an immediate parse error. Address arithmetic uses 32-bit unsigned integers, so addresses above 0xFFFFFFFF are unsupported.

Common Mistakes

  • Users frequently forget to set the gap fill value when the target device requires erased flash to read as 0xFF instead of 0x00.
  • Another frequent error is supplying an SREC that contains only S0 and S9 records, resulting in an empty output.
  • Selecting an explicit base address higher than existing record addresses truncates lower data without warning.
  • Omitting the end address leaves the image size equal only to the span of populated records, which may be too small for certain bootloaders expecting a fixed-length binary.
  • Submitting a file with duplicate addresses in separate records triggers an overlap error instead of last-write-wins behavior.
  • Using a fill value outside 0–255 (for example entering 0x100) causes the converter to reject the parameter silently and default to 0xFF.
  • Assuming the converter will automatically detect and apply the correct address width when mixing S1 and S3 records in one file leads to incorrect placement of higher-address data.

LONG-FORM ANSWERS

Frequently asked questions

How are overlapping S1 records at the same address resolved during conversion?

The converter reports an error and refuses to produce output when any two data records target the identical byte address. This prevents silent corruption of firmware images that may have been generated by separate build steps.

What happens to S0 header information containing part numbers or dates?

S0 records are parsed only for validation and then discarded. No header text is written into the binary image or stored as metadata in the resulting BIN file.

Can the tool produce a BIN larger than the highest address present in the SREC?

Yes. Supply an explicit end address in the options panel. All bytes between the highest record address and the chosen end address receive the selected gap fill value.

Which checksum algorithm is used to validate each S-record before conversion?

The standard Motorola one’s-complement checksum is verified on every record. Records failing this check are rejected and the conversion aborts with the record number reported.

How does the converter treat 24-bit S2 addresses when the target microcontroller uses a 32-bit memory map?

S2 addresses are zero-extended to 32 bits. The upper byte remains zero unless an explicit base address offset is added by the user.

What is the maximum number of records the browser-based parser will accept before memory limits are reached?

Approximately 250 000 records can be processed before typical browser heap limits are approached, corresponding to roughly 4 MiB of payload data.

Does the output BIN preserve the original S-record line endings or record order?

No. The binary image contains only the assembled data bytes. Record order and line-ending characters are irrelevant to the final contiguous file.

How should gap fill be chosen for NOR flash that erases to all ones?

Set the gap fill value to 0xFF. This matches the erased state of most NOR devices and avoids programming unnecessary bytes during subsequent flashing operations.