Nano / CH340 Bootloader programming

I have looked everywhere for a solution to this, so forgive me if this is a redundant post. I just purchased a handful of Nano's (I can't find a US or "legit" distributor still selling this board, is this an obsolete board? If so, what's it's replacement? I'm trying to put this device inside a PS3 joystick housing so it needs to be small), apparently Chinese without a bootloader (unable to Upload the Blink sketch). So in the process of the ArduinoISP sketch, and an Instructable defining a pinout which seems superseded by the sketch for my Mega2650's. So I'm trying to figure out the pinout according to the Sketch info, when I notice the Nano silkscreening includes 2 Rst pins?! (Pins 3 and 28 are both labelled RST).

I have the CH340, and have installed the drivers. When the Nano is plugged directly into the USB, the Arduino IDE recognizes the port. I believe this means the driver is working?

Can someone point me to a Fritz or some other kind of info on how to wire up the Nano to a Mega in order to run the ArduinoISP sketch and get this Nano running?

Thank you

That'd by my assessment as well - since port appears, drivers are probably OK. Does the LED blink when you plug it in? If not, that implies that it hasn't been bootloaded. I recommend telling the IDE that it's an Uno instead of a nano (both before and after bootloading it) - the Uno bootloader (optiboot) is better (smaller, so more space for sketches), and 100% compatible with the Nano.
If the LED does blink, try telling the IDE that it's an Uno instead of a Nano, and see if that works for uploading.

There are countless diagrams of the wiring for ISP connections online. Have you used google? A quick search turns up pages upon pages of diagrams and tutorials. The connections are the same as for an Uno, or any other ATMega328 based board. The pins may be in different places, but the numbers are the same.
Many nano clones even have that 2x3 block of 6 pins that matches the pinout of most ISP programmers, to make it easy to connect a programmer to.

The nano brings reset out to multiple pins, yes. The pins are connected internally and you can use whichever reset pin you prefer.

Thank you, DrAzzy, for the quick reply. I actually made a cable for connecting the six pin headers between the Mega and the Nano. No luck. I found several diagrams, which appear to conflict with each other and the ArduinoISP sketch, when it comes to the Mega pinout which the sketch says is different than other Arduino modules. The pins identified in the ArduinoISP sketch do not appear electrically connected to the 6 pin header on the Mega. No problem, I tried multiple combinations. I tried reversing the Tx and Rx pins (a-la RJ-45 networking cables), but also rethought the acronymns MISO and MOSI and switched these back after a few failures.

I tried both the 6 pin header and individual pins on the Nano, but no diagram I've found identifies the SCK and RST pins on the Nano for programming--are these functions different / on different pins during flashing than during normal operation? I did find a very through "Instructable" which identifies the SCK as connected to pin 3 on the Nano, which the Nano silkscreening identifies as GND. This wasn't successful either. I've tried using the regular RST pin on the Nano as part of the critical 6 pins since electrically it buzzes out to the same pin. I've tried a pullup resistor on the Nano's RST line, and tying RST to GND while attempting to release it at the exact same time the upload begins (or shortly thereafter), since I read somewhere that this can actually work. No progress so far.

When plugged into the USB, the Nano's PWR light comes on, and the "L" light flashes erratically at first, then stabilizes at two flashes at a time for a few seconds, then a 3 flash burst and finally to a regular ~1 Hz flash (not the ~50% duty cycle of Blink which still refuses to upload). During programming, which the IDE occasionally claims to get all the way through without error, there is no activity on the Nano's Tx or Rx lights. The L light continues its 1Hz flash rate and there is no activity on the Mega pin 7 diode indicating communication underway (other than the startup pulse train). The Mega "heartbeat" pulse seems to operate nicely throughout the failure.

Typically, the IDE fails (quickly), with the following string of errors:
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0x03
avrdude: stk500_getsync() attempt 2 of 10: not in sync: resp=0xe0
avrdude: stk500_getsync() attempt 3 of 10: not in sync: resp=0xe0
avrdude: stk500_getsync() attempt 4 of 10: not in sync: resp=0xe0
avrdude: stk500_getsync() attempt 5 of 10: not in sync: resp=0x00
avrdude: stk500_getsync() attempt 6 of 10: not in sync: resp=0xe0
avrdude: stk500_getsync() attempt 7 of 10: not in sync: resp=0xe0
avrdude: stk500_getsync() attempt 8 of 10: not in sync: resp=0xe0
avrdude: stk500_getsync() attempt 9 of 10: not in sync: resp=0x00
avrdude: stk500_getsync() attempt 10 of 10: not in sync: resp=0xe0
Problem uploading to board. See http://www.arduino.cc/en/Guide/Troubleshooting#upload for suggestions.

Thanks again anyone for your thoughtfulness and replies.

To be 100% sure, check device manager if the driver is installed correct. Never had it with a CH340 chip but with the PL2303 it happened often that Windows did assign a COM number (thus it showed up in the IDE) but the driver failed (! next to the device in the device manager).

Also, I never received a Arduino from China without bootloader. Have you tried the use the Nano when you have Uno selected?

carrt01:
During programming, which the IDE occasionally claims to get all the way through without error, there is no activity on the Nano's Tx or Rx lights.

If you mean programming just via USB and the CH340 then you always should see the RX blink. Because that's a hardware thing, not a bootloader thing. If you don't see it blink then the CH340 isn't working.

But to burn a bootloader (and yes, it's a good idea to use the Uno bootloader (Optiboot) like DrAzzy said. Even when it came with a bootloader already). You have to connect the 6 pin header of the mega to the 6 pin header of the Nano except for the reset pin. The reset pin of the nano (pin 5 of the ISP header) should be connected to pin 53 of the Mega. You should also disable auto reset on the Mega, connect a +-10uF capacitor between reset and GND on the Mega.

septillion:
check device manager if the driver is installed correct.

Thank you for the reply. Yes, I've checked the Device Manager, which lists the CH340 on the COM port and indicates it is working properly.

septillion:
I never received a Arduino from China without bootloader. Have you tried the use the Nano when you have Uno selected? ... If you don't see it blink then the CH340 isn't working.... it's a good idea to use the Uno bootloader (Optiboot) like DrAzzy said.

Interesting feedback. I ordered a handful, I'll build another. This one does not flash the Rx light, either during standalone programming or during ArduinoISP bootloader programming. I have tried bootloader programming while selecting the Uno and although that has been unsuccessful thus far, will continue using that approach.

septillion:
But to burn a bootloader (and yes, . Even when it came with a bootloader already). You have to connect the 6 pin header of the mega to the 6 pin header of the Nano except for the reset pin. The reset pin of the nano (pin 5 of the ISP header) should be connected to pin 53 of the Mega. You should also disable auto reset on the Mega, connect a +-10uF capacitor between reset and GND on the Mega.

Good feedback, again. While I've seen portions of these ideas in various places on the internet, I haven't heard such a cohesive and comprehensive explanation thus far. I will pull the reset pin from the header and rebuild using this newly clarified information. (As an aside, I recall that in the early days of the PC, a similar problem was seen with the Intel 8086, solved by changing out a capacitor on the reset pin from the power supply.)

On the positive side, in my last attempt the IDE did appear to connect through the Mega and at least the IDE thought it was programming--a state which, alas, the IDE maintained all night until I disconnected power....

Thanks all for the feedback. I will continue to post updates and appreciate feedback. Perhaps this thread will help another soul down the road.

1 Like

To follow-up, I pulled the Reset line from the 6 pin header, added a 10uF capacitor and routed it to the Mega pin 53, as recommended by septillion, and set the ISP to "Uno" while programming through the Mega to the Nano (per both DrAzzy and septillion). No joy. Next, I built a second Nano. Bypassing the bootloader programming, I assumed the bootloader was already present and attempted to directly program Blink into the second Nano. Received the following error:

avrdude: ser_open(): can't open device "\.\COM6": Access is denied.

Suspecting the Windows machine again, I verified the CH340 COM port was present, unplugged / reinserted the Nano USB cable, and updated the driver in Device Manager. Windows responded that the current driver was the most up-to-date, and programming the Nano failed again. I also verified that the chip on the Nano, nearest the USB port, was a CH340G.

I guess I became spoiled, several years ago, to the expectation that when I plug my Mega into the USB port, it simply works. I expected this from all Arduino products. Among the "genuine" distributors listed on the Arduino.cc web site, I have found none yet selling the Nano, I wonder if there is a correlation here? This is frustrating, but I am not (yet) defeated.

As always, I welcome / appreciate feedback.

Hello,

although quite late, I want to add one thing: I had the same error messages with two cheap Nanos from China. After reading lot's of pages I found be random, that I had bought an Atmega168 version!
Just set CPU to this and it worked instantly.

Hope I saved somebody some time :slight_smile:

Regards