Closed noahp closed 3 years ago
Why do you need such behavior?
In my use case, I'm writing hex data into a flash chip and it's useful to not have to handle the scenario where flash address decrements. I added this option to use in a build check to ensure the generated hex files won't have non-monotonically-incrementing addresses, and figured I'd offer it here if there's any interest!
In my use case, I'm writing hex data into a flash chip and it's useful to not have to handle the scenario where flash address decrements. I added this option to use in a build check to ensure the generated hex files won't have non-monotonically-incrementing addresses, and figured I'd offer it here if there's any interest!
I don't really understand. Are you send hex file "as is" into your firmware?
No worries, I decided to hack it at runtime like this instead:
from collections import OrderedDict
ih = IntelHex()
ih._buf = OrderedDict()
ih.loadhex(filename)
lastaddr = None
for addr in ih._buf:
assert (
(lastaddr is None) or (addr > lastaddr)
), "Error decrementing address at 0x{:x}".format(addr)
lastaddr = addr
Closing!
Add an option to enforce strictly monotonically incrementing addresses when loading a hex file.
Added example bad file, added
--strict
option to thehex_info.py
script to enable the option, which will stacktrace on error: