Upload sketch only once!

Hi!
I've made a board with an atmega2560. I'm trying to upload the bootloader with another arduino used as ISP and I get this error:

avrdude: verification error, first mismatch at byte 0x3e000
		         0x0d != 0xff
		avrdude: verification error; content mismatch

but the led on pin 13 digital blinks. So, I tried to upload a sketch and it works only the first time! :astonished:
If I try twice it fails with a timeout error.
Can somebody help me?

Thank you very much!

After you load ArduinoISP, are you disabling auto-reset? If the host Arduino resets then the bootloader will be in control, not the ArduinoISP sketch. One easy way is to hook a 1 to 2 microfarad capacitor between Reset (+) and Ground (-) on the host Arduino after you upload ArduinoISP.

Yes...I put the 110Ohm resistor as explained here Arduino Playground - HomePage it right?
Thank you

Yes, the resistor should work.

I'm not entirely clear on the problem... Did you burn a bootloader without error?

You can use the ArduinoISP to upload sketches but I think you need the bootloader to turn control over to the sketch on startup. If the error was with burning the bootloader you should get that fixed first.

No...that's the first problem...when I burn it I get the error in my first post.
I have also tried to upload a sketch via usb (with ft232) and it succeeded, but if I try to upload it again it fails.
I made few tests and I I can upload a sketch only ones after the bootloader, but I think it is a bootloader-related problem because of that error...

Thank You

(deleted)

I was thinking about a lock, too. But I haven't edited the original board.txt...
This is the mega2560 section:

mega2560.name=Arduino Mega 2560

mega2560.upload.protocol=stk500v2
mega2560.upload.maximum_size=258048
mega2560.upload.speed=115200

mega2560.bootloader.low_fuses=0xFF
mega2560.bootloader.high_fuses=0xD8
mega2560.bootloader.extended_fuses=0xFD
mega2560.bootloader.path=stk500v2
mega2560.bootloader.file=stk500boot_v2_mega2560.hex
mega2560.bootloader.unlock_bits=0x3F
mega2560.bootloader.lock_bits=0x0F

mega2560.build.mcu=atmega2560
mega2560.build.f_cpu=16000000L
mega2560.build.core=arduino

Thank You

(deleted)

How long are the wires between Arduino ISP and the target (atmega2560)?

No "!!!"...I just tried with the blink example...
The wires are long about 70cm...mmh..is it too much?

Thank You

The wires are long about 70cm...mmh..is it too much?

I've never used anything longer than about 20cm so I can't say for certain if 70cm is or is not a problem. I can say that 20cm has been a good choice for me.

At this point, you nothing to lose... Try shorter wires. Carefully check all connections.

Less than 10cm, but nothing change :expressionless:

(deleted)

Mac Os X 10.6.6 and arduino IDE 0022...
I also tried with 0020 with the same result...

Should I try on windows?

Thank you

(deleted)

I have already tried this, too.
Do you think that using avrdude directly without the ide could be a solution for the boot loader error?
I searched on web about this problem and I found another person who can upload a sketch only ones and was a problem with fuses...
This is the link: http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1268700386/0

Thank you

Do you think that using avrdude directly without the ide could be a solution for the boot loader error?

It is not a direct solution; the IDE runs AVRDUDE just as you would. But using AVRDUDE would give you more control and may help isolate the problem.

Do you have another processor (like a DIP 328) + breadboard that you could use to prove that the software and ISP are working correctly?

(deleted)

From that other string:

"After programming the bootloader (with the STK500 programmer), I remove the ISP cable and move the serial connector to the second DB9 on the STK500. This port is cabled into the '328 via a 2 wire jumper (rx/tx). I then use the Arduino IDE to upload the sketch. It works once, but only once."

If that is what you are doing, using a serial connection to upload sketches and not the ICSP connection, you need to manually reset the target system just before the sketch loads. That is what the auto-reset on the Arduino does for you. To implement auto-reset on a target machine you need the DTR signal from the PC to get to the reset pin through a capacitor.

In my board there is the FT232 and I have connected the DTR pin just like in the arduino board.
This is the circuit:


IC11 is the FT232 and C33, C28 are both 100nF.

Thank for your help!