Uploading sketch to pro mini using mega2560

I have been reading on how to do this but I can't seem to get it to work. I connect the ground and 5v pins on the mega to gnd and vcc on the pro mini. I connect the mosi, miso, and sck pins on the mini to 50, 51, and 52 on the mega. I also connect the reset pin on the mini to 53 on the mega. I select pro mini from the list of boards, select appropriate processor, com, and select arduino as isp. I uploaded the arduino as isp sketch to the mega previously and when I try to upload I get this error:

Arduino: 1.8.9 (Windows 8.1), Board: "Arduino/Genuino Mega or Mega 2560, ATmega2560 (Mega 2560)"

Sketch uses 2944 bytes (9%) of program storage space. Maximum is 30720 bytes.
Global variables use 271 bytes (13%) of dynamic memory, leaving 1777 bytes for local variables. Maximum is 2048 bytes.
C:\Program Files (x86)\Arduino\hardware\tools\avr/bin/avrdude -CC:\Program Files (x86)\Arduino\hardware\tools\avr/etc/avrdude.conf -v -patmega328p -carduino -PCOM12 -b57600 -D -Uflash:w:C:\Users\USER\AppData\Local\Temp\arduino_build_561631/Aerator_Final.ino.hex:i 

avrdude: Version 6.3-20171130
         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                    : COM12
         Using Programmer              : arduino
         Overriding Baud Rate          : 57600
avrdude: ser_open(): can't set com-state for "\\.\COM12"

avrdude done.  Thank you.

An error occurred while uploading the sketch

This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.

bigone5500:
I also connect the reset pin on the mini to 53 on the mega.

This is wrong. It should be connected to pin 10 on the Mega.

However, that issue is unrelated to this error:

bigone5500:

avrdude: ser_open(): can't set com-state for "\\.\COM12"

Make sure you have the correct port for your Mega selected from the Arduino IDE's Tools > Port menu.

Sometimes the port will be labeled with the board name in the menu. Other times it will not. If you don’t know which port is your Arduino, you can find it like this:

  • Unplug your Arduino board from the computer.
  • Tools > Port
  • Note the ports, if any, listed in the menu.
  • Close the Tools menu
  • Plug your Arduino board into the computer.
  • Tools > Port - The new port listed in the menu is your Arduino board.

If COM12 is the correct port, try restarting your computer.

you invoked serial upload to ISP programmer?
for Serial upload wire RX/TX of Mini to RX1/TX1 of the Mega and use the SerialPassthrough example sketch (set the correct baud rate in the sketch)

So to touch on what I have been reading, I connect the two boards as such:

Mega to Mini
Gnd to Gnd
5V to VCC
50 to 12
51 to 11
52 to 13
10 to RST

Am I correct that I need to use the Arduino as ISP sketch on the Mega to upload to the Pro Mini? If so, then I should select pro mini, 5v 16mhz, and proper port for the Mega. I then select arduino as ISP in programmer.

Any incorrectness in this please correct me.

Thanks.

Well I went ahead and tried the above method. I can't get this thing to program for the life of me. There needs to be a bullet proof method of programming these things.

Please do this:

  • (In the Arduino IDE) File > Preferences
  • Check the checkbox next to "Show verbose output during: upload
  • Click "OK"
  • Tools > Burn Bootloader
  • After the Burn Bootloader process fails, you'll see a button on the right side of the orange bar "Copy error messages". Click that button.
  • In a forum reply here, click on the reply field.
  • Click the </> button on the forum toolbar. This will add the forum's code tags markup to your reply.
  • Press "Ctrl + V". This will paste the Burn Bootloader output between the code tags.
  • Move the cursor outside of the code tags before you add any additional text to your reply.

pert:

  • Tools > Burn Bootloader

Per, OP doesn't want to burn the bootloader. They used "Upload" command

Oops. Thanks Juraj.

bigone5500 you need to do Sketch > Upload Using Programmer to accomplish what you are trying to do. You can't do a regular Sketch > Upload or press the Upload button. That would require that you have a USB to TTL serial adapter connected to your Pro Mini instead of the Mega used as an Arduino as ISP.

pert:
Oops. Thanks Juraj.

bigone5500 you need to do Sketch > Upload Using Programmer to accomplish what you are trying to do. You can't do a regular Sketch > Upload or press the Upload button. That would require that you have a USB to TTL serial adapter connected to your Pro Mini instead of the Mega used as an Arduino as ISP.

or use the Mega as USB to TTL serial adapter

pert:
Oops. Thanks Juraj.

bigone5500 you need to do Sketch > Upload Using Programmer to accomplish what you are trying to do. You can't do a regular Sketch > Upload or press the Upload button. That would require that you have a USB to TTL serial adapter connected to your Pro Mini instead of the Mega used as an Arduino as ISP.

OK. I have never used that command before. I will try it in a little while. I have been outside working and for some reason I got tired... Imagine that. LOL.

Thanks for your help!

So I have ditched the mega method and I am trying to do the upload with uno with the chip removed. I have connected the gnd to gnd, 5v to vcc, rx to rx, tx to tx, and reset to rst. I see others on youtube using this method but it does not work for me.

What could I be doing wrong?

Also, I have it set to pro mini, 5v 16mhz, and the port for the uno. I have it set to avrisp mkII. I am using the upload button. I get this error.

Arduino: 1.8.9 (Windows 8.1), Board: "Arduino Pro or Pro Mini, ATmega328P (5V, 16 MHz)"

Sketch uses 930 bytes (3%) of program storage space. Maximum is 30720 bytes.
Global variables use 9 bytes (0%) of dynamic memory, leaving 2039 bytes for local variables. Maximum is 2048 bytes.
C:\Program Files (x86)\Arduino\hardware\tools\avr/bin/avrdude -CC:\Program Files (x86)\Arduino\hardware\tools\avr/etc/avrdude.conf -v -patmega328p -carduino -PCOM11 -b57600 -D -Uflash:w:C:\Users\user\AppData\Local\Temp\arduino_build_68805/Blink.ino.hex:i 

avrdude: Version 6.3-20171130
         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                    : COM11
         Using Programmer              : arduino
         Overriding Baud Rate          : 57600
avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0xc0
avrdude: stk500_getsync() attempt 2 of 10: not in sync: resp=0x00
avrdude: stk500_getsync() attempt 3 of 10: not in sync: resp=0x00
avrdude: stk500_getsync() attempt 4 of 10: not in sync: resp=0x00
avrdude: stk500_getsync() attempt 5 of 10: not in sync: resp=0x00
avrdude: stk500_getsync() attempt 6 of 10: not in sync: resp=0x00
avrdude: stk500_getsync() attempt 7 of 10: not in sync: resp=0x00
avrdude: stk500_getsync() attempt 8 of 10: not in sync: resp=0x00
avrdude: stk500_getsync() attempt 9 of 10: not in sync: resp=0x00
avrdude: stk500_getsync() attempt 10 of 10: not in sync: resp=0x00

avrdude done.  Thank you.

An error occurred while uploading the sketch

This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.

When you did an Upload Using Programmer the bootloader was erased. The bootloader is necessary to do a standard upload. If you want to do a standard Upload, you'll need to connect your Mega back up as an Arduino as ISP, then do a Tools > Burn Bootloader first.

Ok. I'll try that. I don't know why I am having so much trouble now. I used to be able to program these things easily. There must have been something changed in the past year.

My understanding is that you have had two separate problems so far:

  • Trying to use the Upload command to upload via an ISP programmer.
  • Trying to do a serial upload after you erased the bootloader via Upload Using Programmer.

There has not been anything done that would change either of those issues in all the years I've worked with Arduino.

The easiest way to work with the Pro Mini is to buy a USB to TTL serial adapter board or cable that plugs right into the 1x6 header that's along one of the short edges of the Pro Mini. The Pro Mini comes with the bootloader installed so you can just plug in the adapter and hit Upload. You can buy the USB to TTL serial adapter boards on eBay for $1.28 USD w/ free shipping from China. They're also a really useful tool to have on hand. It's well worth spending $1.28 to save all the hassle and wasted time of trying to use an Arduino as ISP or a jerry rigged Uno to upload. I like these ones:
https://www.ebay.com/itm/382715233411

pert:
My understanding is that you have had two separate problems so far:

  • Trying to use the Upload command to upload via an ISP programmer.
  • Trying to do a serial upload after you erased the bootloader via Upload Using Programmer.

There has not been anything done that would change either of those issues in all the years I've worked with Arduino.

The easiest way to work with the Pro Mini is to buy a USB to TTL serial adapter board or cable that plugs right into the 1x6 header that's along one of the short edges of the Pro Mini. The Pro Mini comes with the bootloader installed so you can just plug in the adapter and hit Upload. You can buy the USB to TTL serial adapter boards on eBay for $1.28 USD w/ free shipping from China. They're also a really useful tool to have on hand. It's well worth spending $1.28 to save all the hassle and wasted time of trying to use an Arduino as ISP or a jerry rigged Uno to upload. I like these ones:
https://www.ebay.com/itm/382715233411

So I went on ebay and bought the module you posted. I have a couple of those already but none with the ftdi chip. The two I have use the CH340G and probably clone Prolific chips. They do not work for me. I can't figure out why but I think the drivers are for genuine chips and not clone chips.

Anyway I ordered the one you posted and another with the FTDI chip that ships a bit faster.

I will wait for them to arrive and try them out. I'll post back with my results.

Thanks.

bigone5500:
So I went on ebay and bought the module you posted. I have a couple of those already but none with the ftdi chip. The two I have use the CH340G and probably clone Prolific chips. They do not work for me. I can't figure out why but I think the drivers are for genuine chips and not clone chips.

Anyway I ordered the one you posted and another with the FTDI chip that ships a bit faster.

I will wait for them to arrive and try them out. I'll post back with my results.

Thanks.

do you reset the mini right before upload to activate the bootloader?

bigone5500:
I have a couple of those already but none with the ftdi chip. The two I have use the CH340G and probably clone Prolific chips. They do not work for me.

The CH340 are good too. I haven't used the Prolific chips as much, but they should do the trick. The biggest problem you'll find with these USB to TTL serial adapter boards is that many of them don't use the standard "FTDI header" pinout:

  • DTR or RTS
  • RX
  • TX
  • 5V
  • CTS
  • GND

You need that pinout in order to be able to plug the adapter right in to the Pro Mini. Sure, you can use some jumper wires to adapt a non-standard adapter pinout, but that's a hassle and introduces the opportunity for miswiring.

Worse, some of the adapter boards don't even break out the DTR or RTS pin, which is needed for the auto-reset during uploads. You can always manually reset the Pro Mini at just the right time, but who wants to do that when you can pay a few cents for for an adapter that does it automatically?

There are adapter boards with chips other than the FTDI FT232 which have the correct pinout, and those will work just as well. They take a bit more searching on eBay to find and the price is about the same, so I default to the FT232 boards.

bigone5500:
I think the drivers are for genuine chips and not clone chips.

The truth is that the $1.28 FT232 boards have counterfeit chips. That was a problem some years ago when FTDI released a version of their Windows driver that "bricked" the counterfeits (actually you could revive them with a bit of effort), but there was a lot of negative reaction to that so FTDI soon released a new driver version that doesn't brick the counterfeits. So I don't think you'll have any problems caused by the counterfeit FT232. I've been using these for years with no problems.

I haven't heard anything about clone or counterfeit CH340. I think that chip would not be an attractive target, since the original ones are already so cheap.

I have heard that there was an issue with driver support for either the counterfeit PL2303 or CP2102 (I can't remember which one).

Juraj:
do you reset the mini right before upload to activate the bootloader?

Yes, I have tried the reset trick but I can't seem to get it right. I have also read that you need to use the DTR pin somehow but I don't really know. I have tried a few ways to connect it to my serial adapter but nothing. I pressed the pins of the adapter into a mini breadboard and pushed jumper wires through the holes in the pro mini into the opposite side of the breadboard. I then jumpered to the adapter and played around with it a while. I got frustrated so I quit for a while to think about it. I have since ordered a couple different adapters with the FTDI chips and when they arrive I'll try it out then. The first one should be here monday.

I'll post back with my results.

Thanks for all the help!

If you connect the DTR pin from the USB to TTL serial adapter to the pin marked "GRN" on the Pro Mini, it will be automatically reset at the right time in the upload.

If you can't make this connection, then you need to watch the black console window and press the reset button as soon as you see the lines like:

Sketch uses 2944 bytes (9%) of program storage space. Maximum is 30720 bytes.
Global variables use 271 bytes (13%) of dynamic memory, leaving 1777 bytes for local variables. Maximum is 2048 bytes.

The confusing thing is that you might think you should press reset as soon as you click the "Upload" button. However, the Arduino IDE compiles the sketch before starting the upload. The bootloader only runs for a short time before timing out, so if you press the reset button too soon, then it may have already exited the bootloader before the upload process starts.