Go Down

Topic: Put an Arduino Uno in programming mode (Read 5208 times) previous topic - next topic

AdrianZa

Sep 10, 2015, 07:18 pm Last Edit: Sep 10, 2015, 08:30 pm by AdrianZa
Hello,

I have two Arduinos, one Atmega2560 and one Atmega328p (16MHz with optiboot from Nick Gammon Atmega_Board_Programmer).
I try to upload a sketch from Atmega2560 (RX1/TX1) to Atmega328p (in TX/RX), but Atmega328p fail to enter in programming mode.

Atmega2560 -> Atmega328p
D38 -> RST
TX1 -> RX
RX1 -> TX

I use the following code to reset Atmega328p:

Code: [Select]

digitalWrite (38, LOW);
delay (100); 
digitalWrite(38, HIGH);
delay(100)


After this, try to get in sync with Atmega328p:

Code: [Select]

 for (int i = 0; i < 16; i++) {
    Serial1.write((char)0x30);
    Serial1.write((char)0x20);
    delay(50);
  }


But nothing happens. Atmega328p responds with 0x00 0xFF instead of 0x14 0x10.
When I try the same code with Atmega2560 and Arduino Mini Pro (from SparkFun - I don't know what bootloader have) is working like a charm.

I suspect it is a problem with the reset time. I have tried many versions, but I have't found the right values.

Sorry for my English, but is not my first language. Thank you.

DrAzzy

Is the board actually running at 16mhz? Is the external crystal connected correctly?
ATTinyCore for x4/x5/x61/x7/x8/x41/1634/828/x313 megaTinyCore for the megaavr ATtinies - Board Manager:
http://drazzy.com/package_drazzy.com_index.json
ATtiny breakouts, mosfets, awesome prototyping board in my store http://tindie.com/stores/DrAzzy

AdrianZa

Running on 16MHz. I can upload using FTDI with no problem.

dmjlambert

Pro Mini usually uses a 57600 baud bootloader.  Optiboot usually is compiled to run at 115200.  Have a look the Arduino IDE's boards.txt file to see the baud rates.   Can you please post the results of your work when you get this going so we can see how to accomplish this type of programming from one board to another?

AdrianZa

I try at different bound rate (all of them). Indeed, with Pro Mini work only at 57600 bound rate.

CrossRoads

Rebootload the Promini as an Uno, then it will upload at 115200.  I bootload all my 328P designs as Uno, easy to keep track that way.
(unless I need to use A6/A7 with SMD parts, then I'll do things a little different).
Designing & building electrical circuits for over 25 years.  Screw Shield for Mega/Due/Uno,  Bobuino with ATMega1284P, & other '328P & '1284P creations & offerings at  my website.

AdrianZa

Rebootload the Promini as an Uno, then it will upload at 115200.  I bootload all my 328P designs as Uno, easy to keep track that way.
(unless I need to use A6/A7 with SMD parts, then I'll do things a little different).
Not Pro Mini is my problem. It is work. As I said, I have a 328P with optiboot (as an Uno) who fail to enter in programming mode.

dmjlambert

Can you please share your sketch which you use to send a program from Mega to the Pro Mini bootloader, so we can see how it is done?   I would like to learn about this.

mart256

#8
Sep 11, 2015, 12:43 pm Last Edit: Sep 11, 2015, 12:43 pm by mart256
Not Pro Mini is my problem. It is work. As I said, I have a 328P with optiboot (as an Uno) who fail to enter in programming mode.
Do as Crossroads says. This is to confirm that the problem may be the bootloader and not the hardware.

AdrianZa

Do as Crossroads says. This is to confirm that the problem may be the bootloader and not the hardware.
When try to upload in 328p (with optiboot as UNO) thru FTDI, from computer, work whit not problem. When try to upload in 328p (with optiboot as UNO) from Atmega2560 it is not working.

If is there a problem with the bootloader, I would be able to upload sketch thru FTDI from computer?

AdrianZa

Can you please share your sketch which you use to send a program from Mega to the Pro Mini bootloader, so we can see how it is done?   I would like to learn about this.

I will try to explain when I get in front of a PC. I write from phone now.

dmjlambert

It is possible you are doing commands which are not compatible with all bootloaders, such as Uno's bootloader.   Are you able to upload to the Pro Mini from the Mega?

AdrianZa

It is possible you are doing commands which are not compatible with all bootloaders, such as Uno's bootloader.   Are you able to upload to the Pro Mini from the Mega?
Yes. From the Atmega2560 to the pro Mini I can upload with no problem and it is working perfect.

mart256

I didnt mean that the bootloader is corrupt, I mean the bootloader may be in conflict with the uploader sketch. But its up to you if you want to check what its suggested. Good luck.


dmjlambert

Yes. From the Atmega2560 to the pro Mini I can upload with no problem and it is working perfect.
Ok if you can post the Mega code which works for uploading to the Pro Mini that will probably help.

Go Up