eerimoq / bincopy

Mangling of various file formats that conveys binary information (Motorola S-Record, Intel HEX, TI-TXT, Verilog VMEM, ELF and binary files).
MIT License
109 stars 38 forks source link

Do we have function like change s19 content? #34

Closed 123zmz123 closed 1 year ago

123zmz123 commented 1 year ago

Hello thanks for your great job, we already use bincopy in our projects. it works very well! my question were do we have a function that can change the content in a specific address, and update to a new s19 file for example old S32580040320FFFFFFFF0000100000010000000000000000000000000000000000000000000026 new S32580040320FFFFFFFF00001000000FFFF000000000000000000000000000000000000000003C hope your respond.

eerimoq commented 1 year ago

You can do from a Python script. Not sure if it is possible from the command line. How do you use bincopy?

123zmz123 commented 1 year ago

sorry for the late response. we use it from script like import bincopy and do something fun, now we want to use bincopy read a s19 file and change some content like in address 0x8008001 change 4 byte from 0xff 0xff 0xff 0xff to 0x4A 0x5A 0x1D 0x1C and save as a new file I try to use the tutorial and there are no hint about how to do this kind of stuff. can you give me a hint? best regard.

eerimoq commented 1 year ago

Something like this?

import bincopy

bf = bincopy.BinFile()
bf.add_srec('S32580040320FFFFFFFF0000100000010000000000000000000000000000000000000000000026')
bf.add_binary(b'\x0f\xff\xf0', 0x80040329, overwrite=True)
print(bf.as_srec(), end='')
123zmz123 commented 1 year ago

got it, I will try, because I try to search some function with key word like change modify ......