MCUdude / optiboot_flash

Optiboot subtree for MightyCore, MegaCore, MiniCore and MajorCore
56 stars 57 forks source link

Fix Error compiling bootloader with -DBIGBOOT option #1

Closed vanbwodonk closed 6 years ago

MCUdude commented 7 years ago

I'm not sure about this. Got this error when testing this on ATmega128.

#ATmega128/A
atmega128: MCU_TARGET = atmega128
atmega128: CFLAGS += $(COMMON_OPTIONS) -DBIGBOOT $(UART_CMD)
atmega128: LIBS += -latmega128
atmega128: AVR_FREQ ?= 16000000L
atmega128: LDSECTIONS = -Wl,--section-start=.text=0x1fc00 -Wl,--section-start=.version=0x1fffe
atmega128: atmega128/$(PROGRAM)_atmega128_$(BAUD_RATE)_$(AVR_FREQ).hex
atmega128: atmega128/$(PROGRAM)_atmega128_$(BAUD_RATE)_$(AVR_FREQ).lst
atmega128a: atmega128
$ make atmega128 AVR_FREQ=16000000L BAUD_RATE=1000000 UART=0 LED=B5 LED_START_FLASHES=2 -BIGBOOT
avr-gcc (GCC) 4.9.3
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

BAUD RATE CHECK: Desired: 1000000, Real: 1000000, UBRRL = 1, Error=0.0%
avr-gcc -g -Wall -Os -fno-split-wide-types -mrelax -mmcu=atmega128 -DF_CPU=16000000L  -DBAUD_RATE=1000000 -DLED_START_FLASHES=2    -DLED=B5  -DBIGBOOT -DUART=0   -c -o optiboot_flash.o optiboot_flash.c
avr-gcc -g -Wall -Os -fno-split-wide-types -mrelax -mmcu=atmega128 -DF_CPU=16000000L  -DBAUD_RATE=1000000 -DLED_START_FLASHES=2    -DLED=B5  -DBIGBOOT -DUART=0 -Wl,--section-start=.text=0x1fc00 -Wl,--section-start=.version=0x1fffe -Wl,--relax -nostartfiles -nostdlib -o atmega128/optiboot_flash_atmega128_1000000_16000000L.elf optiboot_flash.o -lc -latmega128
/usr/local/opt/avr-binutils/bin/avr-ld: cannot find -latmega128
collect2: error: ld returned 1 exit status
make: *** [atmega128/optiboot_flash_atmega128_1000000_16000000L.elf] Error 1
rm optiboot_flash.o
vanbwodonk commented 7 years ago

Strange, but you used avr-gcc 4.9.3. I compiled under linux/ubuntu with 4.9.2 version. Can you compile your repo with 4.9.3 without my makefile patch?

make atmega128 AVR_FREQ=16000000L BAUD_RATE=1000000 UART=0 LED=B5 LED_START_FLASHES=2 -BIGBOOT
avr-gcc (GCC) 4.9.2
Copyright (C) 2014 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

BAUD RATE CHECK: Desired: 1000000, Real: 1000000, UBRRL = 1, Error=0.0%
avr-gcc -g -Wall -Os -fno-split-wide-types -mrelax -mmcu=atmega128 -DF_CPU=16000000L  -DBAUD_RATE=1000000 -DLED_START_FLASHES=2    -DLED=B5  -DBIGBOOT -DUART=0   -c -o optiboot_flash.o optiboot_flash.c
avr-gcc -g -Wall -Os -fno-split-wide-types -mrelax -mmcu=atmega128 -DF_CPU=16000000L  -DBAUD_RATE=1000000 -DLED_START_FLASHES=2    -DLED=B5  -DBIGBOOT -DUART=0 -Wl,--section-start=.text=0x1fc00 -Wl,--section-start=.version=0x1fffe -Wl,--relax -nostartfiles -nostdlib -o atmega128/optiboot_flash_atmega128_1000000_16000000L.elf optiboot_flash.o -lc -latmega128 
avr-size atmega128/optiboot_flash_atmega128_1000000_16000000L.elf
   text    data     bss     dec     hex filename
    648       0       0     648     288 atmega128/optiboot_flash_atmega128_1000000_16000000L.elf
avr-objcopy -j .text -j .data -j .version --set-section-flags .version=alloc,load -O ihex atmega128/optiboot_flash_atmega128_1000000_16000000L.elf atmega128/optiboot_flash_atmega128_1000000_16000000L.hex
avr-objdump -h -S atmega128/optiboot_flash_atmega128_1000000_16000000L.elf > atmega128/optiboot_flash_atmega128_1000000_16000000L.lst
rm atmega128/optiboot_flash_atmega128_1000000_16000000L.elf optiboot_flash.o
MCUdude commented 7 years ago

Can you compile your repo with 4.9.3 without my makefile patch?

Yes, it compiles just fine without the patch

$ make atmega128 AVR_FREQ=16000000L BAUD_RATE=1000000 UART=0 LED=B5 LED_START_FLASHES=2 -BIGBOOT
avr-gcc (GCC) 4.9.3
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

BAUD RATE CHECK: Desired: 1000000, Real: 1000000, UBRRL = 1, Error=0.0%
avr-gcc -g -Wall -Os -fno-split-wide-types -mrelax -mmcu=atmega128 -DF_CPU=16000000L  -DBAUD_RATE=1000000 -DLED_START_FLASHES=2    -DLED=B5  -DBIGBOOT -DUART=0   -c -o optiboot_flash.o optiboot_flash.c
avr-gcc -g -Wall -Os -fno-split-wide-types -mrelax -mmcu=atmega128 -DF_CPU=16000000L  -DBAUD_RATE=1000000 -DLED_START_FLASHES=2    -DLED=B5  -DBIGBOOT -DUART=0 -Wl,--section-start=.text=0x1fc00 -Wl,--section-start=.version=0x1fffe -Wl,--relax -nostartfiles -nostdlib -o atmega128/optiboot_flash_atmega128_1000000_16000000L.elf optiboot_flash.o -lc
avr-size atmega128/optiboot_flash_atmega128_1000000_16000000L.elf
   text    data     bss     dec     hex filename
    648       0       0     648     288 atmega128/optiboot_flash_atmega128_1000000_16000000L.elf
avr-objcopy -j .text -j .data -j .version --set-section-flags .version=alloc,load -O ihex atmega128/optiboot_flash_atmega128_1000000_16000000L.elf atmega128/optiboot_flash_atmega128_1000000_16000000L.hex
avr-objdump -h -S atmega128/optiboot_flash_atmega128_1000000_16000000L.elf > atmega128/optiboot_flash_atmega128_1000000_16000000L.lst
rm atmega128/optiboot_flash_atmega128_1000000_16000000L.elf optiboot_flash.o

I've compiled optiboot_flash with the BIGBOOT flag enabled with avr-gcc 4.9.2 without any errors before

vanbwodonk commented 7 years ago

What version of avr-libc do you use?

MCUdude commented 7 years ago

I'm using avr-libc 2.0.0

MCUdude commented 6 years ago

I updated my toolchain, and suddenly this patch were needed. I manually corrected it along with a bunch of other fixes, so it's not necessary to merge this.

Anyways thanks for bringing a proper solution! 👍