Linux serial debugging assistant

foreword

Based on the information on the Internet, the relevant concepts are summarized, and some of the content is quoted from the article after the article.

There are two options for using a serial port terminal under linux:

  • Command-line based minicom
  • Putty of graphical interface (xshell has no linux version)

1 Overview

1.1 Linux serial device

The serial port under Linux is different from Windows, it appears in the form of device files. Under /dev/the directory, there are two situations:

  • The serial port configured by the host: the device file is usually ttyS0, ttyS1, etc., use dmesg | grep ttySto view;
  • USB to serial port: device files are usually ttyUSB0, ttyUSB1, etc., use dmseg | grep ttyUSBto view;

The USB-to-serial cable of CH340 is used, so the result is as follows:

1.2 minicom

1.2.1 Install minicom

Install minicom using online

sudo apt-get install minicom

1.2.2 Configure minicom

Next, configure minicom ( -sthe parameter indicates entering the configuration interface):

sudo minicom -s

   Enter sudo minicom -s, note that sudo must be added before, otherwise there will be a permission problem of cannot write to /etc/minicom/minirc.dfl after configuration!

Use the arrow keys to select Serial port setup, press Enter to enter the configuration menu of minicom, as shown in the figure below

Enter a or A to select the serial device

(1) Set the serial device file name

 (2) Set serial port properties

After configuring the serial device, press Enter, and then enter E to configure the baud rate. The default configuration is 115200 8N1 (baud rate: 115200, data bits: 8, parity bit: N none, stop bit: 1 ).

(3) Set hardware/software flow control

   After configuring the baud rate, press Enter, and then enter F to configure hardware flow control, select NO

   Then continue to configure software flow control, also select NO.

(4) Save settings

After all configurations are completed, press Enter to return to the previous interface, select save setup as dfl (that is, save it as the default configuration), and press Enter to save the settings;

(5) Exit the main menu

Select Exit from Minicomto exit the main menu Select Exit from Minicomto exit the main menu.

Then select Exit to close minicom.

(6) Use minicom

   Enter the command sudo minicom again, the configuration just now takes effect, and you can see the output information of the serial port

When using minicom to view the log, today I found that I couldn’t press Enter to enter the command line mode to enter the command. After searching the information, I found that the key point is that there is a Serial port setup-->Hardware Flow Contorl option in the serial port configuration has been changed to Yes , which makes the keyboard useless and unable to accept any input. Just change it to No. The specific modification operation is as follows: sudo minicom /dev/ttyUSB0 (after modification, there is a problem with saving permissions, and root permissions are required)

After entering minicom, press Ctrl+A and then press the letter key O to enter the configure Minicom interface and enter the Serial port setup interface. At this time, the F - Hardware Flow Contorl item is Yes, press the F key to change it to No, that is, turn off the hardware flow control, and return to Go back to the upper menu, select Save setup as _dev_ttyUSB0 to save the configuration modification. This will allow you to enter commands.

The usage of the key combination is: first press the Ctrl+A key combination, then release these two keys, and then press the Z key. There are also some commonly used key combinations.
(1) S key: send the file to the target system;
(2) W key: automatically scroll the screen. When the displayed content exceeds one line, the following content will be automatically wrapped. This feature is useful when viewing kernel boot information.
(3) C key: clear the display content of the screen;
(4) B key: browse the history display of minicom;
(5) X key: exit mInicom, and it will prompt to confirm the exit.

3. The directory where the configuration file is located
Ctrl + A --> O
+-----[configuration]------+
| Filenames and paths |
| File transfer protocols -|
| Serial port setup |
| Modem and dialing |
| Screen and keyboard |
| Save setup as dfl |
| Save setup as.. |
| Exit |
+-------------------------+

选择"Filenames and paths"
+-----------------------------------------------------------------------+
| A - Download directory : /home/crliu                                    |
| B - Upload directory   : /tmp                                         |
| C - Script directory   :                                              |
| D - Script program     : runscript                                    |
| E - Kermit program     :                                              |
| F - Logging options                                                   |
|                                                                       |
|    Change which setting?                                              |
+-----------------------------------------------------------------------+

(1) A - download Storage location of downloaded files (development board ---> PC)
The files on the development board will be transferred to the /home/crliu directory on the PC.
(2) B - upload Read uploaded files from here (PC ---> development board)
The PC sends files to the development board, and the files to be sent are in the /tmp directory (the directory on the PC). After this configuration, every time you send a file to the development board, you only need to enter the file name instead of the absolute path of the directory where the file is located.

reference

1. Author blog post
[Embedded Linux (Environment)] Serial port assistant under Linux
Installation and use of serial port tool minicom
How to use minicom gracefully
[linux] serial communication tool - minicom introduction + simple operation 

Guess you like

Origin blog.csdn.net/qq_22168673/article/details/128781075