Optiboot / optiboot

Small and Fast Bootloader for Arduino and other Atmel AVR chips
Other
1.09k stars 401 forks source link

Optiboot grows bigger with (Arduino IDE) avr-gcc 7.3.0 #301

Open WestfW opened 3 years ago

WestfW commented 3 years ago

Compiled with the version of avr-gcc (7.3.0) distributed with recent Arduino IDEs (1.8.13), optiboot grows 14 bytes. The normal versions still fit in 512 bytes, but attempts to build a non-blinking, EEPROM-support version (documented as possible) fail...

The area of code growth is not obvious :-(

See https://github.com/Optiboot/optiboot/issues/300

 make GCCROOT=/Applications/Arduino-1.8.13.app/Contents/Java/portable/packages/arduino/tools/avr-gcc/7.3.0-atmel3.6.1-arduino5/bin/ atmega328
avr-gcc (GCC) 7.3.0

/Applications/Arduino-1.8.13.app/Contents/Java/portable/packages/arduino/tools/avr-gcc/7.3.0-atmel3.6.1-arduino5/bin/avr-gcc -g -Wall -Os -fno-split-wide-types -mrelax -mmcu=atmega328p -DF_CPU=16000000L  -DBAUD_RATE=115200 -DLED_START_FLASHES=3              -c -o optiboot.o optiboot.c

/Applications/Arduino-1.8.13.app/Contents/Java/portable/packages/arduino/tools/avr-gcc/7.3.0-atmel3.6.1-arduino5/bin/avr-gcc -g -Wall -Os -fno-split-wide-types -mrelax -mmcu=atmega328p -DF_CPU=16000000L  -DBAUD_RATE=115200 -DLED_START_FLASHES=3            -Wl,--section-start=.text=0x7e00 -Wl,--section-start=.version=0x7ffe -Wl,--relax -nostartfiles -o optiboot_atmega328.elf optiboot.o 
/Applications/Arduino-1.8.13.app/Contents/Java/portable/packages/arduino/tools/avr-gcc/7.3.0-atmel3.6.1-arduino5/bin/avr-size optiboot_atmega328.elf
   text    data     bss     dec     hex filename
    496       0       0     496     1f0 optiboot_atmega328.elf
 make atmega328
avr-gcc (AVR_8_bit_GNU_Toolchain_3.6.1_495) 5.4.0

avr-gcc -g -Wall -Os -fno-split-wide-types -mrelax -mmcu=atmega328p -DF_CPU=16000000L  -DBAUD_RATE=115200 -DLED_START_FLASHES=3              -c -o optiboot.o optiboot.c

avr-gcc -g -Wall -Os -fno-split-wide-types -mrelax -mmcu=atmega328p -DF_CPU=16000000L  -DBAUD_RATE=115200 -DLED_START_FLASHES=3            -Wl,--section-start=.text=0x7e00 -Wl,--section-start=.version=0x7ffe -Wl,--relax -nostartfiles -o optiboot_atmega328.elf optiboot.o 
avr-size optiboot_atmega328.elf
   text    data     bss     dec     hex filename
    482       0       0     482     1e2 optiboot_atmega328.elf
WestfW commented 3 years ago

Huh. optiboot_x SHRINKS by two bytes. Which is especially odd since it looks like the part of code that grows is NOT the actual flash writing (which is substantially different.)

WestfW commented 3 years ago

Not particularly useful, but...

avr-gcc 5.4:

00007fc0 00000020 t do_spm
00007fb2 0000000e t getNch
00007f7e 00000018 T getch
00007e04 0000016c T main
00007ffe 00000002 R optiboot_version
00007e00 00000004 T pre_main
00007f70 0000000e T putch
00007fa2 00000010 T verifySpace
00007f96 0000000c T watchdogConfig

avr-gcc 7.3.0:

00007fce 00000020 t do_spm
00007fc0 0000000e t getNch
00007f8c 00000018 T getch
00007e04 0000017a T main
00007ffe 00000002 R optiboot_version
00007e00 00000004 T pre_main
00007f7e 0000000e T putch
00007fb0 00000010 T verifySpace
00007fa4 0000000c T watchdogConfig
motolav commented 3 years ago

I ran "make atmega328p" with GCC 11.1.0 and it shrunk 2 bytes compared to your 7.3.0 GCC 12 will have the mode_cc changes to the AVR target, which is already in master

mcuee commented 1 year ago

Please refer to here as well.

avr-gcc 7.3.0 is always worse than avr-gcc 5.4.0 when compiling optiboot.

Screenshot 2022-12-10 201350