srec_binary(5)

πŸŽ€ NAME πŸŽ€

srec_binary β€” binary file format. bestie, this is the srec_binary(5) page, and it lives in the File Formats Manual section. buckle up 🫢

✨ DESCRIPTION ✨

okay so literally: yes, you can read and write binary files using srec_cat(1). That's the whole plot, but the details are lowkey important.

πŸ•³οΈ File Holes πŸ•³οΈ

a file hole is basically a chunk of a regular file that contains NUL characters and is not stored in any data block on disk. Holes are a long-standing feature of Unix files, no cap.

for instance, this Unix command creates a file where the first bytes are a hole:

$ echo -n "X" | dd of=/tmp/hole bs=1024 seek=6
$

Now /tmp/hole has 6,145 characters (6,144 NUL characters plus an X character), yet the file occupies just one data block on disk. iconic behavior, honestly ✨

File holes exist so we don't waste disk space. Database applications use them extensively, and more generally so does every application that performs hashing on files.

want more lore? See http://www.oreilly.com/catalog/linuxkernel2/chapter/ch17.pdf for more information.

πŸ“– Reading πŸ“–

binary files get their size from the size of the file on the file system.

If the file has holes, those read back as blocks of NUL (zero) data, because there is no elegant way to detect Unix file holes. In general, you probably want to use the -unfill filter to find and remove large swathes of zero bytes. yes bestie, -unfill is the moment πŸ’…

✍️ Writing ✍️

when srec_cat(1) produces a binary file, it honours the address information and places the data into the binary file at the addresses specified in the hex file. This usually results in holes in the file. Sometimes the reported file size is alarmingly large as a result. not me gasping at the file size 😭

If you are on a brain-dead operating system without file holes, then those are real data blocks containing real zero bytes, and they consume real amounts of disk space. Upgrade - I suggest Linux. periodt.

To make a file of the size you expect, use

srec_info foo.s19

to find the lowest address, then use

srec_cat foo.s19 -intel -offset -n -o foo.bin -binary

where n is the lowest address present in the foo.s19 file, as reported by srec_info(1). The negative offset serves to move the data down to have an origin of zero. slay πŸ”₯

πŸ‘€ SEE ALSO πŸ‘€

  • srec_input(1) β€” for a description of the -unfill filter.
  • srec_examples(1) β€” has a section about binary files, and ways of automagically offseting the data back to zero in a single command. iykyk ✨

okay legal bestie moment: SRrecord version 1.65, and Copyright (C) 1998... Peter Miller.

The SRrecord program comes with ABSOLUTELY NO WARRANTY; for the details, use the SRrecord -VERSion License command. This is free software and you are welcome to redistribute it under certain conditions; for those details, use the SRrecord -VERSion License command.

🫢 MAINTAINER 🫢

  • Scott Finneran β€” E-Mail: scottfinneran@yahoo.com.au
  • Peter Miller β€” E-Mail: pmiller@opensource.org.au

Reference Manual Β· SRecord version 1.65 Β· srec_binary(5) β€” the footer didn't give us a date, so this is the cute sign-off instead πŸŽ€βœ¨πŸ’…

πŸ“¦ where this page comes from