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-unfillfilter.srec_examples(1)β has a section about binary files, and ways of automagically offseting the data back to zero in a single command. iykyk β¨
Β©οΈ COPYRIGHT Β©οΈ
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
- opensuse-leap 16.0: srecord 1.65.0-bp160.1.12 Β· GPL-3.0-or-later
- opensuse-leap 16.0: srecord 1.65.0-bp160.1.12 Β· GPL-3.0-or-later
- opensuse-leap 16.0: srecord 1.65.0-bp160.1.12 Β· GPL-3.0-or-later
- opensuse-leap 16.0: srecord 1.65.0-bp160.1.12 Β· GPL-3.0-or-later
- Copyright (C) 2007-2009, 2011 Peter Miller
- Copyright (C) 1998, 2006-2009, 2014 Peter Miller
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms