Read and Write flash error

I have a board in a machine that I never wrote the source code for. I want to upload my build on there but in case anything goes wrong I want to make a backup.

All this is now tested on my development board so I don't break the current live machine.

So far my research has got me to read a hex file from the attached board.

“C:/Program Files (x86)/Arduino/hardware/tools/avr/bin/avrdude” -C “C:/Program Files (x86)/Arduino/hardware/tools/avr/etc/avrdude.conf” -D -v -p atmega328p -c arduino -P COM13 -b 115200 -U flash:r:”test2.hex”:i

This creates a hex file that is 78kb.

using this to write the hex to the board -U flash:w:”test2.hex”:i

Thows

avrdude: Version 6.3-20190619
         Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
         Copyright (c) 2007-2014 Joerg Wunsch

         System wide configuration file is "C:/Program Files (x86)/Arduino/hardware/tools/avr/etc/avrdude.conf"

         Using Port                    : COM13
         Using Programmer              : arduino
         Overriding Baud Rate          : 115200
         AVR Part                      : ATmega328P
         Chip Erase delay              : 9000 us
         PAGEL                         : PD7
         BS2                           : PC2
         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        65    20     4    0 no       1024    4      0  3600  3600 0xff 0xff
           flash         65     6   128    0 yes     32768  128    256  4500  4500 0xff 0xff
           lfuse          0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
           hfuse          0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
           efuse          0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
           lock           0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
           calibration    0     0     0    0 no          1    0      0     0     0 0x00 0x00
           signature      0     0     0    0 no          3    0      0     0     0 0x00 0x00

         Programmer Type : Arduino
         Description     : Arduino
         Hardware Version: 3
         Firmware Version: 4.4
         Vtarget         : 0.3 V
         Varef           : 0.3 V
         Oscillator      : 28.800 kHz
         SCK period      : 3.3 us

avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.00s

avrdude: Device signature = 0x1e950f (probably m328p)
avrdude: safemode: lfuse reads as 0
avrdude: safemode: hfuse reads as 0
avrdude: safemode: efuse reads as 0
avrdude: reading input file "test2.hex"
avrdude: writing flash (32768 bytes):

Writing | #################################################  | 98% 5.64s
avrdude: stk500_paged_write(): (a) protocol error, expect=0x14, resp=0x10
Writing | ################################################## | 99% 5.72savrdude: stk500_recv(): programmer is not responding
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_recv(): programmer is not responding

If I write the build from Arduino IDE it works correctly. Located C:\Users\USER\AppData\Local\Temp\arduino_build_379183

The build that Adruino IDE creates is only 14kb not the 78kb that is read fro the device.

Other details:

Board Ardunio UNO

I am now stuck so please help.

TLDR: I want to dump the current binary from a board as a backup in case the new build doesn't work. And I do not have the source for the current binary.

I think the bootloader is being prevented from overwriting itself, by the fuse settings. The bootloader and avrdude are not aware of the fuse settings, so you get an error. Your test program probably works, try it.

Being very new to this a lot of what you said went over my head....

We bit the bullet in the end and just updated the build on the device. This worked so there was no need to backup the original binary but thanks for the help.