Serial communication and management of Linux

Source: Internet
Author: User
Tags pack dmesg

Linux serial port and windows have some differences, the following will introduce the Linux under the serial communication management

To see if a USB port is supported:

#lsmod | grep usbserial

If there is no information: sudo apt-get install setserial

Plug in USB to serial port, enter command in terminal

#dmesg | grep ttyUSB0

If the connection success message appears, the system has identified the device

First, find your own serial device.

Find the COM port method that connects your own board to your PC

Windows: Device Manager

Linux:

(1) dmesg #查看带有 "SerialNumber" (serial number), where the serial number is 0

(2) DMESG | grep TTYUSB

(3) Ls-l/dev/ttyusb*

Two. Serial Communication control

C-kermit

Kermit is a tool that integrates serial communication and network communication.

Compared to minicom, U-boot developers recommend the use of serial communication software Ckermit

1) install Kermit: $ sudo apt-get install ckermit

or source installation: to http://www.columbia.edu/kermit/ck80.html#download download C-kermit latest version
2) in the $home master directory, create the. KERMRC profile, vi ~/.KERMRC:

    Setline/dev/ttyUSB0//serial port name, to confirm that the current user has permission to operate on itSetSpeed115200Baud rateSetcarrier-Watch offSetHandshake NoneSetflow-Control None RobustSetFile Type binSetfile name litSetRec Pack +     SetSend Pack + //This can be changed to a larger point, easy to download the kernel    SetWindow5 

3) Use

Use Kermit–c to connect the serial port, if garbled, please close the terminal more than a few times, always successful-:) back to Kermit:ctrl .+\, then press C to jump back to the serial control: Enter C, that is, connect command into command mode: $kermit input: Connect connection into non-command mode: $kermit-C #equivalent to running Connect or C under command mode.*to enter the command mode, proceed as follows:1) input"[ctrl]\].2) input"C"In order to enter the Kermit command mode can be a variety of commands (Support tab completion), such as help can be viewed, input"?"lists all commands. *return COM terminal from Command mode: input"Connect". or enter"C"This switches the serial interface (for example, below Uboot). Some common commands in command mode: LS CD pwd ...after you enter connect in the send file Kermit, skip to U-Boot serial interface. Input LOADB 0xAddress Enter Press CTRL+\, and then press C to switch to Kermit. Input command: Send/home/Zimagekermit Start transmitting data, and can see the progress of transmission, after sending, input C, and then back to u-boot interface, and then enter: The Go 0xAddress kernel starts running.*A simple complete example: After starting the board Uboot, I want to pass a file/root/test.sh to address 0xc0008000 steps as follows:1) $kermit-c #连接到串口上面了. 2) input"loadb 0xc0008000" 3) input"[ctrl]\]4) input"C"this enters the command mode.5) input"send/root/test.sh" 6) input"Connect". So it's done. Ckermit seems to support only the Kermit protocol.

* transfer file to the board Flash above: Enter "Send File"  

minicom

Minicom is the software of serial communication under Linux1, confirm the read/write permission to the serial port:ls-l/dev/ttyUSB0 (serial device)2, configure the serial port to run: #sudoMinicom-s1) Serial Port setup: The cursor shown at this point"Change which setting", type"A", the cursor is moved to the corresponding section A, modify the string  number Note: The use of USB to the serial port, then the serial port COM1 corresponds to TtyUSB0, COM2 corresponds to ttyUSB1, if not using USB to serial port, but directly using the serial port, then the string  The mouth COM1 corresponds to ttyS0, COM2 corresponds to ttyS1. 2after configuring the serial device, press ENTER, go back to the selection screen, and then enter E to configure the baud rate, according to the default configuration can be1152008N1 (baud rate:115200, Data bits:8, parity bit: N None, stop bit:1). 3after configuring the baud rate, press ENTER, and then enter F to configure hardware flow control, set to"NO"   4Configure software flow control, and select No.
  
When you are finished configuring, press ENTER to return to the previous interface, select Save Setup as DFL (the default configuration for its save bit), and then select Exit from Minicom, and close Minicom. Use  sudoMinicom-c on #进入minicom的串口终端显示界面 (-c on means support for color character display) under the console by combining key Ctrl+A Z can enter the minicom menu.
Use of key combinations: Press CTRL first+a key, then release the two keys and press the Z key. There are also some common key combinations. (1) s key: Sends the file to the target system;2) W Key: Automatic roll screen. When the displayed content is more than one line, the following content is automatically wrapped. This feature is useful when viewing boot information for a kernel. (3) C Key: Clear the display of the screen;4) b Key: Browse the historical display of minicom;5x key: Exit minicom, you will be prompted to confirm the exit. The next time you enter sudo minicon you can enter directly. Command minicom is entered into the Serial console screen, and minicom-s for configuration minicom. Description/dev/The ttyS0 corresponds to the port that the serial 0 connects you to the Development Board. Note: An abnormal shutdown of minicom willCreate several files under/var/lock lck*, these files prevent the minicom run, delete them can be restored to see if the serial port is available, you can send data to the serial port, such as the COM1 port,Echo "Test">/dev/ttyS0 when burning the kernel with the XMODEM protocol via the serial port, there is no XMODEM protocol, so the package must also be installed: LrzszsudoApt-getInstallLrzsz This time can be normal with minicom through the serial port to burn the kernel.

Check whether the serial port is available, can send data to the serial port such as to the COM1 port,echo"test" >/dev/ls -l/dev/ ttys* generally under the name of the serial port under Dev, if there is no external plug-in serial card, the default is the dev ttys* general ttyS0 corresponding com1,ttys1 corresponding COM2 view serial drive:cat /proc/tty/drivers/grep ttys*

RELATED links:

http://blog.csdn.net/xian_2015/article/details/49443483 Ckermit

http://5deweb.blog.163.com/blog/static/4902191120138601058790/

Http://blog.chinaunix.net/uid-25562715-id-1990181.html

http://blog.chinaunix.net/uid-28751779-id-5097822.html Linux serial communication knowledge and serial programming

Serial communication and management of Linux

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.