Search code examples
shellhexbinaryfiles

Read data at given address out of hex file using srec tools


I'm wondering if there is a way to read data out of a .hex file at a given address using the srec tool family like srec_cat or srec_info. I know that I could parse the file by myself but there must be a tool out there already. Does anyone have already done something similar?


Solution

  • Today I found a solution using srec_cat to write only part of the hex file to a binary output file.

    srec_cat.exe my.hex -intel -crop 0x08010000 0x08010040 -offset -0x08010000 -o out.bin -binary 
    

    The datasheet pointed out that is also possible to print the result to std:out. For me this is not working at all. Have no clue why.

    Output filename [ format ] This option may be used to specify the output file to be used. The special file name “−[rq] is understood to mean the standard output. Output defaults to the standard output if this option is not used.

    What do I have to write to use this functionality:

    srec_cat.exe my.hex -intel -crop 0x08010000 0x08010040 -offset -0x08010000 -o -[rq] -binary 
    

    Anyway the workaround with the file is working as expected. Without the file step would be a nice add on.