how to insert value in hex file using srec_cat

2.6k Views Asked by At

I have a value say 0xAABBCCDD that I want to add to a hex file at a known address. I have not found an srec_cat option to do this yet, is this possible?

1

There are 1 best solutions below

0
ReAl On

It is possible by combination of srec_cat commands. Let in.hex be input file, out.hex be output file, 0x64 is the address to place 4-byte value so that the value will occupy addresses from 0x64 to 0x67 (0x68 is the first address after the value).

srec_cat in.hex -I -E 0x64 0x68 -GEN 0x64 0x68 -LECONST 0xAABBCCDD 4 -O out.hex -I

Step by step:

in.hex -I

read input file in.hex, format Intel hex

-E 0x64 0x68

apply filter Exclude—remove (if any) data in range 64 (including) — 0x68 (excluding)

-GEN 0x64 0x68

GENerate content for address range 0x64 (including) — 0x68 (excluding)

-LECONST 0xAABBCCDD 4

the content is Little Endian CONSTant 0xAABBCCDD with width 4 bytes.

-O out.hex -I

write Out result data.

p.s. See srec_cat and srec_input (for filter description)