ATMEGA2560 bootloader compilation under Eclipse: content and size differents

Hi,

I want to build the bootloader sources for ATMEGA2560; so I got back the sources under /stk500v2/ folder in bootloaders folder.
I create Eclipse project with AVR setting, etc. I got back the compiler and linker options from makefile file under /stk500v2/ to set C/C++ setting. However the .hex file generated is different with the orginal stk500boot_v2_mega2560.hex. It's bigger. I can't understand why.

This is some Eclipse messages in the console view:

Building file: ../src/stk500boot.c
Invoking: AVR Compiler
avr-gcc -w -Os -fpack-struct -fshort-enums -fno-jump-tables -std=gnu99 -funsigned-char -funsigned-bitfields -Wstrict-prototypes -Wa,-adhlns=../src/stk500boot.lst -mmcu=atmega2560 -DF_CPU=16000000UL -MMD -MP -MF"src/stk500boot.d" -MT"src/stk500boot.d" -c -o "src/stk500boot.o" "../src/stk500boot.c"
Finished building: ../src/stk500boot.c

Building target: kelvin_bootloader_atmega2560.elf
Invoking: AVR C++ Linker
avr-g++ -Wl,-Map,kelvin_bootloader_atmega2560.map,--cref -Wl,-Map=kelvin_bootloader_atmega2560.map,--cref -lm -Wl,--section-start=.text=3E000 -mmcu=atmega2560 -o "kelvin_bootloader_atmega2560.elf" ./src/stk500boot.o
Finished building target: kelvin_bootloader_atmega2560.elf

Invoking: AVR Create Extended Listing
avr-objdump -h -S kelvin_bootloader_atmega2560.elf >"kelvin_bootloader_atmega2560.lss"
Finished building: kelvin_bootloader_atmega2560.lss

Create Flash image (ihex format)
avr-objcopy -R .eeprom -R .fuse -R .lock -R .signature -O ihex kelvin_bootloader_atmega2560.elf "kelvin_bootloader_atmega2560.hex"
Finished building: kelvin_bootloader_atmega2560.hex

I attached the original bootloader file and the mine generated.

Thank you for your help guys !

Anthony

kelvin_bootloader_atmega2560.hex (25.2 KB)

stk500boot_v2_mega2560.hex (20.5 KB)

It can be caused by different version of compiler, libraries etc. and it may not be a problem.
Is it working ?

I don't know yet coz I'm waiting a capacity for my Arduino UNO (it's my ICSP !). I let you know about this.

Another question: I read the max size for the bootloader (for ATMEGA2560) is 8KBytes. But the orginal I build is arround 9KBytes. And I must to implement some functionnalities (read .hex from the SDCard then flash this new firmware). Is it possible to burn a new bootloader with the size up to 8Kbytes ?

Thank you!

Is it possible to burn a new bootloader with the size up to 8Kbytes ?

Up to 8k yes!
Didi you mean over 8k, isn't it?
Then answer is no. ATmega2560 has maximum bootsize 4096 words.

Thanks :slight_smile:

Ok I set this define ENABLE_MONITOR to undef, and the new .hex size is arround 4kBytes, so it's perfect :slight_smile: