Skip to content

Improper handling of HEX file with non-contiguous addresses or type 03 records. #13

@david-nc

Description

@david-nc

The current optiboot file for the arduino UNO, optiboot_atmega328.hex, ends with the following lines:

:107FE0001150E9F7F2DF1F91089580E0E8DFEE27F6
:047FF000FF270994CA
:027FFE00040479
:0400000300007E007B
:00000001FF

The standalone programmer sketch does not properly handle the skipped addressed between 7FF5 and 7FFE, instead placing the 0x04 0x04 that should be at address 7FFE immediately after the code from the previous line, resulting in a verify error. The sketch also does not handle the type 03 record in the following line (this was mentioned in a previously issue that has been closed for some time, but never corrected).

This can be corrected by checking the address specified in the HEX file against the current write address, and skipping forward until the correct address is reached, leaving the skipped addresses set as the default 0xFF. Note that this does requires that addresses in the HEX file be sequential.

The issue with the type 03 record can be corrected by testing for the record type, and if the record type is 03 reading in the record, but ignoring the date contained within the record.

All code modification are to the code.cpp file, diff output contained in the attached file (note - code.cpp was auto-formatted in Arduino IDE before making changes).
code_cpp_diff.txt

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions