Search by Tags

Configuring Serial Port Debug Console (Linux/U-Boot)

 

Article updated at 13 Apr 2022
Compare with Revision




Introduction

On our Toradex modules, the U-Boot boot loader and the Linux kernel use UART_A as serial debug console. The serial console is the primary and most reliable interface to the boot loader and Linux kernel. This article has two main sections:

  • How to use (attach to and communicate via) the debug UART, a.k.a serial console.
  • How to disable the debug UART.

If you are looking for instructions on how to communicate with other devices using the UART, please refer to the article UART (Linux).

Warning: We do not recommend to use UART_A for any other purpose. Disabling it prevents analyzing errors (e.g. crash of the user interface) or analyzing if the system is in a non-bootable state.

Tip: This article shows how to disable the debug messages on the serial console only. In case you would like to disable debug messages or the virtual console on graphical output (DVI-I, HDMI, LVDS, or VGA) please refer to the Framebuffer (Linux) article.

Use the Debug UART (Serial Console)

You can easily access your Toradex SoM via the serial, in this section, you will find out how to set up the hardware on each of our boards as well as know the parameters. This section applies to both our BSP Layers and Reference Images for Yocto Project and TorizonCore.

Console Serial Parameters

Connecting to the board requires some parameters, here they are:

  • port: it depends on your hardware, often it is /dev/ttyUSBx on Linux, or COMx on Windows, being x a number to be determined in the next section.
  • Baud Rate: 115200
  • Parity: none
  • Bits: 8
  • Stop bits: 1
  • Flow control: none

Windows - Find the Number of the COM Port

Go to Control Panel and find the Device Manager. Your COMx port will be listed under Ports.


  • Windows device manager

    Windows device manager

Linux - Find the Number of the ttyUSB Port

Unplug the device from your computer and run:

$ ls /dev/ttyUSB*

Plug the device and run the same command again, your device will be listed:

$ ls /dev/ttyUSB*

Linux - Add User to Dialout Group

To avoid being requested to use sudo all the time, you can add your user to the dialout group. You can find your user name with the whoami command. To do it in a single-line, in your development PC, run:

$ sudo usermod -a -G dialout $(whoami)

To apply the changes, either reboot or log off, and log in.

Hardware

Select your carrier board from the tabs below:

Connect a USB C to USB Type-A cable to X66.


  • Serial Setup for Verdin Development Board

    Serial Setup for Verdin Development Board

Note: Notice that the USB C connector (X66) has an integrated USB-serial converter that provides access to the computer on module's debug serial port.

Verdin has an integrated Serial-to-USB converter that lists 4 serial ports on your computer. The highest index is the Linux serial console. Example, if you see /dev/ttyUSB0, /dev/ttyUSB1, /dev/ttyUSB2 and /dev/ttyUSB3 listed, then /dev/ttyUSB3 is the serial console. The same logic applies to Windows COM ports.

Attention: If you connect to the first or the second port (for example /dev/ttyUSB0 or /dev/ttyUSB1), you will not be able to use the board. This happens because those ports are dedicated to power/reset control and FTDI JTAG. Just close those connections and reset the board.

Connect a USB C to USB Type-A cable to DEBUG.


  • Serial setup for Dahlia Carrier Board

    Serial setup for Dahlia Carrier Board

Note: Notice that the USB C connector (DEBUG) has an integrated USB-serial converter that provides access to the computer on module's debug serial port.

Verdin has an integrated Serial-to-USB converter that lists 4 serial ports on your computer. The highest index is the Linux serial console. Example, if you see /dev/ttyUSB0, /dev/ttyUSB1, /dev/ttyUSB2 and /dev/ttyUSB3 listed, then /dev/ttyUSB3 is the serial console. The same logic applies to Windows COM ports.

Attention: If you connect to the first or the second port (for example /dev/ttyUSB0 or /dev/ttyUSB1), you will not be able to use the board. This happens because those ports are dedicated to power/reset control and FTDI JTAG. Just close those connections and reset the board.

Connect the DB9 to the IDC adapter cable to the X22 connector on the Ixora:


  • IDC header connected to the Ixora Carrier Board

    IDC header connected to the Ixora Carrier Board

Note: The adapter is included in the Toradex Cable Kit, the standard we used is normally called DTK or Intel standard.

Connect your host machine to the adapter cable using a serial cable or Serial to USB converter:


  • Serial setup for Ixora Carrier Board

    Serial setup for Ixora Carrier Board

Use UART-1 via the USB Type-B connector X29:


  • Using UART via USB X27

    Using UART via USB X27

Make sure that the jumpers JP10 and JP12 are set to USB mode as shown in the image below:


  • Jumpers JP10 and JP12 - USB mode

    Jumpers JP10 and JP12 - USB mode

Connect the DB9 to the IDC adapter cable to the X13 connector on the Iris:


  • IDC header connected to the Iris Carrier Board

    IDC header connected to the Iris Carrier Board

Note: The adapter is included in the Toradex Cable Kit, the standard we used is normally called DTK or Intel standard.

Connect your host machine to the adapter cable using a serial cable or Serial to USB converter:


  • Serial setup for the Iris Carrier Board

    Serial setup for the Iris Carrier Board

Connect a USB micro-B to USB Type-A cable to X4.


  • Serial setup for Aster Carrier Board

    Serial setup for Aster Carrier Board

Note: Notice that the micro USB connector (X4) can be employed as a means to power the system and also has an integrated USB-serial converter that provides access to the computer on the module's debug serial port.

Use UART A via the USB Type-B connector X27:


  • Using UART via USB X27

    Using UART via USB X27

Make sure that the jumpers JP19 and JP17 are set to USB mode as shown in the image below:


  • Jumpers JP17 and JP19 - USB mode

    Jumpers JP17 and JP19 - USB mode

Setting up a terminal

In case you want to know how to set up a terminal emulator to start accessing your module, please refer to Serial Terminal Emulator article.

Find my Board IP

To get your board IP address, follow the instructions from the section Find your IP and MAC address on the article Basic Linux Commands.

Examples of why you need your board IP:

  • You are connecting to the debug UART because you were unable to login via SSH due to missing the board IP.
  • The DHCP tables from your LAN router were refreshed and now the board has a different IP address.
  • You want to access a service hosted on the board, for instance, a web server or a remote graphical user interface.

Change the Debug UART (Serial Console) to Another Port

We don't provide instructions on how to do this. We advise you to use either the default Debug Port defined by Toradex or NXP.

For the i.MX 8/8X SoMs which have a System Controller Unit/System Controller Firmware (SCU/SCFW), or other SoMs from the i.MX 8 family (such as the i.MX 8M Mini) which use a BootROM, it may be nearly or even impossible to change the default UART.

Disable the Debug UART (Serial Console)

Here are sections for disabling the console on U-Boot and the Linux kernel. Make sure to check on UART (Linux) the name of the UART interfaces available for your specific SoM before proceeding.

Disable U-Boot Console Output on UARTA

Custom U-Boot

To disable the serial console modifying U-Boot, you need to reconfigure it following some basic steps. Before proceding, you have to install a GNU toolchain:

Prerequisites

Accordingly to the official documentation of U-boot regarding to silencing the console, the following config options need to be defined in the respective board header file to achieve the goal:

CONFIG_SILENT_CONSOLE
CONFIG_SYS_DEVICE_NULLDEV
CONFIG_SILENT_CONSOLE_UPDATE_ON_RELOC
CONFIG_SILENT_CONSOLE_UPDATE_ON_SET
So, follow the next steps to silence the serial terminal:

  1. Get the U-boot source code:
$ mkdir -p ~/workdir
$ cd ~/workdir
$ git clone -b <branch> git://git.toradex.com/u-boot-toradex.git

Warning: Replace <branch> by the U-Boot Git Branch for your specific configuration. You can find the version information here.

  1. Go to u-boot-toradex/configs and modify the defconfig file of the respective board (for example, for colibri iMX8X: u-boot-toradex/configs/colibri-imx8x_defconfig) by adding and setting the variables at the end of the file as shown below:
...
CONFIG_SILENT_CONSOLE=y
CONFIG_SYS_DEVICE_NULLDEV=y
CONFIG_SILENT_CONSOLE_UPDATE_ON_RELOC=y
...
  1. Define the variables at the board's config header, located at include/configs (for example, for colibri iMX8X: /include/configs/colibri-imx8x.h):

#define CONFIG_SILENT_CONSOLE
#define CONFIG_SYS_DEVICE_NULLDEV
#define CONFIG_SILENT_CONSOLE_UPDATE_ON_RELOC
#define CONFIG_BOARD_EARLY_INIT_F 1

  1. For enabling silent console, append the environment variable 'silent=1' to CONFIG_EXTRA_ENV_SETTINGS in the respective board header file:

#define CONFIG_EXTRA_ENV_SETTINGS \
	BOOTENV \
	AHAB_ENV \
	M4_BOOT_ENV \
	MEM_LAYOUT_ENV_SETTINGS \
	...
	"silent=1\0"\

  1. Compile, deploy and integrate the modifications of the U-boot. Please refer to the following article concerning the setup/compilation of the same: Build U-Boot and Linux Kernel from Source Code.

Note: Enabling silent console just bypasses the console messages to null. Depending on the module type and U-Boot version you might still be able to interrupt U-Boot by pressing the specified key which allows you to control the U-Boot at run time.

Disable most Log Messages from Linux Kernel

To get fewer debug messages from the Linux Kernel one can use the "quiet" Kernel parameter.

# setenv tdxargs '${tdxargs} quiet'
# saveenv

Disable Linux Kernel Console Output on UARTA

Disable the console from the kernel completely by setting the console= option on the kernel command line. This can be achieved by doing it from the U-Boot prompt or using U-Boot-envtools under Linux to modify the env variables:

# setenv tdxargs 'console=null'
# saveenv

or using U-Boot-envtools under Linux:

# fw_setenv tdxargs 'console=null'
# reboot

After this, no kernel messages/serial login are available on debug serial port anymore. To re-enable the debug serial port console one needs to reset the 'console' variable back to the respective serial TTY (e.g: ttyLP0 on Colibri VFxx).

# setenv tdxargs 'console=ttyLP0'
# saveenv

or using U-Boot-envtools under Linux:

# fw_setenv tdxargs 'console=ttyLP0'
# reboot

Configure Baudrate for Serial Getty on UARTA

While during boot the serial baudrate is taken from the U-Boot environment variable baudrate, the later login shell baudrate needs to be configured separately if required in respective /etc/systemd/system/getty.target.wants/serial-getty@<serial device>.service file:

  • i.MX 6/7: /etc/systemd/system/getty.target.wants/serial-getty@ttymxc0.service
  • Tegras: /etc/systemd/system/getty.target.wants/serial-getty@ttyS0.service

Disable Serial Getty on UARTA

Newer BSPs always start an explicit serial getty on UART_A which can be disabled as follows:

# systemctl disable serial-getty@ttyS0.service

Starting from Bsp 3.0 (Kernel 4.14), serial getty cannot be disabled anymore. You need to mask it as follows:

# systemctl mask serial-getty@ttymxc0.service

An interesting blog post from Mr. Poettering about the thematic can be found here.

Video - Using the serial console with Toradex Computer Modules