How to install arduino mega 2560 as isp programmer for atmel 644

Hello, I’m working with @miros.407 on the project. I tried to use the ini file @maxgerhardt posted. My Serial Port is COM5 and I replaced the SERIAL_PORT_HERE with COM5.

Now I’m getting the Error Code:

avrdude: can’t open config file “C:\Users\HP”: Permission denied
avrdude: error reading system wide configuration file “C:\Users\HP”
*** [upload] Error 1

Any ideas on how to give the permission?
I have found the path: -C
C:\Program Files (x86)\Arduino\hardware\tools\avr\etc
is read-only.

EDIT: now this is strange:

avrdude: can’t open config file “C:\Users\HP Gaming Rechner\Desktop”: Permission denied
avrdude: error reading system wide configuration file “C:\Users\HP Gaming Rechner\Desktop”
*** [upload] Error 1

We use https://ww1.microchip.com/downloads/en/DeviceDoc/doc2593.pdf page 2 figure 1.1 and we install that on a breadboard and connect it with a isp


at the middle is the 644 and at the bottom middle is our isp connection

1 Like

Do you have a space in your Windows username?

In the platformio.ini, can you replace $PROJECT_PACKAGES_DIR/tool-avrdude/avrdude.conf with "$PROJECT_PACKAGES_DIR/tool-avrdude/avrdude.conf" please (quoting should escape the path properly)

I’m afraid I do have a space in the username.

Adding the quotation marks worked. now we have an Invalid device Signature Error

Executing task in folder BlinkyTest: C:\Users\HP Gaming Rechner.platformio\penv\Scripts\pio.exe run --target upload <

Processing ATmega644 (platform: atmelavr; board: sanguino_atmega644_8m; framework: arduino)
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------Verbose mode can be enabled via -v, --verbose option
CONFIGURATION: Redirecting...
PLATFORM: Atmel AVR (3.0.0) > Sanguino ATmega644 or ATmega644A (8 MHz)
HARDWARE: ATMEGA644 8MHz, 4KB RAM, 63KB Flash
DEBUG: Current (simavr) On-board (simavr)
PACKAGES:

  • framework-arduino-avr 5.1.0
  • tool-avrdude 1.60300.200527 (6.3.0)
  • toolchain-atmelavr 1.50400.190710 (5.4.0)
    LDF: Library Dependency Finder → Library Dependency Finder (LDF) — PlatformIO latest documentation
    LDF Modes: Finder ~ chain, Compatibility ~ soft
    Found 5 compatible libraries
    Scanning dependencies…
    No dependencies
    Building in release mode
    Checking size .pio\build\ATmega644\firmware.elf
    Advanced Memory Usage is available via “PlatformIO Home > Project Inspect”
    RAM: [ ] 0.2% (used 9 bytes from 4096 bytes)
    Flash: [ ] 1.5% (used 984 bytes from 64512 bytes)
    Configuring upload protocol…
    AVAILABLE: custom
    CURRENT: upload_protocol = custom
    Uploading .pio\build\ATmega644\firmware.hex

avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.03s

avrdude: Device signature = 0x000000 (retrying)

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

avrdude: Device signature = 0x000000 (retrying)

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.

*** [upload] Error 1
================================================================================================== [FAILED] Took 2.09 seconds ==================================================================================================
The terminal process “C:\Users\HP Gaming Rechner.platformio\penv\Scripts\pio.exe ‘run’, ‘–target’, ‘upload’” terminated with exit code: 1.

No problem then quoting solves it.

Welp. There are 3 possibilities here:

  1. The wireup between the Arduino Mega programmer and the ATMega644 is wrong
  2. The target board is not powered (?)
  3. You have a fake chip and it really does report 0x0000 as its ID o_O

Are you following the wireup as shown in https://www.instructables.com/How-to-use-Arduino-Mega-2560-as-Arduino-isp/ for the SPI lines and a capacitor between RESET and VCC on the Arduino Mega? Do you maybe have a picture of the setup or a wireup diagram available that you’re following?

I will check the wireup. The Board is powered. I hope the chip isn’t the problem. This would be unsolveable.

The wireup is following the one in the link you posted.
We still get the Yikes! Error.

The picture is cutoff at the left so I can’t see if you have a capacitor installed between RST and VCC, further the breadboard at the bottom is cut off.

A thing I find weird in the target board is the RESET line. Am I blind or does the bottom right pin of the ISP header, which is supposed to be RESET, go nowhere, just between the two headers themselves, but not to the actual RESET pin of the chip, which is just connected to one pin of the button? Hardware error? The SPI SlaveSelect (SS) line must definitely go the RESET of the target.

You can check whether it makes a difference if you connect the the SS pin of the Mega to the bottem left pin of the reset button (in regards to the above posted picture) (or touch it while programming with a male-male cable). The RESET button is an input connected to nothing else (if you don’t press the button) so nothing bad should happen.

Edit: Also, the page https://www.arduino.cc/en/Tutorial/BuiltInExamples/ArduinoISP should be the main source of information for the wireup. There are different wireups in there, e.g. RESET <-> RESET or SS <–>RESET with caps and not. Just glossed over it, maybe you can extract some more information from this and try a few different things.

We don’t have a capacitor installed. Is this crucial?

Reset is connected to pin 53 of the Arduino Mega. Should be SS.

I have to attend to an appointment now. Thanks for helping, I will reply again tomorrow.

Alternative we can use a cable like this intead of 10 pins we have a Cable with 6 Pins so it is an isp Cable. IDC Flachbandkabel Pfostenbuchsen 10-polig 1,0m für ISP: Amazon.de: Elektronik

We test it with these but it dosen’t work for us. We flip the End of the cable around but nothing change.

Yes

This is the suggested wiring for using a Mega as a ISP programmer… although it’s for a Uno, same principle applies, and you can read between the lines as to which pins on the target match the 644 :wink:

The Arduino MEGA above is programming an Arduino UNO connecting D51-D11, D50-D12, D52-D13, GND-GND, 5V-5V and D10 to RESET. This type of board needs a 10µF electrolytic capacitor connected to RESET and GND with the positive (long leg) connected to RESET. The capacitor has to be placed after the programmer board has been loaded with the ISP sketch.

The 10µF electrolytic capacitor connected to RESET and GND of the programming board is needed only for the boards that have an interface between the microcontroller and the computer’s USB, like Mega, Uno, Mini, Nano. Boards like Leonardo, Esplora and Micro, with the USB directly managed by the microcontroller, don’t need the capacitor.

Basically, if you don’t put it on the Mega after loading the ArduinoISP sketch, your Mega will reset instead of the target board, which isn’t very helpful! :laughing: Or at least, that’s what I think it prevents! :open_mouth:

Looks like the 644 RST should be connected to D10 on the Mega, not SS…

Longer answer: Yes absolutely because the capacitor suppresses a voltage drop of the RESET line from high to low when programmer tool initializes the device and does an eventual auto-reset, like @pfeerick said.

Some thoughts of mine:

  • double check with a multimeter that the reset pin of the ISP header goes through to the actual reset pin of the ATMega644. If it’s not, then the programmer can impossibly reset the chip, and then you need to make direct connection to that pins, somehow, either by soldering it or tapping that pin with the needed wire
  • double check that you’re NOT feeding 5V from the Arduino Mega into the target board when the target board is connected to its power supply at the same time! You’ll have two power supplies fighting each other and there’ll be a current between them. Either disconnect VCC between the two boards or disconnect the power supply from the target board (5V from the Mega should be plenty to power your target board which only has like the MCU and 3 other chips…)
  • double check voltages on the board to see if between GND and VCC of the board there really is a good 5V supply
  • double check the wiring as proposed by @pfeerick
  • note that I’ve seen that the ISP sketches / resources talk about “old school wiring” and new wiring. So there might be conflicting information around. Look into the source code of the exact (and hopefully recent) version of the Arduino as ISP sketch that you’re putting on your Arduino Mega, it should already tell you exactly how the wireup is supposed to be
  • you can sanity check that the “Arduino as ISP” Mega board is generally working by e.g. flashing a known-good Arduino Uno with the exact wireup as shown above. This would instantly eliminate the programmer from being the problem
  • if you’ve tried all wiring methods, all the voltages seem good and the programmer works in general on another chip then you can
    1. Add -F on a new line in the list of upload_flags of the platformio.ini, to try a “force”
    2. If this very likely makes no difference replace the ATMega644 of your target board, as it might by truely dead by “something”. From your pictures I do see that the chip is socketed so you can just pull it out and put a new one in, if you have a replacement part (that can also still be ordered today)
  • if you think PlatformIO is the problem (which it should be not, seems like a wiring or chip problem to me), you can still sanity-check that by doing it only within the Arduino IDE. The core you should be using is GitHub - MCUdude/MightyCore: Arduino hardware package for ATmega1284, ATmega644, ATmega324, ATmega324PB, ATmega164, ATmega32, ATmega16 and ATmega8535 with the “ATmega644” board selected. Then do a “burn bootloader” with the Arduino as ISP programmer selected and check if that works.
  • as another caveat: your microcontroller has no crystall oscillator attached to its XTAL1 and XTAL2 pins, it’s just an empty hole. The microcontroller should recognize that and start up on its internal RC oscillator (8MHz) though, I hope. Otherwise the chip will just do nothing without a clock. Possible clock settings are listed in the core

So it doesn’t make any sense to try all your ideas when we don’t connect an capacitor?

You’re still free to try without and prove me wrong but according to the information I read online that is needed :smiley:.

As another sidenote, if you have another programmer like https://www.ebay.de/itm/USB-ISP-USBASP-AVR-Programmer-mit-10-auf-6-Pin-Adapter-und-Kabel-Arduino/393020847827 that is prebuilt for tasks like this and already has the right cable, it might be much less painfull (given that the header pinout is correct regarding reset and the chip is actually still working). The USBASP (and others) is also directly supported.

1 Like

Now we added a capaciator 10µf and flash again now it gets flashed but we got a verifaction error.
avrdude: verifying …
avrdude: verification error, first mismatch at byte 0x0000
0x00 != 0x0c
avrdude: verification error; content mismatch

avrdude: safemode: Fuses OK (E:00, H:00, L:00)

avrdude done. Thank you.

A flag must be given so that the chip is erased before upload.

Add -e in a new, indented line to the upload_flags.

Thats the complet error. But don’t know why. I checked the wireing. Flashed the arduino with the isp new. Connect the Capaciator. I swaped between the platform ini’s.

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)

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

avrdude: Device signature = 0x000000
avrdude: Yikes! Invalid device signature.
avrdude: Expected signature for ATmega644 is 1E 96 09
avrdude: erasing chip
avrdude: reading input file “.pio\build\sanguino_atmega644\firmware.hex”
avrdude: writing flash (984 bytes):

Writing | ################################################## | 100% 0.97s

avrdude: 984 bytes of flash written
avrdude: verifying flash memory against .pio\build\sanguino_atmega644\firmware.hex:
avrdude: load data flash data from input file .pio\build\sanguino_atmega644\firmware.hex:
avrdude: input file .pio\build\sanguino_atmega644\firmware.hex contains 984 bytes
avrdude: reading on-chip flash data:

Reading | ################################################## | 100% 0.58s

avrdude: verifying …
avrdude: verification error, first mismatch at byte 0x0000
0x00 != 0x0c
avrdude: verification error; content mismatch

avrdude: safemode: Fuses OK (E:00, H:00, L:00)

avrdude done. Thank you.

the first ini

[env:sanguino_atmega644]
platform = atmelavr
board = sanguino_atmega644
framework = arduino
upload_port = COM3
upload_protocol = custom
upload_speed = 19200
upload_flags =
-e
-C
; use “tool-avrdude-megaavr” for the atmelmegaavr platform
$PROJECT_PACKAGES_DIR/tool-avrdude/avrdude.conf
-p
$BOARD_MCU
-P
$UPLOAD_PORT
-b
$UPLOAD_SPEED
-c
stk500v1
-F

upload_command = avrdude $UPLOAD_FLAGS -U flash:w:$SOURCE:i

the Second is the same i only change the board to board = sanguino_atmega644_8m

Seems like the chip isn’t responding at all. Were you ever able to get avrdude to output the correct device signature there?

What are your result on the checklist at How to install arduino mega 2560 as isp programmer for atmel 644 - #20 by maxgerhardt?

So i checked now everything. I wrote an small blinky where it loops through and blink. When i connect my wire to the Output pin 5 at the 644 the led Flashes perfectly until the reading error is comming. So

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)

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

avrdude: Device signature = 0x000000
avrdude: Yikes! Invalid device signature.
avrdude: Expected signature for ATmega644A is 1E 96 09
avrdude: erasing chip
avrdude: reading input file “.pio\build\ATmega644A\firmware.hex”
avrdude: writing flash (942 bytes):

Writing | ################################################## | 100% 0.97s

until here it flashes perfect and correct. but then

avrdude: 942 bytes of flash written
avrdude: verifying flash memory against .pio\build\ATmega644A\firmware.hex:
avrdude: load data flash data from input file .pio\build\ATmega644A\firmware.hex:
avrdude: input file .pio\build\ATmega644A\firmware.hex contains 942 bytes
avrdude: reading on-chip flash data:

Reading | ################################################## | 100% 0.58s

avrdude: verifying …
avrdude: verification error, first mismatch at byte 0x0000
0x00 != 0x0c
avrdude: verification error; content mismatch

avrdude: safemode: Fuses OK (E:00, H:00, L:00)

avrdude done. Thank you.

here Stops but i don’t have any idea why. So the Programmer runs perfectly, the arduino as programmer too. I connected the Leds for heartbeat, error and programming. So it is another Reason why it fails. The double power isn’t it because i power the ship by the arduino. The Capiciator could be but i change it so booth couldn’t be broken. The Ship 644 is also working because i’ve got the LED output only at my output pin. Any other ideas? i change the wirering between SS for reset and D10 booth dosen’t work.