I've compiled and uploaded ArduinoISP to the nano with no problem.
I've installed megacore.
I switch the board to MegaCore128, clock to 'external 8mhz'
BOD is set to 2.7V
EEPROM Not Retained
Compiler LTO disabled
No Bootloader
Port to the USB port of the Nano
Programmer to 'Arduino as ISP'
when I click 'Burn Bootloader', I get the following:
avrdude: Version 6.3-20201216
Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
Copyright (c) 2007-2014 Joerg Wunsch
System wide configuration file is "/Users/bownes/Library/Arduino15/packages/MegaCore/hardware/avr/2.1.3/avrdude.conf"
User configuration file is "/Users/bownes/.avrduderc"
Using Port : /dev/cu.usbserial-14130
Using Programmer : stk500v1
Overriding Baud Rate : 19200
AVR Part : ATmega128
Chip Erase delay : 9000 us
PAGEL : PD7
BS2 : PA0
RESET disposition : dedicated
RETRY pulse : SCK
serial program mode : yes
parallel program mode : yes
Timeout : 200
StabDelay : 100
CmdexeDelay : 25
SyncLoops : 32
ByteDelay : 0
PollIndex : 3
PollValue : 0x53
Memory Detail :
Block Poll Page Polled
Memory Type Mode Delay Size Indx Paged Size Size #Pages MinW MaxW ReadBack
----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
eeprom 4 12 64 0 no 4096 8 0 9000 9000 0xff 0xff
flash 33 6 128 0 yes 131072 256 512 4500 4500 0xff 0xff
lfuse 0 0 0 0 no 1 0 0 9000 9000 0x00 0x00
hfuse 0 0 0 0 no 1 0 0 9000 9000 0x00 0x00
efuse 0 0 0 0 no 1 0 0 9000 9000 0x00 0x00
lock 0 0 0 0 no 1 0 0 9000 9000 0x00 0x00
calibration 0 0 0 0 no 4 0 0 0 0 0x00 0x00
signature 0 0 0 0 no 3 0 0 0 0 0x00 0x00
Programmer Type : STK500
Description : Atmel STK500 Version 1.x firmware
Hardware Version: 2
Firmware Version: 1.18
Topcard : Unknown
Vtarget : 0.0 V
Varef : 0.0 V
Oscillator : Off
SCK period : 0.1 us
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.
avrdude done. Thank you.
Connections are all good, 128 has power.
any clues would be most appreciated
// Configure SPI clock (in Hz).
// E.g. for an ATtiny @ 128 kHz: the datasheet states that both the high and low
// SPI clock pulse must be > 2 CPU cycles, so take 3 cycles i.e. divide target
// f_cpu by 6:
// #define SPI_CLOCK (128000/6)
//
// A clock slow enough for an ATtiny85 @ 1 MHz, is a reasonable default:
#define SPI_CLOCK (1000000/6)
Not the same. In the first case, there is zero response - no answer from the target. It can be anything (clock, power...) but mostly HW connection. The second case, there is an obvious communication problem:
expect=0x14, resp=0x14 - good
expect=0x14, resp=0x02 - good answer, but it seems like expectation is wrong.
See stk500v1 for more details.
This is the result : avrdude: stk500_disable(): protocol error.
It seems like programmer and target are out of sync. So probably different value as @ua6em advises?
ATmega128 doesn't use the usual SPI pins for programming. See the datasheet:
Even though the SPI Programming interface re-uses the SPI I/O module, there is one important difference: The MOSI/MISO pins that are mapped to PB2 and PB3 in the SPI I/O module are not used in the Programming interface. Instead, PE0 and PE1 are used for data in SPI Programming mode as shown in the following table.