Programming using Serial2 on Mega2560

Hi,

I am trying to program a Mega2560 using Serial2. I have a serial to USB and am able to program the board using the rx0/tx0 pins with the help of the ftdi…

However when I try to program using the Serial2 the program does not get uploaded.

So, my question is how do I program the board using the RX/TX of Serial2? What changes do I have to make to the bootloader before uploading it or otherwise to enable the Serial2 pins to allow programming.

Thanks

What happened to pins 0 and 1? Why aren't you using them?

I have to use this to enable serial debugging and pins 0 and 1 are already being used as parts of other modules in the project we are working on.

I have read in forums and on arduino.cc that 0 and 1 can be used without any modifications. But unfortunately those Rx and tx pins are already being used.

So please advise, as to what can be done to enable programming using Serial2.

Would it not be easier to move the device on serial 0 to another serial port?

You could design your project so that it does not make a mess of the programming pins or use SPI.

Mark

We have an AtMega 16U2 attached to Rx0/Tx0 and we are working on getting it started, without much success so far.

As for Rx1/Tx1 we have an encoder on it since they share an interrupt pin. We thought this through but weren't able to foresee this problem of Serially programming and debugging which is now a necessity.

So this leaves us with Rx2/Tx2 and Rx3/Tx3 which we have been trying to figure out how to use to program.

I guess you where on the money to begin with, modify the bootloader. Look in the datasheet for the USART registers, replace 0 with 2 in the bootloader code registers.

I’ve never seen the code, but I guess it wouldn’t be too difficult.

We have an AtMega 16U2 attached to Rx0/Tx0 and we are working on getting it started, without much success so far.

For what? Why can't this be attached to RX2/TX2?

Reprogramming the bootloader doesn't seem to be within your skill scope.

PaulS:

We have an AtMega 16U2 attached to Rx0/Tx0 and we are working on getting it started, without much success so far.

For what? Why can't this be attached to RX2/TX2?

It has been attached for serial to usb conversion as was given on the product page of Arduino Mega2560. We haven't gotten it to work yet. But are working on it.

What likely changes maybe needed to the AtMegaBOOT.c file to enable programming using RX2/TX2.