Right then. Let me describe what I did to get to this point:
$ avrdude -c arduino -p m328p -v -P /dev/tty.usbmodemfd141 -b 19200
avrdude: Version 5.8cvs, compiled on Jan 15 2010 at 17:27:01
Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
Copyright (c) 2007-2009 Joerg Wunsch
System wide configuration file is "/usr/local/CrossPack-AVR-20100115/etc/avrdude.conf"
User configuration file is "/Users/nick/.avrduderc"
User configuration file does not exist or is not a regular file, skipping
Using Port : /dev/tty.usbmodemfd141
Using Programmer : arduino
Overriding Baud Rate : 19200
AVR Part : ATMEGA328P
Chip Erase delay : 9000 us
PAGEL : PD7
BS2 : PC2
RESET disposition : dedicated
RETRY pulse : SCK
serial program mode : yes
parallel program mode : yes
Timeout : 200
StabDelay : 100
CmdexeDelay : 25
SyncLoops : 32
ByteDelay : 0
PollIndex : 3
PollValue : 0x53
Memory Detail :
Block Poll Page Polled
Memory Type Mode Delay Size Indx Paged Size Size #Pages MinW MaxW ReadBack
----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
eeprom 65 5 4 0 no 1024 4 0 3600 3600 0xff 0xff
flash 65 6 128 0 yes 32768 128 256 4500 4500 0xff 0xff
lfuse 0 0 0 0 no 1 0 0 4500 4500 0x00 0x00
hfuse 0 0 0 0 no 1 0 0 4500 4500 0x00 0x00
efuse 0 0 0 0 no 1 0 0 4500 4500 0x00 0x00
lock 0 0 0 0 no 1 0 0 4500 4500 0x00 0x00
calibration 0 0 0 0 no 1 0 0 0 0 0x00 0x00
signature 0 0 0 0 no 3 0 0 0 0 0x00 0x00
Programmer Type : Arduino
Description : Arduino
Hardware Version: 2
Firmware Version: 1.18
Topcard : Unknown
Vtarget : 0.0 V
Varef : 0.0 V
Oscillator : Off
SCK period : 0.1 us
avrdude: AVR device initialized and ready to accept instructions
Reading | ################################################## | 100% 0.04s
avrdude: Device signature = 0x1e950f
avrdude: safemode: lfuse reads as FF
avrdude: safemode: hfuse reads as DE
avrdude: safemode: efuse reads as 5
avrdude: safemode: lfuse reads as FF
avrdude: safemode: hfuse reads as DE
avrdude: safemode: efuse reads as 5
avrdude: safemode: Fuses OK
avrdude done. Thank you.
You will note that it detected the ATMEGA328P part, and read the fuses. So from here on, it is just formality I think.
First important point: Since we are using a Mega, and programming is done via SPI, we need to use the Mega SPI pins, not the Uno ones.
Mega Duem
D53 Reset (SS)
D51 D11 (MOSI)
D50 D12 (MISO)
D52 D13 (SCK)
Gnd Gnd
+5 +5
Next, I uploaded the "example" ArduinoISP sketch that shipped with 1.0 of the IDE onto the Mega.
Then, it appeared to work better (ie. at all) if I stuck a 10 uF capacitor between Reset and Gnd on the Mega.
It also appeared to need the Mega to be reset (ie. reset button) before trying anything. Wait a few seconds for the Tx/Rx lights to stop flashing, as the bootloader on the Mega tries to do serial comms.
Then I used avrdude on the command line, after working out which comm port the device was recognized on (in my case, /dev/tty.usbmodemfd141).
avrdude -c arduino -p m328p -v -P /dev/tty.usbmodemfd141 -b 19200
The -v just checks that it can communicate with the target device.
If you want to see more, replace -v by -vvvv and then you see stuff like this:
Using Port : /dev/tty.usbmodemfd141
Using Programmer : arduino
Overriding Baud Rate : 19200
avrdude: Send: 0 [30] [20]
avrdude: Send: 0 [30] [20]
avrdude: Send: 0 [30] [20]
avrdude: Recv: . [14]
avrdude: Recv: . [10]
AVR Part : ATMEGA328P