Record break in avr-objcopy using gap-fill

66 Views Asked by At

I'm using avr-objcopy to join multple sections to get one binary, that will be programmed to flash.

    avr-objcopy --gap-fill 0xFF -j .section1 -j .section2 -O ihex main.elf main.hex

I get HEX file that contains such lines (spaces added for readability):

    ...
    :10 0A60 00 4583932B909592239627968340815181 BD
    :10 0A70 00 628173814D935D936D937C931397DF91 A6
    :0C 0A80 00 CF911F910F91FF90EF900895 0F
    :10 0A8C 00 FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF 6A
    :10 0A9C 00 FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF 5A
    ...

As you can notice, filled auto-generated records are not 16-byte aligned (here starts with 0x0A8C). Programming software adds it's own padding to each record, so that record is placed to page with start address 0x0A80, while bytes before 0x0A8C are FF-filled. That leads to programming error.

While i export to binary instead of ihex everything is OK, but i want to use HEX.

I've noticed that such problem can be solved using secondary conversion:

    avr-objcopy -I ihex -O ihex main.hex main2.hex

That leads to hex file with such lines:

    :10 0A60 00 4583932B909592239627968340815181 BD
    :10 0A70 00 628173814D935D936D937C931397DF91 A6
    :10 0A80 00 CF911F910F91FF90EF900895FFFFFFFF 0F
    :10 0A90 00 FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF 66
    :10 0AA0 00 FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF 56

Is there any key to merge records without second conversion?

0

There are 0 best solutions below