SOLVED: How to tell if an arduino has been 'locked'

HI,

I have some Unos, one has some code on it I'd like to pull off the chip and put on to another.

Connecting Uno #1 to the computer and running AVRDUDE commands, I can backup the flash and EEPROM using the following commands -

Backup FLASH UNO
avrdude.exe -p atmega328p -c arduino -P COM9 -b 115200 -U flash:r:flash_backup_file.hex:h

Backup EEPROM UNO
avrdude.exe -p atmega328p -c arduino -P COM9 -b 115200 -U eeprom:r:eeprom_backup_file.hex:h

Write FLASH to Uno
avrdude.exe -p atmega328p -c arduino -P COM9 -b 115200 -e -U flash:w:flash_backup_file.hex:h

Write EEPROM to Uno
avrdude.exe -p atmega328p -c arduino -P COM9 -b 115200 -U eeprom:w:eeprom_backup_file.hex:h

However, connecting Uno #2 (it uses the same COM port#) and repeating the commands gives me errors -
avrdude.exe: stk500_getsync() attempt 1 of 10: not in sync: resp=0x00
avrdude.exe: stk500_getsync() attempt 2 of 10: not in sync: resp=0x1c
avrdude.exe: stk500_getsync() attempt 3 of 10: not in sync: resp=0x00
avrdude.exe: stk500_getsync() attempt 4 of 10: not in sync: resp=0x1c
avrdude.exe: stk500_getsync() attempt 5 of 10: not in sync: resp=0x00
avrdude.exe: stk500_getsync() attempt 6 of 10: not in sync: resp=0x1c
avrdude.exe: stk500_getsync() attempt 7 of 10: not in sync: resp=0x00
avrdude.exe: stk500_getsync() attempt 8 of 10: not in sync: resp=0x1c
avrdude.exe: stk500_getsync() attempt 9 of 10: not in sync: resp=0x00
avrdude.exe: stk500_getsync() attempt 10 of 10: not in sync: resp=0x1c

(sometimes the resp= are different hex vaules)

I can't even read the fuse/lock bits.

Am I doing something wrong or has the chip already been locked?

Eddiie:
I can backup the flash and EEPROM using the following commands -

Through Optiboot?

AVRDUDE talks to AVR programmers, I did not know it can talk the the Arduino serial bootloader.

The ArduinoISP program turns an Arduino UNO into a AVR programmer and AVRDUDESS can access it as a STK500 V1.x firmware device.

You can then use the UNO as an AVR programmer. I was using it yesterday for setting fuses on an ATmega328 target device, but have not tried the rest of the functionality such as reading and writing HEX files.

srnet:
AVRDUDE ... I did not know it can talk the the Arduino serial bootloader...

That is, by far, the most common way applications are upload to an Arduino.

Indeed, obvious really, especially given how often it appears in the messages window.

I have a question about setting fuses, but it needs to be in a different forum.

I went and used the sketch that turns the uno into a ISP programmer and was able to backup the FLASH and EEPROM.

When I go to write the file to the new Uno, I get error - fileio - invalid operation=0

C:\AVRDude>avrdude.exe -p atmega328p -c avrisp -P COM9 -b 19200 -e -U flash:w:flash_backup.hex:h

avrdude.exe: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.04s

avrdude.exe: Device signature = 0x1e950f (probably m328p)
avrdude.exe: erasing chip
avrdude.exe: reading input file "flash_backup.hex"
avrdude.exe: fileio: invalid operation=0
avrdude.exe: read from file 'flash_backup.hex' failed

avrdude.exe: safemode: Fuses OK (E:FD, H:DE, L:FF)

avrdude.exe done. Thank you.

same for writing EEPROM

Some Googling suggested adding a :m at the end of the command, that returned a different error -

C:\AVRDude>avrdude.exe -p atmega328p -c avrisp -P COM9 -b 19200 -e -U flash:w:flash_backup.hex:h:m

avrdude.exe: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.04s

avrdude.exe: Device signature = 0x1e950f (probably m328p)
avrdude.exe: erasing chip
avrdude.exe: reading input file "flash_backup.hex:h"
avrdude.exe: invalid byte value (flash_backup.hex:h) specified for immediate mode
avrdude.exe: read from file 'flash_backup.hex:h' failed

avrdude.exe: safemode: Fuses OK (E:FD, H:DE, L:FF)

avrdude.exe done. Thank you.

Help.

I went and used the sketch that turns the uno into a ISP programmer

avrdude.exe -p atmega328p -c avrisp -P COM9 -b 19200 -e -U flash:w:flash_backup.hex:h

Some Googling suggested adding a :m at the end of the command

That part of the command is right, but if you're using an Uno sketch as the programmer, this part:

-c avrisp

is wrong (it should be "-c stk500v1")
You shouldn't have been able to read the sketch without having the programmer type correct; why did you switch?

Hold on, I got it.

I had to change to add :i (intel format?) instead of :h (hex format)!

Topic solved!