Programming Arduino Pro Mini 328 with UART2 of TX2

Hi there,

I am having issues uploading a sketch to my ATmega328P chip which is on a custom board identical to the Arduino Mini Pro. This board is connected to a TX2 module setup. The Rx and Tx lines goes directly to TX2 but through a 5V <-> 1.8V level shifter and we downloaded the Arduino IDE on Ubuntu.

If we connect a USB dongle to the Rx and Tx lines on our custom board to the TX2 carrier board setup, we can successfully upload the sketch.

But we expect that we do not need to use a dongle, since the Rx and Tx signal lines from the Atmega328P on our custom board goes directly to the TX2 module via a connector. When we try to upload a sketch without the dongle, we get this error

avrdude: arduino_read_sig_bytes(): (a) protocol error, expect=0x10, resp=0x0e
avrdude: error reading signature data for part “ATMEGA328P”, rc=-3
avrdude: error reading signature data, rc=-3
avrdude: stk500_disable(): protocol error, expect 0x14 resp=0x00

The Tx and Rx lines works, since without the dongle I can read and write bytes using the Arduino serial monitor. This shows that UART communication (without the dongle) between our custom board that has the Atmega328P and through the connector to the TX2 module is working. However, we just cannot upload the sketch without the dongle.

We do the same steps, press upload, press the reset button but it does not work. When we got our Atmega328p it needed a bootloader, so I used an Arduino to burn the bootloader in it. I followed these steps

where I wired it to an Arduino open the AdruinoISP sketch and burned the bootloader onto the Atmega328p.

We are using /dev/ttyTHS1 at 9600 baud rate.

Has anyone managed to program the Arduino without using a USB through the Arduino IDE on the TX2? Any help would be very much appreciated!

So far as I know the UARTs are 3.3V TTL logic level. Which physical connector are you using? You might want to double check the logic level at the Jetson side.

Hi linuxdev, thank you for the response. I believe on the Arduino side the logic level for the UART is 5V and the Jetson side UART2 is 1.8V. We are using FX23-120S-0.5SV to connect the UART signals on our custom carrier board to our custom Arduino Mini pro board. I can see the UART working fine on the scope and through the translator. I can program when using an FTDI break out board. But I just can’t program it without one, just wanted to know if anyone can program without the FTDI chip. I do not understand why we would need the FTDI since all it does is convert USB to serial UART interface, the signals coming from the Arduino is already serial UART and we connect it directly to the UART pins of the TX2.

Is it possible one side of the connection is being told to use CTS/RTS flow control, but the other side is not? If that is the case, then one side could send and the other could not send.

That is a good observation. I noticed TX2 has UART2_CTS and UART2_RTS pins but they are not connected to the Arduino Pro Mini board. How do we turn off CTS/RTS flow control on the Jetson side?

I have not tested doing this with direct UART manipulation, but a very reliable way to do this (at least while testing) is to use loopback with gtkterm or another serial terminal. I’d wire the RX and TX together (optionally CTS and RTS), add gtkterm (“sudo apt-get install gtkterm”), and run this as root or a user with permissions:

gtkterm -b 8 -t 1 -s 9600 -p /dev/ttyTHS1

Note that the lack of option “-w” implies disabling hardware flow control.

There are other ways as well, but UARTs are not plug-n-play…they have no ability (for the most part) to be queried. When you query for a serial UART setting what you are getting is the driver’s settings…if the driver was set to something the UART doesn’t accept, then you will never know from a simple driver query.

Here are some example stty manipulations (adjust ofr your case):

To read a port:
stty -a -F /dev/ttyTHS2

To set 115200:
stty -F /dev/ttyTHS2 115200

To set 115200 two stop bits:
stty -F /dev/ttyTHS2 115200 cstopb

To set 115200 but only one stop bit us a hyphen on cstopbit:
stty -F /dev/ttyTHS2 115200 -cstopbit

Note that “crtscts” is flow control. Using a hyphen ("-crtscts") in front implies “no” flow control. “man stty” will show a lot of options, but not all UARTs support all options (even if the driver doesn’t complain).

Thank you linuxdev, I will give that a try!

Once I run gtkterm -b 8 -t 1 -s 9600 -p /dev/ttyTHS1 I noticed it open a terminal. Can I use the IDE still on the Ubuntu to program the Arduino or do I have to set everything up through terminal now? I work mostly on Hardware so not very familiar with firmware. I really appreciate the help, thank you!

This is just a wiring test (not meant to be a permanent solution). When TX and RX are shorted, if you run gtkterm as mentioned, then typing text in should result in the text being echoed back. Now if you were to tie the CTS and RTS together as well, and instead start the command line with CTS/RTS flow control, then echo of text during typing would show the driver and hardware on that side are working correctly in that mode.

I don’t normally recommend disconnecting/connecting UART lines on a running system, but if nothing odd is going on you could do the following to transition to the remote device:

  1. Settings were verified set and correct with gtkterm. Exit gtkterm (do not reboot or reset anything).
  2. Remove the TX/RX jumper in loopback without changing software or shutdown/reboot. If you had CTS/RTS shorted in loopback, then remove that as well. I assume CTS/RTS was removed during any testing where CTS/RTS settings were disabled anyway.
  3. Connect the original remote device in the matching mode.
  4. See if commands work as you expect...we know now that the TX2 side is in that mode and works with that mode.

If you again get data transfer from only one direction I suspect the CTS/RTS of the remote end is required. If things work, then it is likely the driver was just set to the wrong mode in the Jetson.