Skip to content

.hex file with bootloader is incorrect for ATmega2560 targets (Arduino Mega2560) #2842

Closed
marcinbor85/gohex
#2
@WestfW

Description

@WestfW

the .ino.with_bootloader.hex file produced for ATmega2560 targets (and prrobably any AVR target with more than 64k flash) is missing the "extended segment address" entry, so the bootloader ends up positioned at 64k-8k, instead of 256k-8k.

Note the VMA address (0xe000), which should be 0x3e00)

avr-objdump -x /tmp/Arduino1.8.13Build/Blink.ino.with_bootloader.hex   

/tmp/Arduino1.8.13Build/Blink.ino.with_bootloader.hex:     file format ihex
/tmp/Arduino1.8.13Build/Blink.ino.with_bootloader.hex
architecture: UNKNOWN!, flags 0x00000000:

start address 0x00000000

Sections:
Idx Name          Size      VMA       LMA       File off  Algn
  0 .sec1         00000600  00000000  00000000  00000010  2**0
                  CONTENTS, ALLOC, LOAD
  1 .sec2         00001d1e  0000e000  0000e000  00001090  2**0
                  CONTENTS, ALLOC, LOAD

And here's that section of the .hex file:

:1005C000F894EC91E22BEC938FBFC0E0D0E081E097
:1005D0000E942D010E94DA0180E00E942D010E94FC
:1005E000DA012097A1F30E940000F1CFEE0FFF1F68
:1005F000881F8BBF0790F691E02D1994F894FFCFD8      ;; last code from sketch
:10E000000D9489F10D94B2F10D94B2F10D94B2F129     ;; first code from bootloader
:10E010000D94B2F10D94B2F10D94B2F10D94B2F1F0
:10E020000D94B2F10D94B2F10D94B2F10D94B2F1E0

It should look like:

:1005C000F894EC91E22BEC938FBFC0E0D0E081E097
:1005D0000E942D010E94DA0180E00E942D010E94FC
:1005E000DA012097A1F30E940000F1CFEE0FFF1F68
:1005F000881F8BBF0790F691E02D1994F894FFCFD8      ;; last code from sketch
:020000023000CC
:10E000000D9489F10D94B2F10D94B2F10D94B2F129     ;; first code from bootloader
:10E010000D94B2F10D94B2F10D94B2F10D94B2F1F0
:10E020000D94B2F10D94B2F10D94B2F10D94B2F1E0

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions