Go Down

Topic: Burning the bootloader on a Chinese Nano (Read 10583 times) previous topic - next topic

lesept

Hi,
I recently bought unofficial Nanos on Ali***, but as I cannot see them with the IDE, I believe the bootloader is not burnt. So I searched and found some information on how to do it, such as:
Code: [Select]
http://www.instructables.com/id/How-To-Burn-a-Bootloader-to-Clone-Arduino-Nano-30/

I followed the instructions, double - triple checked the connexions and started to burn, but... I get this error message:

Code: [Select]
Arduino : 1.8.2 (Windows 10), Carte : "Arduino Nano, ATmega328"

avrdude: Expected signature for ATmega328P is 1E 95 0F
         Double check chip, or use -F to override this check.
Erreur lors de la gravure de la séquence d'initialisation.

Ce rapport pourrait être plus détaillé avec
l'option "Afficher les résultats détaillés de la compilation"
activée dans Fichier -> Préférences.


After activating the verbose options, I get more error messages:

Code: [Select]
Arduino : 1.8.2 (Windows 10), Carte : "Arduino Nano, ATmega328"

C:\Users\Chuwi\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino9/bin/avrdude -CC:\Users\Chuwi\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino9/etc/avrdude.conf -v -patmega328p -cstk500v1 -PCOM4 -b19200 -e -Ulock:w:0x3F:m -Uefuse:w:0xFD:m -Uhfuse:w:0xDA:m -Ulfuse:w:0xFF:m

avrdude: Version 6.3, compiled on Jan 17 2017 at 12:00:53
         Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
         Copyright (c) 2007-2014 Joerg Wunsch

         System wide configuration file is "C:\Users\Chuwi\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino9/etc/avrdude.conf"

         Using Port                    : COM4
         Using Programmer              : stk500v1
         Overriding Baud Rate          : 19200
avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0x15
avrdude: stk500_getsync() attempt 2 of 10: not in sync: resp=0x15
         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 : STK500
         Description     : Atmel STK500 Version 1.x firmware

avrdude: stk500_getparm(): (a) protocol error, expect=0x14, resp=0x14

avrdude: stk500_getparm(): (a) protocol error, expect=0x14, resp=0x02

avrdude: stk500_getparm(): (a) protocol error, expect=0x14, resp=0x10
         Hardware Version: 4728160
         Firmware Version: 0.4598883
         Topcard         : STK502
         Vtarget         : 1.8 V
         Varef           : 0.0 V
         Oscillator      : Off
         SCK period      : 0.1 us

avrdude: stk500_initialize(): (b) protocol error, expect=0x10, resp=0x01
avrdude: initialization failed, rc=-1
         Double check connections and try again, or use -F to override
         this check.

avrdude: stk500_disable(): protocol error, expect=0x14, resp=0x10

avrdude done.  Thank you.

Erreur lors de la gravure de la séquence d'initialisation.


Can someone explain what all this means and what I need to do to burn this bootloader?

I use another Nano clone, which perfectly works - so it's not a problem linked to the CH340 driver - to burn using the option "Arduino as ISP", keeping the same features (port, board type, processor).
A force d'essayer on finit par réussir... Donc, plus ça rate, plus on a de chances que ça marche (proverbe Sharduinok).

Robin2

#1
Nov 02, 2017, 01:07 pm Last Edit: Nov 02, 2017, 01:08 pm by Robin2
Have a look at Nick Gammon's chip detector program. It will show you the signature values on your Nano

His website also has a lot of other useful information.

...R
Two or three hours spent thinking and reading documentation solves most programming problems.

lesept

Thanks, I tried that board detector program, and here is what I get :

Code: [Select]
...
Bootloader name: ATmegaBOOT_168_diecimila
...


Code: [Select]

Atmega chip detector.
Written by Nick Gammon.
Version 1.20
Compiled on Nov  2 2017 at 18:36:06 with Arduino IDE 10802.
Attempting to enter ICSP programming mode ...
Entered programming mode OK.
Signature = 0x1E 0x94 0x0B
Processor = ATmega168PA
Flash memory size = 16384 bytes.
LFuse = 0xFF
HFuse = 0xDD
EFuse = 0xF8
Lock byte = 0xFF
Clock calibration = 0x9A
Bootloader in use: Yes
EEPROM preserved through erase: No
Watchdog timer always on: No
Bootloader is 2048 bytes starting at 3800

Bootloader:

3800: 0x0C 0x94 0x34 0x1C 0x0C 0x94 0x51 0x1C 0x0C 0x94 0x51 0x1C 0x0C 0x94 0x51 0x1C
3810: 0x0C 0x94 0x51 0x1C 0x0C 0x94 0x51 0x1C 0x0C 0x94 0x51 0x1C 0x0C 0x94 0x51 0x1C
3820: 0x0C 0x94 0x51 0x1C 0x0C 0x94 0x51 0x1C 0x0C 0x94 0x51 0x1C 0x0C 0x94 0x51 0x1C

...

3FC0: 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF
3FD0: 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF
3FE0: 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF
3FF0: 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF

MD5 sum of bootloader = 0x14 0x61 0xCE 0xDF 0x85 0x46 0x0D 0x96 0xCC 0x41 0xCB 0x01 0x69 0x40 0x28 0x1A
Bootloader name: ATmegaBOOT_168_diecimila

First 256 bytes of program memory:

00: 0x0C 0x94 0x35 0x00 0x0C 0x94 0x5D 0x00 0x0C 0x94 0x5D 0x00 0x0C 0x94 0x5D 0x00
10: 0x0C 0x94 0x5D 0x00 0x0C 0x94 0x5D 0x00 0x0C 0x94 0x5D 0x00 0x0C 0x94 0x5D 0x00
20: 0x0C 0x94 0x5D 0x00 0x0C 0x94 0x5D 0x00 0x0C 0x94 0x5D 0x00 0x0C 0x94 0x5D 0x00
30: 0x0C 0x94 0x5D 0x00 0x0C 0x94 0x5D 0x00 0x0C 0x94 0x5D 0x00 0x0C 0x94 0x5D 0x00
40: 0x0C 0x94 0xF2 0x03 0x0C 0x94 0x5D 0x00 0x0C 0x94 0x0D 0x02 0x0C 0x94 0x3F 0x02
50: 0x0C 0x94 0x5D 0x00 0x0C 0x94 0x5D 0x00 0x0C 0x94 0x5D 0x00 0x0C 0x94 0x5D 0x00
60: 0x0C 0x94 0x5D 0x00 0x0C 0x94 0x5D 0x00 0x6F 0x02 0x11 0x24 0x1F 0xBE 0xCF 0xEF
70: 0xD4 0xE0 0xDE 0xBF 0xCD 0xBF 0x11 0xE0 0xA0 0xE0 0xB1 0xE0 0xE2 0xE4 0xF9 0xE0
80: 0x02 0xC0 0x05 0x90 0x0D 0x92 0xAE 0x34 0xB1 0x07 0xD9 0xF7 0x21 0xE0 0xAE 0xE4
90: 0xB1 0xE0 0x01 0xC0 0x1D 0x92 0xA4 0x3F 0xB2 0x07 0xE1 0xF7 0x10 0xE0 0xCA 0xE6
A0: 0xD0 0xE0 0x04 0xC0 0x22 0x97 0xFE 0x01 0x0E 0x94 0x9B 0x04 0xC8 0x36 0xD1 0x07
B0: 0xC9 0xF7 0x0E 0x94 0xB3 0x02 0x0C 0x94 0x9F 0x04 0x0C 0x94 0x00 0x00 0x26 0xE0
C0: 0x40 0xE8 0x55 0xE2 0x60 0xE0 0x70 0xE0 0x8E 0xE4 0x91 0xE0 0x0E 0x94 0xAB 0x01
D0: 0x62 0xE0 0x71 0xE0 0x8E 0xE4 0x91 0xE0 0x0C 0x94 0x1D 0x03 0xE0 0x91 0x4E 0x01
E0: 0xF0 0x91 0x4F 0x01 0x01 0x90 0xF0 0x81 0xE0 0x2D 0x60 0x91 0x00 0x01 0x8E 0xE4
F0: 0x91 0xE0 0x09 0x95 0x6E 0xE1 0x71 0xE0 0x8E 0xE4 0x91 0xE0 0x0E 0x94 0x00 0x03

Programming mode off.


What should I do now?
A force d'essayer on finit par réussir... Donc, plus ça rate, plus on a de chances que ça marche (proverbe Sharduinok).

Robin2

What should I do now?
Select an option from Tools/Board that uses an Atmega 168.

...R
Two or three hours spent thinking and reading documentation solves most programming problems.

lesept

I tried the sketch 'Atmega_Board_Programmer' and it behaved well.
But when I try to upload an empty sketch in the Nano clone, here is what I get :

Code: [Select]
avrdude: stk500_getsync() attempt 2 of 10: not in sync: resp=0x85

The whole thing:
Code: [Select]
Arduino : 1.8.2 (Windows 10), Carte : "Arduino Nano, ATmega328"

...

Compilation du croquis...

...

Le croquis utilise 444 octets (1%) de l'espace de stockage de programmes. Le maximum est de 30720 octets.
Les variables globales utilisent 9 octets (0%) de mémoire dynamique, ce qui laisse 2039 octets pour les variables locales. Le maximum est de 2048 octets.
C:\Users\Chuwi\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino9/bin/avrdude -CC:\Users\Chuwi\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino9/etc/avrdude.conf -v -patmega328p -carduino -PCOM4 -b57600 -D -Uflash:w:C:\Users\Chuwi\AppData\Local\Temp\arduino_build_573536/Vide.ino.hex:i

avrdude: Version 6.3, compiled on Jan 17 2017 at 12:00:53
         Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
         Copyright (c) 2007-2014 Joerg Wunsch

         System wide configuration file is "C:\Users\Chuwi\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino9/etc/avrdude.conf"

         Using Port                    : COM4
         Using Programmer              : arduino
         Overriding Baud Rate          : 57600
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0x85
Bibliothèque non valide trouvée dans C:\Users\Chuwi\Documents\Arduino\libraries\arduino_sketches-master : C:\Users\Chuwi\Documents\Arduino\libraries\arduino_sketches-master
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 2 of 10: not in sync: resp=0x85
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 3 of 10: not in sync: resp=0x85
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 4 of 10: not in sync: resp=0x85
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 5 of 10: not in sync: resp=0x85
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 6 of 10: not in sync: resp=0x85
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 7 of 10: not in sync: resp=0x85
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 8 of 10: not in sync: resp=0x85
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 9 of 10: not in sync: resp=0x85
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 10 of 10: not in sync: resp=0x85

avrdude done.  Thank you.

Problème de téléversement vers la carte. Voir http://www.arduino.cc/en/Guide/Troubleshooting#upload pour suggestions.
Bibliothèque non valide trouvée dans C:\Users\Chuwi\Documents\Arduino\libraries\arduino_sketches-master : C:\Users\Chuwi\Documents\Arduino\libraries\arduino_sketches-master
Bibliothèque non valide trouvée dans C:\Users\Chuwi\Documents\Arduino\libraries\arduino_sketches-master : C:\Users\Chuwi\Documents\Arduino\libraries\arduino_sketches-master


What is going wrong ? Is the bootloader properly loaded ?
A force d'essayer on finit par réussir... Donc, plus ça rate, plus on a de chances que ça marche (proverbe Sharduinok).

lesept

Select an option from Tools/Board that uses an Atmega 168.

...R
I get the same result:
Code: [Select]
avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0xf8
only the code changes from 0x85 to 0xf8
A force d'essayer on finit par réussir... Donc, plus ça rate, plus on a de chances que ça marche (proverbe Sharduinok).

Robin2

#6
Nov 02, 2017, 10:59 pm Last Edit: Nov 02, 2017, 11:01 pm by Robin2
I get the same result:
Code: [Select]
avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0xf8
That is not the same message as in your Original Post where you said it was
Quote
avrdude: Expected signature for ATmega328P is 1E 95 0F
Not only is it a different message but it is a different type of message. In the Original Post avrdude was communicating properly but getting the wrong information. In your Reply #5 it is not communicating at all - perhaps because the wrong serial port is selected or the wiring is incorrect.

You need to describe in full detail how you are trying to load the bootloader code. For example are you using an Uno with the ArduinoISP program loaded onto it as the programmer for loading the bootloader onto the Nano?

Also, I presume that when you wrote Reply #5 you had selected a different Board as the destination - but you have not told us what board you selected.

I know it is tedious, but you must give us all the details. We cannot look over your shoulder to see your PC screen.

...R
Two or three hours spent thinking and reading documentation solves most programming problems.

lesept

You are right, I'll try to explain everything in details. I use windows 10.

In the beginning, I thought I had bought chinese Nano equipped with Atmega 328. In message #0, I tried to burn the bootloader using another Nano clone, but this one is equipped with an Atmega 328. I uploaded the sketch 'ArduinoISP' on it, connected both arduinos and burned using the option 'Arduino as ISP'. The parameters of the IDE were Nano, Atmega328. This led to the first message.

Then in answer #1, you suggested I read Gammon's post, which I did. I downloaded the archive, tried hard to understand... and run the board detector program, which led to answer #2. Seeing no answer, I decided to try the 'board programmer', which I believed uploaded the bootloader. Is it what it did?

Then I tried to upload a simple sketch into the Nano and got the result from answer #4. Still believing I had an Atmega 328 at that time...

Until I saw your answer #3. So I tried to change to Atmega 168 and got the same type of error, answer #5.

So I think there is a bootloader in this nano now, uploaded by the board programmer, but as a newbie, I'm not sure... I don't know what else to do now.
A force d'essayer on finit par réussir... Donc, plus ça rate, plus on a de chances que ça marche (proverbe Sharduinok).

Robin2

Your Reply #7 is confusing because you refer to 2 nanos and I don't know which is which. Maybe call them nanoA and nanoB.

If you think that Nick Gammon's board programmer uploaded a bootloader I suggest you repeat the whole process and read carefully what type of chip it thinks it is uploading the bootloader to and what bootloader it uploads. Maybe copy the information and paste it in your next Reply.

...R
Two or three hours spent thinking and reading documentation solves most programming problems.

lesept

#9
Nov 03, 2017, 11:42 pm Last Edit: Nov 04, 2017, 12:33 pm by lesept
So NanoA, the working one, is an Atmega 328
NanoB, not working, is an Atmega 168, but I didn't know that when I used the board programmer. So I may have chosen, if the option is asked for (which I'm not sure of because the program can recognize its target), I may have chosen to program a bootloader for Atmega 328...

I'll try again tomorrow morning and watch carefully to tell you what I did precisely. It's almost midnight here and I had a looooong day today with the kids!
A force d'essayer on finit par réussir... Donc, plus ça rate, plus on a de chances que ça marche (proverbe Sharduinok).

lesept

Here is what Ido :

First connect working NanoA to bad NanoB using the connexion scheme shown here:
Code: [Select]
http://www.instructables.com/id/How-To-Burn-a-Bootloader-to-Clone-Arduino-Nano-30/

Then I connect NanoA to the computer running the IDE on Windows10. I use the option "use Arduino as ISP" and run the board programmer sketch on NanoA from Nick Gammon"s github.

Here is what I get on the console:
Code: [Select]

Atmega chip programmer.
Written by Nick Gammon.
Version 1.37
Compiled on Nov  4 2017 at 10:24:44 with Arduino IDE 10802.
Attempting to enter ICSP programming mode ...
Entered programming mode OK.
Signature = 0x1E 0x94 0x0B
Processor = ATmega168PA
Flash memory size = 16384 bytes.
LFuse = 0xFF
HFuse = 0xDD
EFuse = 0xF8
Lock byte = 0xFF
Clock calibration = 0x91
Bootloader address = 0x3E00
Bootloader length = 512 bytes.
Type 'Q' to quit, 'V' to verify, or 'G' to program the chip with the bootloader ...


Obviously it recognized the processor. Then I type G and the console says:
Code: [Select]
Fixing low fuse setting ...
Programming mode off.
Attempting to enter ICSP programming mode ...
Entered programming mode OK.
Erasing chip ...
Writing bootloader ...
Committing page starting at 0x3E00
Committing page starting at 0x3E80
Committing page starting at 0x3F00
Committing page starting at 0x3F80
Written.
Verifying ...
No errors found.
Writing fuses ...
LFuse = 0xC6
HFuse = 0xDD
EFuse = 0xFC
Lock byte = 0xEF
Clock calibration = 0x91
Done.
Programming mode off.
Type 'C' when ready to continue with another chip ...


Then C and Q to continue and quit.
A force d'essayer on finit par réussir... Donc, plus ça rate, plus on a de chances que ça marche (proverbe Sharduinok).

lesept

Then I connect the NanoB to the IDE, using processor Atmega 168 and AVRISP.mkll
I load the blink sketch and run it and I get:

Code: [Select]
avrdude: Version 6.3, compiled on Jan 17 2017 at 12:00:53
         Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
         Copyright (c) 2007-2014 Joerg Wunsch

         System wide configuration file is "C:\Users\Chuwi\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino9/etc/avrdude.conf"

         Using Port                    : COM4
         Using Programmer              : arduino
         Overriding Baud Rate          : 19200
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0x83
A force d'essayer on finit par réussir... Donc, plus ça rate, plus on a de chances que ça marche (proverbe Sharduinok).

Robin2

Then I connect the NanoB to the IDE, using processor Atmega 168 and AVRISP.mkll
I have never figured out (i.e have not bothered to) what the differen programmer options mean.

Mine is always set to Arduino as ISP and I can upload to an Uno or Mega with the regular USB cable and to a breadboard Atmega 328 using a USB-TTL cable and to an Attiny1634 using an Atmega328 as the programmer (like you did for loading the bootloader).

...R
Two or three hours spent thinking and reading documentation solves most programming problems.

lesept

#13
Nov 04, 2017, 04:01 pm Last Edit: Nov 04, 2017, 04:03 pm by lesept
I tried the Loopback test:
Code: [Select]
https://forum.arduino.cc/index.php?topic=73748.0
And it works: all the data sent are echoed back.
Code: [Select]
This means that the host computer hardware driver, USB cable, and USB to serial converter are all working.
How can I check that the bootloader is correctly installed, and that it's the proper one?
A force d'essayer on finit par réussir... Donc, plus ça rate, plus on a de chances que ça marche (proverbe Sharduinok).

Robin2

I tried the Loopback test:
That test is irrelevant. Notice how the Arduino is permanently reset - that means it is deliberately not working. All that is being tested is the USB-TTL conversion process.

Did you try what I suggested in Reply #12

...R
Two or three hours spent thinking and reading documentation solves most programming problems.

Go Up