TX2 <--> ATMega328p via /dev/ttyTHS1

Hi there,

We are trying to upload sketches on the Arduino IDE. We created a custom board that interfaces the Rx and Tx lines from the ATMega328p directly to UART2 on the TX2.

I came upon this forum which is very similar to our setup. https://devtalk.nvidia.com/default/topic/1044908/tx2-lt-gt-atmega328p-arduino-via-dev-ttyths1/?offset=5

It seems like they managed to upload their sketches successfully. I suspect it has something to do with baudrate and two stop bits. The bootloader burned onto the ATMega328p chip is 9600, does the TX2 UART2 line need to be slower? How do I check the baudrate of the UART2 line and change to 2 stop bits. I work mainly on hardware so I am not very familiar with firmware. Can all these UART settings be changed in the Ubuntu terminal?

The TX2 UART2 works well with one stop bit or more anywhere up to 115200 speed. Above this expect to need two stop bits. Two stop bits wouldn’t hurt in other cases. You might try running the UART in loopback mode with a terminal program (e.g., gtkterm) to test at that mode prior to connecting the real data source (just short TX/RX pins directly for the test…there may be some issues if using CTS/RTS, so first test without that…and you shouldn’t need CTS/RTS at speeds at or below 115200, but for loopback you could short these together as well).

Keep in mind that UARTs are quite simple and old in the tech world. There is no “plug and play” as this would require being able to query the UART chip itself to ask it what it is currently set to. All commands for controlling a UART and query are really just talking to the driver, and the driver will say what it is set to, but the driver won’t have any way to know if the actual UART chip is following those settings. You can check what the driver is set to, you set the driver to a value, but you can’t really know if it worked without testing it (and thus loopback). Typically you’d use something like “stty” if you are not using a program capable of making settings of its own (e.g., stty is pointless when using a terminal program because the terminal program makes its own settings anyway…dumb software without knowledge may benefit from having the stty command set things up ahead of time).