Skip to content

How-To Debug Console

Description

The serial port or UART of the Raspberry Pi Compute Module 4 of the Pi-Tron CM4 is directly connected to the devices debug port, found on the left side when viewed from the front (when looking at the USB and Ethernet ports).

This debug port provides the user with an option to connect a serial cable and to view the Raspberry Pi OS system messages and/or to login into the OS without the need for a network connection.

This can be helpful in situations where no network is available, the network is not accessible or something is wrong it's configuration or it is not possible to connect a monitor, mouse and keyboard or the monitor is blank or the system seems non responsive or any other reason why having access to the Debug Console can be helpful.

pi-tron-cm4-debug-port-location

Image 1: Location of the Debug Port on the Pi-Tron CM4

Requirements

  • A mini-USB-B to USB-A cable
  • A USB-Serial adapter from Kontron Electronics
  • 24 volts power supply with 2 pin power plug for the Pi-Tron CM4
  • An SD card reader (only needed for offline editing of the config.txt file)
  • Development computer with network access to the Pi-Tron CM4 or alternatively connect an HDMI monitor, mouse and keyboard
  • To login into the Pi-Tron CM4 via network, it is requires that the SSH server is running
  • The login details are by default: username: pi and password: raspberry
    • Note: The latest version of the Raspberry Pi OS requires the user creating the initial SD card or writing the system to eMMC memory to choose a username and password. The above mentioned defaults may not apply to your situation.
  • A Terminal application (e.g. TeraTerm or Putty on the Windows host, or screen on Linux) set to a baud rate of 115200 baud, 8 data bits, no parity and 1 stop bit.

How-To

Preparation

  • Connect the mini-USB-B to USB-A cable to the Pi-Tron CM4 on one side and the other side into the USB-Serial-Adapter, like in the image below.
  • Plug the USB-Serial-Adapter into a free USB port on the development computer.
  • Insert an SD card with the Raspberry Pi OS into the Pi-Tron CM4. Skip if the CM4 has eMMC memory with the Raspberry Pi OS installed there.
  • Connection for configuration:

    • If the connection to the Pi-Tron CM4 is made via network, connect a network cable.
    • The connection is also possible via monitor, mouse and keyboard if network is not an option.
    • Alternative: Offline editing is also possible, insert the SD card into a card reader and connect it to the development PC. Skip the "power on" step and look at the Setup section.
  • Connect the 2 pin power plug and power on the Pi-Tron CM4.

BL-Pi-Tron-CM4-Power-and-Debug-Console-Connection

Image 2: mini-USB-B to USB-A cable connected to Pi-Tron CM4 and USB-Serial adapter

Setup

Raspberry Pi Software Configuration Tool

The Raspberry Pi Software Configuration Tool give users one central tool to configure many of the Raspberry Pi's available hardware options. This tool is called raspi-config.

  • Now with access to the Raspberry Pi OS on the Pi-Tron CM4, the serial port and the login shell for the Debug Console can be enabled.
  • Run the raspi-config program:

    sudo raspi-config
    
  • Then choose: Interface OptionsSerial Port<Yes><Ok>

  • Back in the main menu, press the Tab key until <Finish> is selected and hit Enter to leave the raspi-config program.
  • Reboot the Pi-Tron CM4 to enable the Debug Console and the login shell.

raspi-config-01

raspi-config-02

raspi-config-03

raspi-config-04

Manual and Offline Setup

If the raspi-config program is not an option because you might need the console active during the first boot or want to prepare the SD card or eMMC memory beforehand, then a manual (offline) change of the files cmdline.txt and config.txt in the first (boot) partition of the SD card/eMMC memory is needed.

  • Insert the SD card into a card reader and connect it to the development computer. If the Pi-Tron CM4 has eMMC memory, mount the eMMC memory using the rpiboot program on the development computer. For more information see section Related Documentation below.
  • Open the text file cmdline.txt in a text editor.
  • Look for the following text in the file:

    console=serial0,115200
    
  • If this entry is present, nothing has to be changed. If it is missing, add it to the front of the line in the cmdline.txt. Then save and close the editor.

    • Note: The cmdline.txt must only consist of one single line. Do not add any additional lines in this file even empty ones!
    • Note 2: For more or additional debug output, delete the word quiet from the line.
  • Now open the config.txt text file in a text editor.
    • Note: The text editor must support Linux style line endings, often represented as LF or \n.
  • Add the following line at the end of the file:

    enable_uart=1
    
  • Save the changes and close the text editor.

  • Eject the card reader together with the SD card or the eMMC memory removable media from the development computer.
  • Insert the SD card into the Pi-Tron CM4 or if the CM4 has eMMC memory, power off the device.

Debug Console and Login

  • Connect the mini-USB-B to USB-A cable with the mini-USB-B plug to the Debug Port as shown in Image 2.
  • Connect the USB-Serial adapter to the development computer.
  • Find the serial device or COM port the USB-Serial adapter registered as on the development computer. Under Windows this can be found in the Device Manager and under Linux this information should be in the system log, try dmesg and look for a device name like ttyUSBxy, where xy represents a number.
  • Open a terminal application and set it's serial configuration to a baud rate of 115200 baud, 8 data bits, no parity and 1 stop bit.
  • Open the serial port in the terminal application.
  • Now power on the Pi-Tron CM4 and look at the terminal application. After a short while a login prompt should appear in the terminal application. It is now possible to login with the pi user or the user which was chosen when the SD card was made or the Raspberry Pi OS was installed on the eMMC memory of the CM4.


This concludes the How-To for the Debug Console. The serial port or UART of the CM4 is now connected to the Debug Port of the Pi-Tron CM4 and can be used to access the Raspberry Pi OS or just to view system or debug messages.

Restrictions

  • No known Restrictions
  • Note: It is recommended to deactivate the login shell in production environments and to change the default username and password of the Raspberry Pi. Recent versions of the Raspberry Pi OS require the user to create their own credentials. For more information take a look at the links below.