2015-09-12 21 views
0

我想修改Arduino Uno的引導程序(optiboot),以便將上傳命令超時從1秒增加到8秒。所以我需要重新編譯引導程序並上傳它。avr-gcc編譯過大optiboot十六進制來適應

我能夠代替不贊成使用「-mshort通話」到「-mrelax」,我可以編譯它,但它會產生過大的二進制:

MBA-Anton:optiboot asmirnov$ make atmega328 
../../../../tools/avr/bin/avr-gcc -g -Wall -Os -fno-inline-small-functions -fno-split-wide-types -mrelax -fno-move-loop-invariants -mmcu=atmega328p -DF_CPU=16000000L -mrelax '-DLED_START_FLASHES=3' '-DBAUD_RATE=115200' -c -o optiboot.o optiboot.c 
../../../../tools/avr/bin/avr-gcc -g -Wall -Os -fno-inline-small-functions -fno-split-wide-types -mrelax -fno-move-loop-invariants -mmcu=atmega328p -DF_CPU=16000000L -mrelax '-DLED_START_FLASHES=3' '-DBAUD_RATE=115200' -Wl,--section-start=.text=0x7e00 -Wl,--section-start=.version=0x7ffe -Wl,--relax -Wl,--gc-sections -nostartfiles -nostdlib -o optiboot_atmega328.elf optiboot.o 
../../../../tools/avr/bin/avr-size optiboot_atmega328.elf 
    text data  bss  dec  hex filename 
    530  0  0  530  212 optiboot_atmega328.elf 
../../../../tools/avr/bin/avr-objcopy -j .text -j .data -j .version --set-section-flags .version=alloc,load -O ihex optiboot_atmega328.elf optiboot_atmega328.hex 
../../../../tools/avr/bin/avr-objdump -h -S optiboot_atmega328.elf > optiboot_atmega328.lst 
rm optiboot.o optiboot_atmega328.elf 

AVR-gcc版本:

MBA-Anton:optiboot asmirnov$ ../../../../tools/avr/bin/avr-gcc --version 
avr-gcc (GCC) 4.8.1 
Copyright (C) 2013 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. 

MBA-Anton:optiboot asmirnov$ 

我GOOGLE了更多,我發現漂亮的same config產生更小的二進制文件,所以怎麼了?

回答

0

使用很老的(2012年)AVR-GCC從here

+1

你嘗試用'-ffunction-sections'和'-fdata-sections'編譯解決了嗎?當用'--gc-sections'鏈接時,應該刪除未使用的部分。 –

+0

我沒有試過 – 4ntoine

+0

如果這有助於當前的GCC版本,會很有趣。 –