http://code.google.com/p/arduino/issues/detail?id=487
a couple of people are interested in changing or patching the optiboot version that comes with the arduino IDE, but are distressed by the apparent need to install a new toolchain to do so. This shouldn't really be necessary; the IDE includes all the tools that are needed; it's just accessing them from the right place that is annoying.
The above issue include diffs to the optiboot "Makefile", as well as a short shell script (for macos) and a .bat file (for windows) that will allow one to rebuild optiboot by connecting to the .../hardware/arduino/bootloaders/optiboot directory and typing "./omake [names]" or "omake [names]" in a terminal/command window. You shouldn't have to have any other developer tools (other than Arduino) installed... Linux users are on their own (but should have fewer problems since installing Arduino usually means installing the other tools in "standard" places rather than the "special" places that they show up on Mac/Windows.)
I'm especially happy with the omake/omake.bat hack
omake:
echo ../../../tools/avr/bin/make OS=macosx ENV=arduino $*
../../../tools/avr/bin/make OS=macosx ENV=arduino $*
omake.bat:
..\..\..\tools\avr\utils\bin\make OS=windows ENV=arduino %*
Makefile.diffs
--- Makefile- 2010-12-24 11:55:50.000000000 -0800
+++ Makefile 2011-02-27 00:48:10.000000000 -0800
@@ -19,6 +19,13 @@
# program name should not be changed...
PROGRAM = optiboot
+# Uncomment this next lines to build within the arduino environment,
+# using the arduino-included avrgcc toolset (mac and pc)
+# ENV ?= arduino
+# OS ?= macosx
+# OS ?= windows
+
+
# enter the parameters for the avrdude isp tool
ISPTOOL = stk500v2
ISPPORT = usb
@@ -27,6 +34,27 @@
MCU_TARGET = atmega168
LDSECTION = --section-start=.text=0x3e00
+ifeq ($(ENV), arduino)
+# For Arduino, we assume that we're connected to the optiboot directory
+# included with the arduino distribution, which means that the full set
+# of avr-tools are "right up there" in standard places.
+TOOLROOT = ../../../tools
+GCCROOT = $(TOOLROOT)/avr/bin/
+AVRDUDE_CONF = -C$(TOOLROOT)/avr/etc/avrdude.conf
+else
+GCCROOT =
+AVRDUDE_CONF =
+endif
+
+ifeq ($(OS), windows)
+# On windows, SOME of the tool paths will need to have backslashes instead
+# of forward slashes (because they use windows cmd.exe for execution instead
+# of a unix/mingw shell?)
+fixpath = $(subst /,\,$1)
+else
+fixpath = $(1)
+endif
+
# the efuse should really be 0xf8; since, however, only the lower
# three bits of that byte are used on the atmega168, avrdude gets
# confused if you specify 1's for the higher bits, see:
@@ -37,10 +65,13 @@
# lock it), but since the high two bits of the lock byte are
# unused, avrdude would get confused.
-ISPFUSES = avrdude -c $(ISPTOOL) -p $(MCU_TARGET) -P $(ISPPORT) $(ISPSPEED) \
--e -u -U lock:w:0x3f:m -U efuse:w:0x$(EFUSE):m -U hfuse:w:0x$(HFUSE):m -U lfuse:w:0x$(LFUSE):m
-ISPFLASH = avrdude -c $(ISPTOOL) -p $(MCU_TARGET) -P $(ISPPORT) $(ISPSPEED) \
--U flash:w:$(PROGRAM)_$(TARGET).hex -U lock:w:0x0f:m
+ISPFUSES = $(GCCROOT)avrdude $(AVRDUDE_CONF) -c $(ISPTOOL) \
+ -p $(MCU_TARGET) -P $(ISPPORT) $(ISPSPEED) \
+ -e -u -U lock:w:0x3f:m -U efuse:w:0x$(EFUSE):m \
+ -U hfuse:w:0x$(HFUSE):m -U lfuse:w:0x$(LFUSE):m
+ISPFLASH = $(GCCROOT)avrdude $(AVRDUDE_CONF) -c $(ISPTOOL) \
+ -p $(MCU_TARGET) -P $(ISPPORT) $(ISPSPEED) \
+ -U flash:w:$(PROGRAM)_$(TARGET).hex -U lock:w:0x0f:m
STK500 = "C:\Program Files\Atmel\AVR Tools\STK500\Stk500.exe"
STK500-1 = $(STK500) -e -d$(MCU_TARGET) -pf -vf -if$(PROGRAM)_$(TARGET).hex \
@@ -53,15 +84,15 @@
DEFS =
LIBS =
-CC = avr-gcc
+CC = $(GCCROOT)avr-gcc
# Override is only needed by avr-lib build system.
override CFLAGS = -g -Wall $(OPTIMIZE) -mmcu=$(MCU_TARGET) -DF_CPU=$(AVR_FREQ) $(DEFS)
-override LDFLAGS = -Wl,$(LDSECTION) -Wl,--relax -nostartfiles
+override LDFLAGS = -Wl,$(LDSECTION) -Wl,--relax -Wl,--gc-sections -nostartfiles
-OBJCOPY = avr-objcopy
-OBJDUMP = avr-objdump
+OBJCOPY = $(GCCROOT)avr-objcopy
+OBJDUMP = $(call fixpath,$(GCCROOT)avr-objdump)
# 20MHz clocked platforms
#