Go Down

Topic: Error trying to upload a sketch on an ATmega328p bootloaded using Arduino IDE (Read 982 times) previous topic - next topic

Nicodeur

Hi all!

I have an issue trying to upload a sketch on an ATmega328p on a breadboard with an external oscillator at 16 MHz. I have successfully flashed the Blink sketch + bootloader on it, using MPlab IPE with the .hex file exported from the Arduino IDE.

Using MPlab IDE, I have checked that the configuration bytes were set correctly, which seems to be the case :


At that point, the LED is blinking correctly, but when I try uploading a new sketch on the ATmega328p using Arduino IDE and the TTL232R connected to the pins RX and TX, RTS connected to the nRESET pin, CTS connected to nothing, I have the following error in the console, repeated 10 times :

avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0x00


It might come from the card selection section as I have checked "Arduino Pro or Pro Mini" with the "ATmega328p (5V, 16MHz)" and I am not using an Arduino Pro or Pro Mini but the same processor at the same clock and voltage.

I have tried changing the power supply to a programmable power supply from a lab but nothing changed ...

Thanks a lot for your help !  :) 

Budvar10

Are you sure the bootloader is there? Also fuses have to be set correctly.
Arduino clone with ATmega1284P   http://forum.arduino.cc/index.php?topic=277260.0

Nicodeur

Are you sure the bootloader is there? Also fuses have to be set correctly.
Hi Budvar, thanks for your answer.

I have just received my Atmel ICE so I can now use atprogram to read the flash memory and the fuses.

I can program my ATmega328p thanks to the ICE programmer, so I flashed the bootloader and my program on it. I have verified that the bootloader was well written at the end of the flash memory.

I have an Arduino Nano on which I have uploaded my program and I can program it directly with no programmer, through USB with Arduino IDE.

I've read the fuses, the lock bits and the flash memory on both my Nano and my standalone ATmega and they are exactly the same, but I still can't program my standalone ATmega without a prorammer ...

Thanks for your help !

dmjlambert

Remove RTS connected to the RESET pin, that does not belong.  Connect a reset button that you can press to ground the reset pin.   Tap the button at the beginning of upload.  
 
If you have an FTDI Basic it has a DTR pin that you can connect to a 0.1uF capacitor, then connect the other side of the capacitor to the reset pin of the MCU.   That would provide a reset pulse at beginning of upload.   If you look at your Nano and follow the traces on it or look at a Nano schematic (Arduino brand or Chinese knock off), you'll notice that is how they are wired. 

You can use the Uno bootloader and fuse settings for your standalone chip, and that would be better than Nano.   in fact, you can put the Uno bootloader and fuse settings on your Nano and then upload to it with the Uno settings.   That would give you more flash space and you would be using the Optiboot bootloader.   I usually bootload my Nanos and Pro Minis with the Uno bootloader then I just treat them like small Unos.   All my ATmega328P 16MHz based boards, including lone ATmega328P alone on a breadboard with a crystal are Unos, it keeps things simple.   If you have an LED and resistor connected to digital pin 13 (pin 19 of the DIP package), and tap the reset button, you'll notice it flashes 3 times rapidly, that indicates your bootloader is ready. 

 

Nicodeur

Thanks for your answer dmjalbert, all is now working perfectly !

Remove RTS connected to the RESET pin, that does not belong.  Connect a reset button that you can press to ground the reset pin.   Tap the button at the beginning of upload.
Done, I don't know why I did it, maybe I have misunderstood something in the DS.

If you have an FTDI Basic it has a DTR pin that you can connect to a 0.1uF capacitor, then connect the other side of the capacitor to the reset pin of the MCU.   That would provide a reset pulse at beginning of upload.   If you look at your Nano and follow the traces on it or look at a Nano schematic (Arduino brand or Chinese knock off), you'll notice that is how they are wired.  
Well, I don't know if my FTDI is a "normal" FTDI device. It's the TTL-232R-PCB, and there is no DTR pin, as it is mentioned in the DS :


However, the RTS pin is pretty similar with the DTR :


And it perfectly works with the wiring you've mentioned !


You can use the Uno bootloader and fuse settings for your standalone chip, and that would be better than Nano.   in fact, you can put the Uno bootloader and fuse settings on your Nano and then upload to it with the Uno settings.   That would give you more flash space and you would be using the Optiboot bootloader.   I usually bootload my Nanos and Pro Minis with the Uno bootloader then I just treat them like small Unos.   All my ATmega328P 16MHz based boards, including lone ATmega328P alone on a breadboard with a crystal are Unos, it keeps things simple.   If you have an LED and resistor connected to digital pin 13 (pin 19 of the DIP package), and tap the reset button, you'll notice it flashes 3 times rapidly, that indicates your bootloader is ready. 

 
Oh I see, the heartbeat signal is on pin 13 and not on pin 9 as it is written in the ArduinoISP sketch example from the Arduino IDE...
Quote from: ArduinoISP
// Put an LED (with resistor) on the following pins:
// 9: Heartbeat   - shows the programmer is running
// 8: Error       - Lights up if something goes wrong (use red if that makes sense)
// 7: Programming - In communication with the slave
My problem is now solved, thanks guys  :)

Go Up