Flash read Error with new bootloader, OK with old

I have a Arduino Nano clone with old bootloader with CH340 chip. I am able to program it with arduino ide on windows pc selecting processor Atmega328p(old bootloader). There is a program availble for Android, ArduinoDroid. When I try to upload a program to the Nano via my android mobile it gives an error "stk500_recv() programmer is not responding". I borrowed an Arduino Uno from a friend and I can upload the program, indicating the hardware,software connection are working fine. I thought the only difference is the bootloader between Uno and Nano. So I updated the bootloader of Nano. It still doesnt work with a new problem.
With the new bootloader on the nano I get "avrdude: stk500_recv(): programmer is not responding" when I try to upload from PC using arduino ide. When on old bootloader this error was not there. Please help.
Posting the two compilation messages.

Nano with old Bootloader

FQBN: arduino:avr:nano:cpu=atmega328old
Using board 'nano' from platform in folder: C:\Users\ADMIN\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6
Using core 'arduino' from platform in folder: C:\Users\ADMIN\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6

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:\Users\ADMIN\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino17/etc/avrdude.conf"

         Using Port                    : COM4
         Using Programmer              : arduino
         Overriding Baud Rate          : 57600
         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: 2
         Firmware Version: 1.16
         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.00s

avrdude: Device signature = 0x1e950f (probably m328p)
avrdude: reading input file "C:\Users\ADMIN\AppData\Local\Temp\arduino\sketches\0FD7F435FD9B262A10C15B6DB4642CBE/COULOMETER.ino.hex"
avrdude: writing flash (13948 bytes):

Writing | ################################################## | 100% 4.36s

avrdude: 13948 bytes of flash written
avrdude: verifying flash memory against C:\Users\ADMIN\AppData\Local\Temp\arduino\sketches\0FD7F435FD9B262A10C15B6DB4642CBE/COULOMETER.ino.hex:
avrdude: load data flash data from input file C:\Users\ADMIN\AppData\Local\Temp\arduino\sketches\0FD7F435FD9B262A10C15B6DB4642CBE/COULOMETER.ino.hex:
avrdude: input file C:\Users\ADMIN\AppData\Local\Temp\arduino\sketches\0FD7F435FD9B262A10C15B6DB4642CBE/COULOMETER.ino.hex contains 13948 bytes
avrdude: reading on-chip flash data:

Reading | ################################################## | 100% 3.37s

avrdude: verifying ...
avrdude: 13948 bytes of flash verified

avrdude done.  Thank you.

Nano with New Bootloader

FQBN: arduino:avr:nano
Using board 'nano' from platform in folder: C:\Users\ADMIN\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6
Using core 'arduino' from platform in folder: C:\Users\ADMIN\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6

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:\Users\ADMIN\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino17/etc/avrdude.conf"

         Using Port                    : COM4
         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: reading input file "C:\Users\ADMIN\AppData\Local\Temp\arduino\sketches\0FD7F435FD9B262A10C15B6DB4642CBE/COULOMETER.ino.hex"
avrdude: writing flash (13948 bytes):

Writing | ################avrdude: stk500_loadaddr(): (a) protocol error, expect=0x14, resp=0x10
################################## | 100% 2.50s

avrdude: 13948 bytes of flash written
avrdude: verifying flash memory against C:\Users\ADMIN\AppData\Local\Temp\arduino\sketches\0FD7F435FD9B262A10C15B6DB4642CBE/COULOMETER.ino.hex:
avrdude: load data flash data from input file C:\Users\ADMIN\AppData\Local\Temp\arduino\sketches\0FD7F435FD9B262A10C15B6DB4642CBE/COULOMETER.ino.hex:
avrdude: input file C:\Users\ADMIN\AppData\Local\Temp\arduino\sketches\0FD7F435FD9B262A10C15B6DB4642CBE/COULOMETER.ino.hex contains 13948 bytes
avrdude: reading on-chip flash data:

Reading | avrdude: stk500_recv(): programmer is not responding
#avrdude: stk500_recv(): programmer is not responding
avr_read(): error reading address 0x0000
    read operation not supported for memory "flash"
avrdude: failed to read all of flash memory, rc=-2
avrdude: stk500_recv(): programmer is not responding

avrdude done.  Thank you.

Failed uploading: uploading error: exit status 1

One update, As I had used the Arduino IDE to flash bootloader, whenever I select Arduino Nano the programmer shows as Arduino as ISP. Do I need to change that?

Hi @dariods8474.

This indicates one of two things happened:

  • The "Burn Bootloader" operation was not successful.
  • The "Burn Bootloader" operation was successful, but you had Tools > Processor > ATmega328P (Old Bootloader) from the Arduino IDE menus when you performed the operation, so you burned the "old" bootloader to the Nano instead of the "new" bootloader as intended.

My recommendation is that you try the "Burn Bootloader" operation again. I'll provide comprehensive instructions you can follow to do that:

I'll provide instructions you can follow to do that:

A. Prepare "Arduino as ISP" programmer

  1. Disconnect the USB cable of the Arduino boards from your computer.
  2. Make the following connections between the pins on the Arduino Uno and the Nano:
    Uno Nano
    12 12
    VCC 5V (VCC on 3.3 V boards)
    13 13
    11 11
    10 RESET
    GND GND
  3. Connect the Arduino Uno to your computer with a USB cable.
  4. Select File > Examples > 11.ArduinoISP > ArduinoISP from the Arduino IDE menus.
    The "ArduinoISP" sketch will open in Arduino IDE.
  5. Select Tools > Board > Arduino AVR Boards > Arduino Uno from the Arduino IDE menus.
  6. Select the port of your Arduino Uno from Arduino IDE's Tools > Port menu.
  7. Select Sketch > Upload from the Arduino IDE menus.
  8. Wait for the upload to finish.

You are now ready to burn the bootloader using your "Arduino as ISP" programmer.

B. Burn Bootloader

Instructions for burning the bootloader:

  1. Select Tools > Board > Arduino AVR Boards > Arduino Nano from the Arduino IDE menus.
  2. Select Tools > Processor > ATmega328P from the Arduino IDE menus.
  3. Select Tools > Programmer > Arduino as ISP from the Arduino IDE menus.
  4. Select Tools > Burn Bootloader from the Arduino IDE menus.
  5. Wait for the process to finish successfully.
  6. Disconnect the USB cable of the Arduino Uno from your computer.
  7. Disconnect the Arduino Uno from the Nano.

The "new" bootloader will now be installed on the Nano. You should now be able to upload to the Nano board with Tools > Processor > ATmega328P selected from the Arduino IDE menus.

The Tools > Programmer menu selection is only used when you are doing Tools > Burn Bootloader or "Upload Using Programmer". When you're doing any other operations, including a standard "Upload", the Tools > Programmer menu selection is completely ignored.

So, except for when you are burning the bootloader, it makes no difference at all what you have selected from the Tools > Programmer menu.

While burning the new bootloader I did select Tools > Processor > ATmega328P. In the compilation message it was showing optiboot_atmega328.hex as the bootloader file. After loading the new bootloader if I select Tools > Processor > ATmega328P (Old Bootloader) the error is some 10 tries trying to upload the sketch and then it fails. With the new bootloader the sketch is compiled and uploaded(blink sketch works) but there is a read flash (verify) error. I again changed to old bootloader to verify and I can upload the sketch. The problem is with the new bootloader.

I see. Unfortunately I'm not sure what exactly would cause this verification failure.

The obvious answer is that the flash memory (or a related system) on the ATmega328P microcontroller has physical damage which was not previously detected due to some difference in the "old" bootloader.

1.The nano board had old bootloader
2. I updated to new and started receiving the error.
3. I reflashed the old bootloader, there are no read(verify)/ write errors
4. I reflashed the new bootloader, the same verify errors started again.
All procedure done to the same nano board using the same uno board while flashing bootloader. I am using the ISP connection on both the boards to interconnect except for the reset pin on the ISP connector on the nano connected to pin 10 on the Uno. All hardware used are the same including the ISP connector cable and the usb cable

Yes, I understand (but good idea for you to summarize the situation in case it is not clear to others).

As I said before, the only conclusion I can come to is that your board has permanent physical damage and must be replaced. But maybe one of the other forum helpers will have another idea.

Thanks for trying to help. I am unable to accept that the board has a physical damage. If it was so then I would receive the read(verify) error even with the old bootloader

Not necessarily so.

I found a solution. When burning the bootloader to Arduino nano I was selecting the board as Nano and in Tools > Processor > ATmega328P. Instead of that I selected Arduino Uno in the board selection. Then clicked Burn Bootloader. The new bootloader (optiboot) was flashed to the Nano. Now when I need to upload sketch I need to set the board as Uno not Nano. I gained additional flash space equal to the Uno. But unfortunately I still cannot use the android software to upload sketch.

I'm sorry to hear that. I don't have any experience with the "ArduinoDroid" app you are using on your Android device, so I'm not sure I will be able to provide much assistance, but I can suggest that you provide some additional information that will allow the forum helpers who are knowledgeable about ArduinoDroid to more effectively assist you:

Just to be clear, when you say "I can upload" here, do you mean that you were able to upload to the Arduino Uno using ArduinoDroid, or are you only referring to the ability to upload to the board using Arduino IDE?

Which USB to serial bridge chip does the Arduino Uno have? This is a black chip near the USB socket.

The chip will usually be identified by writing on the top. This might say something like "Atmel MEGA16U2" or "WCH CH340G" or "SILABS CP2102".

Examples:

Microchip ATmega16U2

📷

MakeMagazinDE - CC BY-SA 4.0 (cropped)

WCH CH340

📷

SparkFun - CC BY-SA 4.0 (cropped)

I ask because I'm wondering if perhaps the cause of the different results from uploading to the Nano vs. the Uno might be that the two boards have different USB chips.

I do see that CH340 support was explicitly added to ArduinoDroid:

https://www.arduinodroid.info/2015/07/ch340g-support.html

However, it looks like, unlike Arduino IDE, ArduinoDroid must be configured for the specific USB chip on the board:

https://www.arduinodroid.info/2014/03/custom-hardware-support.html

If you encountered any warning or error messages when you attempted the upload, please provide the full and exact text of those messages.

I can upload sketch to the Arduino Uno using the Desktop app Arduino IDE and also using the Android Mobile app using ArduinoDroid v6.31
The Arduino Uno has a Mega16u2 chip.
The error shown while using Android app for uploading sketch to Arduino Nano:

avrdue: Sent: 0 [30] [20] 
avrdue: Sent: 0 [30] [20] 
avrdue: Sent: 0 [30] [20] 
avrdue: usb_fill_buf(): usb_bulk_read() error=7
avrdue: stk500_recv(): programmer is not responding

avrdue done. Thank you.
Error: Problem uploading to board

Is there more output than that?

I see this:

https://www.arduinodroid.info/2014/03/custom-hardware-support.html

While uploading ("output" panel) you can see what implementation is used:
"CDC UART" ,
"FTDI UART bridge" ,
"SILABS UART bridge",
"CH340/CH341 bridge"

The official Arduino Nano board has the FTDI FT232R chip, so I would guess that ArduinoDroid is configured for Nano boards that have that chip. So I think you would need to use a hardware configuration specifically for the CH340 chip in order to upload to your Nano derivative board.

You could check which configuration is in use by looking to see which of those messages are displayed in the ArduinoDroid output when you upload.

ArduinoDroid Android app does support Ch340 chip

Did you select the "Uno CH340G" option before you uploaded?

I tried all Nano and Uno options

OK, unfortunately I don't have any other ideas. Hopefully one of the forum helpers who is more knowledgeable about ArduinoDroid will be able to help.