Uno as ISP for Atmega 1281

Hello,

I've been trying to program an Atmega 1281 on a custom circuit board. I've been using an Uno with Arduino ISP firmware installed, but have hit a bit of a snag.

When I try to bootload the 1281 I get random invalid device signatures. Such as 0x070000, 0xff0000, and 0x80001e; see the verbose output:

avrdude: AVR device initialized and ready to accept instructions

Error while burning bootloader.
Reading | ################################################## | 100% 0.02s

avrdude: Device signature = 0x80001e
avrdude: Expected signature for ATmega1281 is 1E 97 04
         Double check chip, or use -F to override this check.

I heard that random device signatures usually are generated by clock mismatching, but after a days worth of reading and experimenting I've yet to find a valid resolution. I've checked all of my connections with a probe, and check and recheck that they are wired correctly. Is there some pin I should probe with an oscilloscope to validate/disprove this?

For the sake of completeness, I'm using this board.txt board:

1281.name=Uno W/ ATmega1281

1281.upload.protocol=arduino
1281.upload.maximum_size=130048
1281.upload.maximum_data_size=8192

1281.bootloader.tool=avrdude
1281.bootloader.unlock_bits=0x3f
1281.bootloader.lock_bits=0x0f

1281.build.core=MCUdude_corefiles
1281.build.variant=64-pin-avr
1281.build.mcu=atmega1281
1281.build.board=AVR_ATmega1281

1281.bootloader.low_fuses=0xFF
1281.bootloader.high_fuses=0xDA
1281.bootloader.extended_fuses=0xFD

1281.menu.LTO.Os=Disabled 

1281.upload.speed=115200
1281.bootloader.low_fuses=0xf7
1281.bootloader.high_fuses=0xd6
1281.bootloader.file=optiboot_flash/{build.mcu}/optiboot_flash_{atmega1281}_{115200}_{16000000}.hex
1281.build.f_cpu=16000000L

Where the optiboot I got from the Megacore github repository.

Any advice as to what I should check/read?

Thanks for reading!

It's most likely a hardware problem but you haven't provided any information on your hardware so it's going to be hard for us to help you.

What pins are you connecting to? On the 1281/2561 the programming pins are not SCK/MOSI/MISO, they are elsewhere.
In repsonse #20 here you can see where I jumpered from an FTDI header to the ICSP header to connect two of the signals.
https://forum.arduino.cc/index.php?topic=380757.15

Thanks for the reply!

Here is a complete detail of my hardware:

:::Programmer:::

Arduino Uno running ArduinoISP, Arduino 1.8.4.

10 µF cap from reset to ground

:::Target:::

Atmega 1281

Power:
Various switching regulators to regulate power to 5V at AVR device: I had probed to confirm it's not dropping below 4.9.

Clock:
16 MHz, with 12 pF caps on both XTAL pins.

:::Connections:::

Uno Mega1281
SCK (13) SCK (11)[PB1]
MISO (12) MISO (13)[PB3]
MOSI (11) MOSI (12)[PB2]
5V Vin Regulates to 5V at Mega
GND GND
RESET 10uF to GND

P.S As I'm writing this I've read CrossRoad's post...

If I understand correctly connections should be...
Uno Mega1281
SCK (13) SCK (11)[PB1]
MISO (12) TX (3)[PE1]
MOSI (11) RX (12)[PE0]
5V Vin Regulates to 5V at Mega
GND GND
RESET 10uF to GND

I'll check it in the morning.

P.P.S
I've been reading your post for about half a decade, just wanted to say thanks!

5V Vin Regulates to 5V at Mega

5V needs to go to 5V. Vin feeds the 5V regulator, you will not get 5V out if you put 5V in.

RESET 10uF to GND

What's that do? To my mind, that just keeps the Uno in Reset state, as such it cannot be used to Bootload the 1281.
You need a Programmer to install the 1281 bootload code.
Nick Gammon's code can run on an Uno to program a 1281.
My standalone programmer runs that code, and can be tweaked to set the fuses to kick off the bootloader after a reset.

CrossRoads:
RESET 10uF to GND

What's that do? To my mind, that just keeps the Uno in Reset state, as such it cannot be used to Bootload the 1281.

From https://www.arduino.cc/en/Tutorial/ArduinoISP

Note for the Arduino Uno: you'll need to add a 10 uF capacitor between reset and ground.

It's intended to prevent the Uno from auto-resetting but I don't think it's necessary with the current version of the ArduinoISP sketch, certainly I never use one and haven't had a problem using the Arduino as ISP.

Switched
Uno Mega
MISO --> TX
MOSI --> RX

Now I'm getting :

avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.02s

avrdude: Device signature = 0x000000 (retrying)

I'm gonna probe the clock later today and verify that it's... clocking(?). Also if I recall correctly, there is something about ArduinoISP requiring different delay times for different chips. I'm however open to any opinions as to source of error.

5V needs to go to 5V. Vin feeds the 5V regulator, you will not get 5V out if you put 5V in.

I have a buck boost switching regulators that do just that w/ 90% efficiency. LMR16006 and LM2623, they're magic. :slight_smile:

Alright, so I got the mega to communicate, yay! Turns out my 10K from reset to 5V was cold soldered...

New issue:

It appears I get an error writing my extended fuse to 0xFD, see verbose below...

avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.02s

avrdude: Device signature = 0x1e9704 (probably m1281)
avrdude: erasing chip
avrdude: reading input file "0x3f"
avrdude: writing lock (1 bytes):

Writing | ################################################## | 100% 0.01s

avrdude: 1 bytes of lock written
avrdude: verifying lock memory against 0x3f:
avrdude: load data lock data from input file 0x3f:
avrdude: input file 0x3f contains 1 bytes
avrdude: reading on-chip lock data:

Reading | ################################################## | 100% 0.01s

avrdude: verifying ...
avrdude: 1 bytes of lock verified
avrdude: reading input file "0xfd"
avrdude: writing efuse (1 bytes):

Writing |  ***failed;  
################################################## | 100% 0.11s

avrdude: 1 bytes of efuse written
avrdude: verifying efuse memory against 0xfd:
avrdude: load data efuse data from input file 0xfd:
avrdude: input file 0xfd contains 1 bytes
avrdude: reading on-chip efuse data:

Reading | ################################################## | 100% 0.01s

avrdude: verifying ...
avrdude: WARNING: invalid value for unused bits in fuse "efuse", should be set to 1 according to datasheet
This behaviour is deprecated and will result in an error in future version
You probably want to use 0xf5 instead of 0xfd (double check with your datasheet first).
avrdude: 1 bytes of efuse verified
avrdude: reading input file "0xd6"
avrdude: writing hfuse (1 bytes):

D:\Programs\Arduino\hardware\tools\avr/bin/avrdude -CC:\Users\You're_Nosey\AppData\Local\Arduino15\packages\MegaCore\hardware\avr\2.0.0/avrdude.conf -v -patmega1281 -cstk500v1 -PCOM5 -b19200 -Uflash:w:C:\Users\You're_Nosey\AppData\Local\Arduino15\packages\MegaCore\hardware\avr\2.0.0/bootloaders/optiboot_flash/atmega1281/optiboot_flash_atmega1281_115200_16000000L.hex:i -Ulock:w:0x0f:m 
Writing | ################################################## | 100% 0.02s

avrdude: 1 bytes of hfuse written
avrdude: verifying hfuse memory against 0xd6:
avrdude: load data hfuse data from input file 0xd6:
avrdude: input file 0xd6 contains 1 bytes
avrdude: reading on-chip hfuse data:

Reading | ################################################## | 100% 0.01s

avrdude: verifying ...
avrdude: 1 bytes of hfuse verified
avrdude: reading input file "0xf7"
avrdude: writing lfuse (1 bytes):

Writing | ################################################## | 100% 0.02s

avrdude: 1 bytes of lfuse written
avrdude: verifying lfuse memory against 0xf7:
avrdude: load data lfuse data from input file 0xf7:
avrdude: input file 0xf7 contains 1 bytes
avrdude: reading on-chip lfuse data:

Reading | ################################################## | 100% 0.01s

avrdude: verifying ...
avrdude: 1 bytes of lfuse verified

avrdude done.  Thank you.

And now it's not talking to me anymore:

avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.02s

avrdude: Device signature = 0x000000 (retrying)

Reading | ################################################## | 100% 0.02s

avrdude: Device signature = 0x000000 (retrying)

Error while burning bootloader.
Reading | ################################################## | 100% 0.02s

avrdude: Device signature = 0x000000
avrdude: Yikes!  Invalid device signature.
         Double check connections and try again, or use -F to override
         this check.

Did I just brick my board...?
Also, if someone else is trying to do this in the future, the boards file I included in the first post wasn't working, so I just used MegaCore's ATMEGA1281.

Update:

Believing that I had set the clock speed to 16Mhz and knowing that it now doesn't work, I assumed that the clock is misbehaving.

So I probed XTAL1 and 2 and noticed that they are at a static 2.5V. Thus, it is not clocking...

I'll post when I find a solution.

So I cleaned the connections on the clock and it seemed to work...

However, I keep getting issues with my extended fuses...

avrdude: verifying ...
avrdude: WARNING: invalid value for unused bits in fuse "efuse", should be set to 1 according to datasheet
This behaviour is deprecated and will result in an error in future version
You probably want to use 0xf4 instead of 0xfc (double check with your datasheet first).
avrdude: 1 bytes of efuse verified
avrdude: reading input file "0xd6"
avrdude: writing hfuse (1 bytes):

I checked, and triple checked the fuses on both the data sheet and Fuse calculator.

I'll do some more reading on this tomorrow, encase anyone else is curious.

Just ignore that. It's the expected behavior and doesn't indicate any problem.