How to use UART1 as a console ?

I want to use UART1 in J17 as a console to print driver debug info upon linux start.Firstly I stop at uboot and modify the env cbootargs as cbootargs=“… console=ttyS0,115200n8 console= ttyTHS2,115200n8 console=tty0 …”
After a while I can see debug info in both screen and UART0(J21). But got nothing from UART1.
After Linux start I type “echo abc > /dev/ttyTHS2”,and I can get corrent content in my serial debugging assistant now, while the baudrate seems to be set 9600.

Normally J21 has the console serial UART…you may find switching to J17 to be not worth your time unless you have some particular purpose.

The first thing to understand is that the driver must be available under both the Linux kernel and under U-Boot. The naming convention of “ttyS0” or “ttyS2” is from the ordinary 16550A type compatibility and is supported under both U-Boot and Linux. The “ttyTHS0” or “ttyTHS2” type naming convention occurs when the serial port uses DMA, and this driver is available only under Linux…U-Boot does not have this driver. You would have to start by disabling the DMA-capable driver from associating with this UART which would in turn imply a device tree edit…the reverse of adding a DMA-capable UART driver to U-Boot is not practical.

In the past when I’ve tested it looked like the default for ttyTHS2 on J17 was 115200 8N1. I like pointing something like gtkterm at ttyTHS2 with a direct wire connection between TX and RX, plus also between CTS and RTS…loopback…and then you can know if it is correct just by whether you see an echo in your terminal (you can try the terminal at different settings for speed for example).

thank you for your helpful reply ! I have another question here -_-, in uboot stage,ttyS0 is initialed, but ttyTHS2 isnt, so I can see debuginfo just from ttyS0. But after linux startup, they both initialed ,I should see debuginfo, is that corrent…

It is possible that the device tree is incorrect. Some of that tree is installed during U-Boot load, and other parts are appended later on and are used once Linux loads.

To see what your tree is in its final form after boot completes you can do something like this:

dtc -I fs -O dts -o extracted.dts /proc/device-tree

What I find interesting is that for ttyS0 there is no ttyTHS0 (and this works as serial console)…however for other ttyS# entries in “/dev” I see a ttyTHS# entry as well…e.g., I see both ttyS1 and ttyTHS1. Could someone from NVIDIA verify if these device special files refer to the same UART, or if it is just coincidence? If this is the same UART would there not be a conflict to have both the DMA and non-DMA version at the same time? If this is a conflict, what device tree removes the DMA version?

I want to do something similar to this on my TX2. I have a serial display device on J17 (UART1) and I want to output to this device from uboot. I want to keep the debug console on UART0 (J21) so it’s a question of how I enable and talk to UART1 from uboot code. I also need to change UART1 baud rate to 57600.

Once Linux is loaded I realise I can access this UART as /dev/ttyTHS2 but this means a much longer wait before I can put something meaningful on the display.

Could anyone please give me some details on exactly how to achieve this?

Are you saying you want to keep serial console unmodified, and use the J17 connector for ordinary serial communications, but enable it from U-Boot?

I have not set up use of serial communications from U-Boot except for serial console, so I can’t be of much use to you there. I can tell you that the changes would depend on release, so first mention what you see from “head -n 1 /etc/nv_tegra_release”.

One issue which confuses me if this is what you want to do is that a serial UART needs something to talk to. If you are using serial communications with U-Boot, and you are not using the serial console, then I don’t know of any other hardware your external communications could target in U-Boot. Perhaps if you give a use-case it would be easier for someone to answer. It sounds like you have some sort of screen which can print serial content.

FYI, if you did set up for use in U-Boot, then this would be “/dev/ttyS2” and not “/dev/ttyTHS2”. ttyTHS2 is the same hardware, but you want to use a single driver and not switch drivers when going from U-Boot to Linux (unless you don’t care about continuity of service).

Yes, I want to keep the serial console unmodified for debug purposes, and use the J17 connector for ordinary serial commmunications to a 3rd-party front-panel-display device. I want to talk to the display device from u-boot.

I realise that the device will be /dev/ttyS2 from u-boot and dev/ttyTTHS2 from linux. I don’t care about continuity of service, I just want to send some characters to the front panel at u-boot time.

Surely this is possible without huge modifications?

The driver already exists in U-Boot (as demonstrated by the serial console). Much of U-Boot is configured during compile time since it is a bare metal application, but other than a configuration tweak and and compile/flash of the bootloader most of what you want should already be there.

The trick comes in what content you want to send to the serial port. You might add a custom function to send text…not sure what you want to show up, but I assume it is something like an “I am alive” indicator.