Cannot disable console output on ttyS0

Hello,

I would like to use the ttyS0 as a general purpose UART. It is connected to the J50 header of the B01 version of the Nano Dev kit.
The first step is to disconnect it from the console, and I followed the instructions in the l4t documentation which says:

For NVIDIA® Jetson Nano™: Edit the platform configuration file p3448-0000.conf to remove the specification console=ttyS0.

The file p3448-0000.conf calls the file p3448-0000.conf.common which has the snippet console=ttyS0. I removed it and then created an sd-card image using the tool jetson-disk-image-creator.sh, with the correct board and revision information for my setup.

It however did not work, and the ttyS0 is still used for the console.
Indeed, it looks like the line console=ttyS0,115200n8 is appended by another script or file, prior to the file p3448-0000.conf.common. This can be seen on the output from the console during boot, in the append section:

U-Boot 2016.07-g0536cf2a27 (Dec 09 2019 - 22:40:32 -0800)

TEGRA210
Model: NVIDIA P3450-Porg
Board: NVIDIA P3450-PORG
DRAM:  4 GiB
MMC:   Tegra SD/MMC: 0, Tegra SD/MMC: 1
SF: Detected MX25U3235F with page size 256 Bytes, erase size 4 KiB, total 4 MiB
*** Warning - bad CRC, using default environment

In:    serial
Out:   serial
Err:   serial
Net:   No ethernet found.
Hit any key to stop autoboot:  1 ^H^H^H 0 
switch to partitions #0, OK
mmc1 is current device
Scanning mmc 1:1...
Found /boot/extlinux/extlinux.conf
Retrieving file: /boot/extlinux/extlinux.conf
733 bytes read in 169 ms (3.9 KiB/s)
1:	primary kernel
Retrieving file: /boot/initrd
5487751 bytes read in 290 ms (18 MiB/s)
Retrieving file: /boot/Image
34191368 bytes read in 1538 ms (21.2 MiB/s)
append: tegraid=21.1.2.0.0 ddr_die=4096M@2048M section=512M memtype=0 vpr_resize usb_port_owner_info=0 lane_owner_info=0 emc_max_dvfs=0 touch_id=0@63 video=tegrafb no_console_suspend=1 console=ttyS0,115200n8 debug_uartport=lsport,0 earlyprintk=uart8250-32bit,0x70006000 maxcpus=4 usbcore.old_scheme_first=1 lp0_vec=0x1000@0xff780000 core_edp_mv=1125 core_edp_ma=4000 tegra_fbmem=0x800000@0x92cb4000 is_hdmi_initialised=1  root=/dev/mmcblk0p1 rw rootwait rootfstype=ext4 console=tty0 fbcon=map:0 net.ifnames=0    root=/dev/mmcblk0p1 rw rootwait rootfstype=ext4 console=tty0 fbcon=map:0 net.ifnames=0 quiet
## Flattened Device Tree blob at 83100000
   Booting using the fdt blob at 0x83100000

   reserving fdt memory region: addr=80000000 size=20000

   Using Device Tree in place at 0000000083100000, end 00000000831776dc


Starting kernel ...

The snippet console=ttyS0,115200n8 occurs before the part console=tty0 fbcon=map:0 net.ifnames=0 which is set by the file p3448-0000.conf.common.

Do you know which file or script is responsible for this? That way I could edit it out from the command line at boot, and access the ttyS0 to interface with my device?

Thank you for any help you can share.

hello audren.cloitre,

please refer to Environment Configuration session to disable Console over UART.
thanks

Hello Jerry,

Thank you for your reply.
I followed the instructions in the Environment Configuration chapter of the l4t documentation, specifically the portion on Disabling the Console, but this does not work.
The snippet console=ttyS0,115200n8 appears several times in the command line at boot, and editing it out of the file p3448-0000.conf.common only removes it once.
After this edit, the snippet console=ttyS0,115200n8 is still present in the command line at boot. It is appended by another file and I do not know which one.

Do you know which other file isimplementing it?

Best,

Audren

Do you see the parameters in the file “/boot/extlinux/extlinux.conf”? Specifically, in the “APPEND” key/value pair?

If you look at the output of “cat /proc/device-tree/chosen/bootargs”, does it show up there?

Thank you for your help!
The snippet does show up in the file /proc/device-tree/chosen/bootargs and not in the file /boot/extlinux/extlinux.conf(both on the Nano).
I tried editting the bootargs file on the Nano, but even as root, I do not have permission to change it.
Do you know a way to edit this file, either post-flash or pre-flash of the sd-card image?

The content of “/proc/device-tree” is not a real filesystem. That content is basically the kernel creating “fake” files in RAM to describe something for you. That content is a reflection of the device tree which was passed to the kernel during boot, so you’d need to change the device tree’s “chosen->bootargs” node, and install the changed device tree.

If you look at the “APPEND” key/value pair in the extlinux.conf file, then you will see it starts with this:
APPEND ${cbootargs}

Earlier boot stages have access to the device tree’s version of a kernel command line, and (perhaps after editing) the command line is passed from one boot stage to the next. The macro “${cbootargs}” is just an environment variable for the kernel, and outputs the final (edited) content of “chosen->bootargs”. Change the device tree content, and the “chosen->bootargs” passed as “${cbootargs}” will also change.

Device tree source files are “.dts” files. Device tree binary files are “.dtb” files. Boot uses the binary format, but it is easy to decompile a dtb into a dts, and it is easy to compile a dts into a dtb.

I do not know the specific dtb file you would want to update. Under most circumstances though you could place the new file in “/boot”, and then edit extlinux.conf to have an “FDT” key/value pair. The value is the full path to the “/boot” dtb file. Example from an Xavier NX running L4T R32.4.3, modified to use an FDT entry (I don’t know if that specific device tree file is actually valid, I am only illustrating…but note I removed the extlinux.conf “console” entry for the serial port, and added an “FDT” entry):

LABEL primary
      MENU LABEL primary kernel
      LINUX /boot/Image
      INITRD /boot/initrd
      FDT /boot/tegra194-p2888-0001-p2822-0000.dtb
      APPEND ${cbootargs} root=/dev/mmcblk0p1 rw rootwait rootfstype=ext4 console=tty0 fbcon=map:0 net.ifnames=0

In that example there is a file “/boot/tegra194-p2888-0001-p2822-0000.dtb”. I don’t know which dtb you will need to edit. Normally I would suggest to flash, and save a log of the flash. Then you could find the file installed, reverse compile it, make your edits, and put the edited version in “/boot” (documentation will probably show you how to create the tree from scratch using kernel source instead of reverse compile, edit, and recompile).

Someone else may know the specific device tree which contains the serial console “chosen->bootargs” entry.

There may also be times when you need to install the device tree through a flash process.

Thank you very much for the detailed explanation!
I am currently using a custom dtb file that was created by the script jetson-io.py to enable SPI communication on the j41 (40-pin) header of the nano. I will investigate this file to see if it contains the offending snippet of code. If not, I’ll go back to the source files used for compiling the kernel and original device tree, to see if it can be found there.

Sometimes several smaller trees are combined to create the larger tree, but if your custom tree has the “chosen” node in it, then you should be able to modify “chosen” directly in your device tree. If not, then you may need to find the particular tree which has “chosen” in it.

I think I found my solution, but it involves recompiling the kernel .
I had to make the following changes to the config file for the kernel:

# CONFIG_SERIAL_8250_CONSOLE is not set
# CONFIG_MAGIC_SYSRQ is not set

I also had to edit the device tree file called tegra210-porg-p3448-common.dtsi located in nvidia_sdk/JetPack_4.3_Linux_JETSON_NANO_DEVKIT/Linux_for_Tegra/sources/hardware/nvidia/platform/t210/porg/kernel-dts/. I changed the chosen entry to the following:

	chosen {
		nvidia,tegra-porg-sku;
		/*stdout-path = "/serial@70006000";*/
		nvidia,tegra-always-on-personality;
		no-tnid-sn;
		/*bootargs = "kmemleak=on earlycon=uart8250,mmio32,0x70006000";*/
		bootargs = "kmemleak=on";
	};

I did not change anything to the entry serial@70006000 on this page.

Furthermore, I had to comment out a function in the source code for the serial driver. It’s the function that sets the serial options for the console output. It’s no longer needed and it gave error on kernel compilation. Here is the commented out function in question, which is at the line 213 of the file nvidia_sdk/JetPack_4.3_Linux_JETSON_NANO_DEVKIT/Linux_for_Tegra/sources/kernel/nvidia/drivers/tty/serial/tegra-combined-uart.c:

static int __init tegra_combined_uart_console_setup(struct console *co,
							char *options)
{
	// int baud = 115200;
	// int parity = 'n';
	// int bits = 8;
	// int flow = 'n';

	// if (options)
	// 	uart_parse_options(options, &baud, &parity, &bits, &flow);

	// return uart_set_options(&tegra_combined_uart_port, co, baud, parity,
	// 			bits, flow);
	return 0;
}

I still edited out the console=ttyS0,115200n8 of the file p3448-0000.conf.common (as per the documentation).
Once the Nano is flashed and booted, I stopped and disabled the service nvgetty:

sudo systemctl stop nvgetty.service
sudo systemctl disable nvgetty.service

You can also add your user to the dialout group so as to use the tty without root privileges:

sudo adduser dialout your_username_replaces_this

Finally, use stty to set the serial options, e.g.:

stty -F /dev/ttyS0 115200

With all of this I get to communicate via serial on the ttyS0 port. I do not get any console interference in the messages, and I can boot the Nano with the serial cables plugged in without losing the graphical user interface (the desktop shows up).
This solved my problem and I will mark this message as my solution, but please so post here if there are issues with this approach, or if you have a better solution than recompiling the kernel.

I’m not sure why the above would need to be removed since it isn’t a serial console function (magic sysrq is from a directly connected keyboard; to use this with serial console requires an echo into the correct “/proc” file).

The CONFIG_SERIAL_8250_CONSOLE makes sense, but I suspect there are other ways to disable this without an actual software recompile. I have not personally done this though, so someone else would have to say if you can avoid a recompile. Do note that the stage which interrupts boot though is in the bootloader prior to the kernel running; even if you need to disable the kernel serial console to prevent nonsense from showing up when using ttyS0 as a non-console, it is still possible for stages prior to reaching Linux to need a change too (but only if boot is locking there…if boot does not lock up from stray activity, then you’ve succeeded in the pre-Linux stages).

Would someone else know of a specific document for disabling serial on a Nano? I only know individual steps in a general way.

Thanks linuxdev, I’ll check on my system whether communication on the serial port blocks the booting process or not. So far, it has not, but there might be a set of bytes that will. More tests will tell.

With respect to the CONFIG_MAGIC_SYSRQ parameter, I had to remove it as the kernel compilation was giving me errors after removing CONFIG_SERIAL_8250_CONSOLE. The compiler said that the uart did not have something related to sysrq (can’t recall the exact error right now). Removing CONFIG_MAGIC_SYSRQ made the error go away.