2015-09-12 44 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版本,会很有趣。 –