0

Attiny85 works Atmega328 does not
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Attiny85 works Atmega328 does not

by ceraum on Sat Jan 14, 2017 10:42 am

Hi all,

Just at my wits end here. Have purchased and assembled a USBtinyISP after failing to program a Atmega328 chip using the UNO, on both I get the same behavior. The dreaded:

avrdude: initialization failed, rc=-1
Double check connections and try again, or use -F to override
this check.

With both UNO and USBtinyISP I can see and program an Attiny85 with no problems at all using straight avrdude and the Arduino IDE. I have checked, double checked all the wiring (heck I've done this 50 times over!), but no luck whatsoever. I have placed and removed capacitors between VCC and ground as well as the reset pin and ground. I held it over my head and placed it under my chair I even tried avrdude while facing all four compass points and reciting poetry but no luck. The next step is to sacrifice a chicken.

I have no idea what to try next (other than the chicken)

Can anyone please offer some practical advice on how I can move past this roadblock. I'm very excited to move to the next step, but have been stalled at this point for some time now.

Many thanks,

CE

ceraum
 
Posts: 11
Joined: Sun Feb 22, 2015 2:50 pm

Re: Attiny85 works Atmega328 does not

by Russell 27 on Sat Jan 14, 2017 3:37 pm

Are you using a factory new (default set) ATmega 328 or one set up for an arduino board. The configuration settings (fuses) for arduino 328 are set up for external 16 Mhz crystal use.

Screen Shot 2015-11-01 at 8.01.52 AM.png
Screen Shot 2015-11-01 at 8.01.52 AM.png (163 KiB) Viewed 809 times


Are these the connections for pin out. If you are using arduino 328 try connecting a 16 Mhz crystal to pin 9 and 10
Russell 27
 
Posts: 240
Joined: Thu Sep 12, 2013 3:59 pm

Re: Attiny85 works Atmega328 does not

by ceraum on Sat Jan 14, 2017 4:24 pm

Hi Russell,

Thanks a bunch for your response, and you identified the very solution I needed. The ATmega 328's I had purchased did have the boot loader pre-installed, which requires the crystal. Oh the wonderful things I am learning (most of which are old hat to many of you)

Since I don't have a crystal laying around, I continued to Google and came across a wonderful page:

http://www.gammon.com.au/breadboard

Nick Gammon has done a great job explaining how to burn a new boot loader with both board detector and programming sketches available. The key for me was to use his suggestion and software, which generates a clock signal on pin 9 of the UNU which can be used to stabilize the chip for programming by connecting to pin 9 of the Atmega. Simply brilliant.

After burning the new bootloader which sets the fuses for internal 8 Mhz guess what?

SUCCESS!!!!

My thanks go out to not only you and Nick, but to the whole community which has given me the confidence to dive right in.

Now it's time for a beer to celebrate.

ceraum
 
Posts: 11
Joined: Sun Feb 22, 2015 2:50 pm

Re: Attiny85 works Atmega328 does not

by Russell 27 on Sat Jan 14, 2017 4:50 pm

Great. Now that you have USBtiny, fuses, flash and eeprom can be programmed directly using avrdude, instead of bootloader, if you like.
Russell 27
 
Posts: 240
Joined: Thu Sep 12, 2013 3:59 pm

Re: Attiny85 works Atmega328 does not

by ceraum on Sun Jan 15, 2017 6:55 pm

Hi all,

Well my journey continues another day. Now I'm struggling with AVR GCC (oh my gosh I'm so close!)

Everything seems to have mostly gotten up and running, but installing it doesn't seem to support Atmega328P, or really a bunch of newer chips.

I worked my way through the Ladyada page:
http://www.ladyada.net/learn/avr/setup-mac.html

But encountered an error near the end:

configure: error: Building GCC requires GMP 4.2+, MPFR 2.4.0+ and MPC 0.8.0+

Not sure what the issue is as all three are installed. One more time I think I might be moving out of of my knowledge area.

Am I missing something obvious? I am going to try and figure out the paths, but not hopeful.

Thanks for any thoughts.

ceraum
 
Posts: 11
Joined: Sun Feb 22, 2015 2:50 pm

Re: Attiny85 works Atmega328 does not

by Russell 27 on Sun Jan 15, 2017 10:55 pm

I use CrossPack-AVR on mac. The latest installer includes all these tools-->

CrossPack-AVR-20131216
avarice: 2.13
avr-binutils: 2.23.2
avr-gcc: 4.8.1
avr-libc: 1.8.0
avrdude: 6.0.1
gdb: 7.6.1
libusb: 0.1.12
make: 4.0
simulavr: 0.1.2.7

To use the make command, Developer Command Line Tools must also be installed, You can get that from apple Developer site. If you use X code those tools are already installed, although full X code is not needed. The first time you type make in Terminal, if those tools are not installed, a window will prompt a download for those tools. I've used this installer on Mavericks and El Captain, I still prefer using Mavericks. The only little issue, when a program function is made in AVRDUDE, the set fuses are displayed for reference. The high fuse is listed as extended and extended fuse is listed as high. This doesn't effect programmed fuses, just reversed in terminal prompt listing. This was corrected in avrdude 6.1. This setup has worked well for me.
Russell 27
 
Posts: 240
Joined: Thu Sep 12, 2013 3:59 pm

Re: Attiny85 works Atmega328 does not

by ceraum on Mon Jan 16, 2017 4:55 am

Hi Russell,

Thanks for the suggestion, but I started there with Crosspack and installed the latest version available. Easy as pie.

Unfortunately it's the Atmega328 which is the problem as it does not yet have support for that chip. Which is why I went down the rabbit hole of trying to find a newer avr-gcc.

So yes all the components you listed are installed.

Is there some way to "add" the newer chips?

ceraum
 
Posts: 11
Joined: Sun Feb 22, 2015 2:50 pm

Re: Attiny85 works Atmega328 does not

by Russell 27 on Mon Jan 16, 2017 9:26 am

hmm. Don't follow your result.

ATmega 328 listed as supported chip in avrdude.
avrdude_supported chips.png
avrdude_supported chips.png (633.18 KiB) Viewed 732 times


Also listed in avr/include/io.h
io_h.png
io_h.png (332.81 KiB) Viewed 732 times
Russell 27
 
Posts: 240
Joined: Thu Sep 12, 2013 3:59 pm

Re: Attiny85 works Atmega328 does not

by ceraum on Mon Jan 16, 2017 9:55 am

Hi Russel,

I hope you are in the NY area, because I'd sure love to shake you hand.

The error I get when running make is:
Code: Select all | TOGGLE FULL SIZE
make
avr-gcc -Os -g -std=gnu99 -Wall -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums  -ffunction-sections -fdata-sections  -DF_CPU=1000000UL   -DBAUD=9600UL -I. -I../../AVR-Programming-Library -mmcu=atmega328p -c -o ../../AVR-Programming-Library/USART.o ../../AVR-Programming-Library/USART.c
unknown MCU 'atmega328p' specified

The list of supported MCUs does not include the 328, but does include other ones I recognize such as Attiny85 and Atmega168.

After that error there are many more listed (I'm not if this is relevant):

Code: Select all | TOGGLE FULL SIZE
../../AVR-Programming-Library/USART.c:1: warning: -ffunction-sections may affect debugging on some targets
../../AVR-Programming-Library/USART.c:1: error: MCU 'atmega328p' supported for assembler only
In file included from ../../AVR-Programming-Library/USART.c:19:
/usr/local/bin/../lib/gcc/avr/4.1.1/../../../../avr/include/avr/io.h:332:6: warning: #warning "device type not defined"
../../AVR-Programming-Library/USART.c:21:26: error: util/setbaud.h: No such file or directory
../../AVR-Programming-Library/USART.c: In function 'initUSART':
../../AVR-Programming-Library/USART.c:24: error: 'UBRR0H' undeclared (first use in this function)
../../AVR-Programming-Library/USART.c:24: error: (Each undeclared identifier is reported only once
../../AVR-Programming-Library/USART.c:24: error: for each function it appears in.)
../../AVR-Programming-Library/USART.c:24: error: 'UBRRH_VALUE' undeclared (first use in this function)
../../AVR-Programming-Library/USART.c:25: error: 'UBRR0L' undeclared (first use in this function)
../../AVR-Programming-Library/USART.c:25: error: 'UBRRL_VALUE' undeclared (first use in this function)
../../AVR-Programming-Library/USART.c:29: error: 'UCSR0A' undeclared (first use in this function)
../../AVR-Programming-Library/USART.c:29: error: 'U2X0' undeclared (first use in this function)
../../AVR-Programming-Library/USART.c:32: error: 'UCSR0B' undeclared (first use in this function)
../../AVR-Programming-Library/USART.c:32: error: 'TXEN0' undeclared (first use in this function)
../../AVR-Programming-Library/USART.c:32: error: 'RXEN0' undeclared (first use in this function)
../../AVR-Programming-Library/USART.c:33: error: 'UCSR0C' undeclared (first use in this function)
../../AVR-Programming-Library/USART.c:33: error: 'UCSZ01' undeclared (first use in this function)
../../AVR-Programming-Library/USART.c:33: error: 'UCSZ00' undeclared (first use in this function)
../../AVR-Programming-Library/USART.c: In function 'transmitByte':
../../AVR-Programming-Library/USART.c:39: error: 'UCSR0A' undeclared (first use in this function)
../../AVR-Programming-Library/USART.c:39: error: 'UDRE0' undeclared (first use in this function)
../../AVR-Programming-Library/USART.c:40: error: 'UDR0' undeclared (first use in this function)
../../AVR-Programming-Library/USART.c: In function 'receiveByte':
../../AVR-Programming-Library/USART.c:44: error: 'UCSR0A' undeclared (first use in this function)
../../AVR-Programming-Library/USART.c:44: error: 'RXC0' undeclared (first use in this function)
../../AVR-Programming-Library/USART.c:45: error: 'UDR0' undeclared (first use in this function)
../../AVR-Programming-Library/USART.c:46: warning: control reaches end of non-void function
make: *** [../../AVR-Programming-Library/USART.o] Error 1

When running: "avrdude -c avrisp" in the terminal I do see Atmega328p (the chip I want) as supported, so that's not the issue.

I'm not 100% sure the folder you are looking at (my ignorance rears it's ugly head - oh wait - that's my head!) but searching for a file with name iom328.h did not reveal any results. But I've deleted and re-installed so much over the past few days I'm surprised my Mac still turn on.

Thanks for your help.

ceraum
 
Posts: 11
Joined: Sun Feb 22, 2015 2:50 pm

Re: Attiny85 works Atmega328 does not

by Russell 27 on Mon Jan 16, 2017 10:54 am

If you want to look at the files in CrossPack avr, in terminal type cd /usr/ then enter. This changes directory to usr. Then type ls and enter for list of files. Then type open local and enter. CrossPack folder should appear in window. You can look through all the files from there. I'm not certain you are defining program commands right. If interested, I can put together a sample file that may help.
Russell 27
 
Posts: 240
Joined: Thu Sep 12, 2013 3:59 pm

Re: Attiny85 works Atmega328 does not

by ceraum on Mon Jan 16, 2017 11:12 am

Hi Russel,

Yep - I'm clearly doing something wrong.

I was able to locate the folder: /usr/local/CrossPack-AVR-20131216/avr/include/avr/ and that does have the file you were indicating

avr screen grab.png
avr screen grab.png (122.94 KiB) Viewed 720 times


Any assistance is greatly appreciated!

ceraum
 
Posts: 11
Joined: Sun Feb 22, 2015 2:50 pm

Re: Attiny85 works Atmega328 does not

by Russell 27 on Mon Jan 16, 2017 11:44 am

I'll get back with you later today.
Russell 27
 
Posts: 240
Joined: Thu Sep 12, 2013 3:59 pm

Re: Attiny85 works Atmega328 does not

by ceraum on Mon Jan 16, 2017 12:27 pm

I wait with bated breath :)

ceraum
 
Posts: 11
Joined: Sun Feb 22, 2015 2:50 pm

Re: Attiny85 works Atmega328 does not

by Russell 27 on Mon Jan 16, 2017 1:59 pm

Can you post your make file contents
Russell 27
 
Posts: 240
Joined: Thu Sep 12, 2013 3:59 pm

Re: Attiny85 works Atmega328 does not

by ceraum on Mon Jan 16, 2017 2:18 pm

Hi Russel,

Here is the Makefile (zipped).

This is from a supplied file from the book "Make: AVR Programming".

The author makes it sound so easy ;)

Makefile.zip
(3.17 KiB) Downloaded 31 times

ceraum
 
Posts: 11
Joined: Sun Feb 22, 2015 2:50 pm

Please be positive and constructive with your questions and comments.