I would like to re-direct console output from UART0 to UART1.
And I would like to use UART1 as debug port after entering linux kernel.
What I did is modifying :
Is it correct to assume this serial console output starts upon Linux kernel load, and that there is no output from the boot loader?
Normally serial console is run from both U-Boot, and then from Linux. The default naming notation is used for both: “ttyS0” (or generically “ttyS#”). If you boot Linux without any modifications, then you’ll see that ttyS0 is the named serial console even on kernel command line.
What might not be so obvious is that NVIDIA provides a serial UART driver on its own hardware which has DMA available, and that these use the “/dev/ttyTHS#” naming scheme, not the “ttyS#” scheme. It’s just conjecture, but there may be issues with first driving the port when there is some sort of DMA version still present. Without modification my TX2 shows I have “ttyTHS1” through “ttyTHS3”. “ttyS0” is present, “ttyTHS0” is absent. Perhaps you will need to adjust so that this serial UART runs only as “ttyS1” and make sure “ttyTHS1” does not exist. It’s my guess that there is a driver conflict and removal of the DMA version on ttyS1/ttyTHS1 will fix it. I do not know what the specific adjustment would be, but I expect it to be somewhere in the device tree.
then system will try to create ‘ttyS2’ for me but then it’s gone.
The crashed parts of the code is in the function, uart_configure_port() in serial_core.c :
The driver which loads for that serial@ port will determine what the naming convention is after Linux is running. Not using DMA will be a requirement of use as a serial console since this is handed off from U-Boot and U-Boot does not have the DMA-aware driver. Whether changes to run without DMA can occur via just device tree I don’t know…there may be other configuration change as well.
The challenge is that first U-Boot must use the new port (and initialize it), then the Linux kernel must use this port without DMA. If the port is running without DMA, then a kernel argument can change the serial console to use this new UART.
Can someone here give the changes or requirements under Linux to force a non-DMA driver for a specific UART port such that it is suitable for an alternate serial console? The “ttyTHS#” naming should disappear, and only a “ttyS#” naming convention should show up for this case.
All ttyTHS designations will fail in U-Boot since this requires a different driver than a ttyS designation. The DMA-capable drivers (ttyTHS designation) only become available after the Linux kernel loads.
Once in the Linux kernel, if serial console had used ttyS1, it may imply you have to specifically avoid using ttyTHS1 (or ttyS2/ttyTHS2). Continuity of service for the port when transitioning from U-Boot to Linux would be the reason this is required.
In the step 4 you mentioned to connect serial port to UART2 to get console logs, as in default UART0 is used, I wonder how is the connection of UART0. I am using developer kit and also Auvidea J130. The tty console is with the keyboard and mouse through a USB port. It seems UART0 is not direct connect to the tty. Is it possible to use UART0 for other use (under OS Ubuntu 16.04)? Thanks