Go Down

Topic: ATMega328P-PU with the USBTinyISB (Read 4611 times) previous topic - next topic

AgeBee

Hi,
I got the following setup to flash a sketch to the ATMega328P-PU with the USBTinyISB v3.0.
Linux, Arduino IDE 1.0.5, ATMega328P-PU on a separate board with no additional hardware (like the quartz, capacitors), 5 Volts to the Vcc and GND Pins is measured.
The wires go from the USBTinyISB 6-PIN header to the ATMega328P-PU like this.

VTG -> Vcc (PIN7)
MOSI -> MOSI (PIN17)
GND -> GND (PIN 8)
MISO -> MISO (PIN 18)
SCK -> SCK (PIN 19)
RST -> RESET (PIN 1)

I use the following entry in boards.txt:
Code: [Select]
atmega328p-16.name=ATmega328p

atmega328p-16.upload.protocol=usbtiny
atmega328p-16.upload.using=USBtinyISP
atmega328p-16.upload.maximum_size=32768
atmega328p-16.upload.speed=19200

atmega328p-16.bootloader.low_fuses=0xff
atmega328p-16.bootloader.high_fuses=0xDE
atmega328p-16.bootloader.path=atmega328p
atmega328p-16.bootloader.file=optiboot_atmega328.hex
atmega328p-16.bootloader.extended_fuses=0x05
atmega328p-16.bootloader.lock_bits=0xFF

atmega328p-16.build.mcu=atmega328p
atmega328p-16.build.f_cpu=16000000L
atmega328p-16.build.core=arduino:arduino
atmega328p-16.build.variant=arduino:standard


I get the following error when I try to upload the sketch:

avrdude: Error: Invalid -P value: '/dev/ttyS0'
         Use -P usb:bus:device

Seems to me that I choose the wrong port. But: When I hook up the ATTiny2313 it works great.
I am not offered to choose a different Serial Port in the menu of the Arduino IDE.
Do the AVCC (PIN 20) and GND (PIN 22) have to be connected additionally ?
How can it be possible that the same hookup does not work for the ATMega328 ? Maybe it's the board entry ??

Thanks for any pointers to solve that problem ?
Regards
AgeBee

mrburnette

You need power & ground in addition to SPI

Read here w/ pictures
http://www.gammon.com.au/forum/?id=11637

Ray

AgeBee

Thanks Ray for your response.

Adding power and GND didn't solve the issue.
However, I get another response:
avrdude: stk500_recv(): programmer is not responding

What still troubles me is the fact that it works with ATTiny2313 but not with the ATMega328P. I strongly believe that the entry in boards.txt is wrong.

mrburnette

My 8/16MHz breadboard files for the 328P-PU

Code: [Select]

##############################################################

atmega328bb.name=ATmega328 on a breadboard (8 MHz internal clock)

atmega328bb.upload.protocol=stk500
atmega328bb.upload.maximum_size=30720
#atmega328bb.upload.speed=57600
atmega328bb.upload.speed=19200

atmega328bb.bootloader.low_fuses=0xE2
atmega328bb.bootloader.high_fuses=0xDA
atmega328bb.bootloader.extended_fuses=0x05
atmega328bb.bootloader.path=arduino:atmega
atmega328bb.bootloader.file=ATmegaBOOT_168_atmega328_pro_8MHz.hex
atmega328bb.bootloader.unlock_bits=0x3F
atmega328bb.bootloader.lock_bits=0x0F

atmega328bb.build.mcu=atmega328p
atmega328bb.build.f_cpu=8000000L
atmega328bb.build.core=arduino:arduino

##############################################################

atmega328xtal16.name=ATmega328 on a breadboard (16MHz Xtal)
atmega328xtal16.upload.protocol=arduino
atmega328xtal16.upload.maximum_size=32256
#atmega328xtal16.upload.speed=115200
atmega328xtal16.upload.speed=19200
atmega328xtal16.bootloader.low_fuses=0xff
atmega328xtal16.bootloader.high_fuses=0xde
atmega328xtal16.bootloader.extended_fuses=0x05
atmega328xtal16.bootloader.path=optiboot
atmega328xtal16.bootloader.file=optiboot_atmega328.hex
atmega328xtal16.bootloader.unlock_bits=0x3F
atmega328xtal16.bootloader.lock_bits=0x0F
atmega328xtal16.build.mcu=atmega328p
atmega328xtal16.build.f_cpu=16000000L
atmega328xtal16.build.core=arduino
atmega328xtal16.build.variant=standard

##############################################################


AgeBee

Ray,
thanks for posting me your settings but neither one did help.
When I used your 'internal' breadboard ATmega328 settings I get the error:

Arduino.h:213:26: error: pins_arduino.h: No such file or directory

When I use the ATmega328 on a breadboard (16MHz Xtal) I get:

avrdude: stk500_recv(): programmer is not responding

There must be one setting which prevents reaching my ATMega328.
BTW, I took another chip and tried with that one. Same negative result. The chip however could flawlessly flashed within an Arduino UNO.

I will keep on searching and let you know when I found a solution.
Regards, AgeBee

mart256

#5
Apr 09, 2014, 10:44 pm Last Edit: Apr 09, 2014, 10:51 pm by mart256 Reason: 1
Did you find a solution?

I own USBTiny 2.0 and have flashed Atmega168 and Atmega328 without trouble. The programmer powers up the micro so no need for external source. I power both pin 7 and pin 20 with VCC and pin 8 and 22 with GND, conecct the 10k pull-up resistor on RESET pin. Wire up SCK, MISO, MOSI. I also conect a 16MHZ crystal as external oscilator (because I use the same configuration as Arduino), but I don't know if it is really necesary.

Then I use this command on avr dude to burn the .HEX on the chips:

Atmega168:
avrdude -c usbtiny -p atmega168 -U flash:w:Blink.hex

Atmega328P:
avrdude -c usbtiny -p m328p -U flash:w:Blink.hex

You may try erasing first the chip and then flashing.

Regards.

EDIT: You said your Atmega328P flashes properly on the Arduino UNO? That means the fuses are set to 16 MHZ external oscilator, then you must connect a 16 MHZ crystal to the Atmega in order to flash with the USBTiny. Hope this works.

mrburnette

#6
Apr 10, 2014, 02:10 am Last Edit: Apr 10, 2014, 02:13 am by mrburnette Reason: 1
I know many swear by the Atmel professional programmers, but for attiny45/85 and atmega328P-PU, the Adafruit ZIF shield for UNO is a good $20 investment and in nearly 3 years, I have not had a single issue.



http://forum.arduino.cc/index.php?topic=103755.0

Ray

AgeBee

Hi,
thanks mart256 and Ray for your interest in my problem.

@mart256:
The programmer powers the chip up, yes, that's correct and I wired it up as you described it. PIN 7 and PIN 20 with Vcc and PIN 8 and 22 with GND.
However, I did not use a 10k pull-up resistor for the RESET PIN. I connected it directly to RESET of the ISB 6-pin header (PIN 5). Could this be the solution ?
And yes, the chip flashes properly within the Arduino UNO. In one of my tries I used a 16 MHz quartz together with two capacitors to GND. But this did not help.

I'll try two things tonight. First, the 10 k pull-up resistor and then the 'direct' flash with avrdude, i.e. not using the Arduino UNO between it. Just your posted command line.

You suggested erasing it beforehand. This works with the -e switch, right ?

@Ray:
I got me the USBTinyISB because it was said that it works flawlessly. Actually it did and I can remember using it for the ATMega328 nearly two years ago with the Arduino IDE 1.0.0. But since then a couple of things had changed (at least my operating system, Arduino IDE).

Regards, AgeBee

mart256

#8
Apr 10, 2014, 03:48 pm Last Edit: Apr 10, 2014, 03:58 pm by mart256 Reason: 1


However, I did not use a 10k pull-up resistor for the RESET PIN. I connected it directly to RESET of the ISB 6-pin header (PIN 5). Could this be the solution ?
Regards, AgeBee


Yep, I guess it may be. Conect the reset of the Atmega328p to a 10kpull up and also to the RESET of the ISB 6-pin header (with the crystal with 22pf capacitors and the other suplpy pins connected). Tell us how is it going then.

Regards

AgeBee

Hi Ray, mrburnette, mart256,

With Rays ...
ATmega328 on a breadboard (16MHz Xtal)

... I get the answer:
avrdude: stk500_recv(): programmer is not responding

With Rays ...
ATmega328 on a breadboard (8 MHz internal clock)
... I get the answer:
In file included from Blink.ino:10:
Arduino.h:213:26: error: pins_arduino.h: No such file or directory

With my entry mentioned above I get:

avrdude: Error: Invalid -P value: '/dev/ttyS4'
         Use -P usb:bus:device
         
However, I get it on the chip with the command line version:
sudo ./avrdude -c usbtiny -C avrdude.conf -p m328p -U flash:w:Blink.cpp.hex

The quartz and the two capacitors were necessary, however it was not necessary to use the 10 k pull-up from RESET to Vcc. It worked with and also without the resistor. The RES of the USBTinyISB was directly connected to PIN 1 of the ATMega328.

So it seems to me that the problem is in the boards.txt where I do not use the prober values.

Nevertheless it works now.
I'll still keep on working for a solution with/over the Arduino.
Thanks guys for your kind help.
Regards, AgeBee

mart256

Happened to me once, the USBTiny didn't work on the Arduino IDE but worked flawless on the console.
Now I always use the console. Glad it worked.

Go Up