Use of USB to serial port in Ubuntu

Source: Internet
Author: User

Minicom is a software for serial communication in Linux. It relies entirely on the keyboard.
It is not as easy to use as a "Super Terminal", but readers will understand its efficiency and convenience after getting used to it. The following describes how to install and configure minicom.

I. Installation
Minicom:

Run the following command:
# Sudo apt-Get install
Minicom

The installation details are as follows:

# Sudo apt-Get install minicom

Reading the package list... complete

Analyzing the dependency tree of the software package
Reading status information... complete
The following additional software will be installed
Package:
Lrzsz

The following [new] software packages will be installed:
Lrzsz
Minicom

A total of 0 software packages were upgraded, and 2 were newly installed.
Software packages. To uninstall 0 software packages, 2 software are not upgraded.

Yes
Download the KB package.

After decompression, it will consume KB
.

Do you want to continue? [Y/n] y

Obtain: 1
Http://ubuntu.uestc.edu.cn

Hard/Universe lrzsz 0.12.21-4.1 [97.0kb]

Get: 2
Http://ubuntu.uestc.edu.cn

Hard/main minicom 2.3 ~ Rc1-2 [173kb]

Download 270kb, 1 S (184kb/s)

The software package lrzsz that was deselected was selected.

(Reading the database... the system currently has a total of 101203 files and directories installed .)
Extracting
Lrzsz (from.../lrzsz_0.12.21-4.1_i386.deb )...

The software package minicom that has been deselected is selected.

Extracting minicom (from
.../Minicom_2.3 ~ Rc1-2_i386.deb )...

Processing the trigger for man-DB...

Is
Set lrzsz (0.12.21-4.1 )...

Setting...
Minicom (2.3 ~ Rc1-2 )...

PS:

Ubuntu
I have nothing to say now. It is quite practical and intelligent. I have associated and installed the related dependency packages (lrzsz. However, if you use Ubuntu
In versions earlier than 8.10, The lrzsz software package may be installed separately (lrzsz includes the x/y/zmodem protocol ). That is to say, the kernel is burned through the XMODEM protocol through the serial port.
The system will prompt that no XMODEM protocol is available, so you need to install the lrzsz package:
# Sudo apt-Get install lrzsz
Then
You can use minicom to burn the kernel through the serial port.

Ii. Configuration
Minicom:

1. Before using minicom, you must first ensure that you have read/write permissions on the serial port. We know
Path: the Linux Device corresponds to a file in the/dev/directory. The serial port COM1 corresponds to ttys0 and com2 corresponds to ttys1. Run the following command to view your permissions on COM1:
$
Ls-L/dev/ttys0
CrW-RW ---- 1 root dialout 4, 64 2009-08-01 11: 05
/Dev/ttys0
As you can see, its owner is root.

2. Just like configuring a Super Terminal in windows, before using minicom
Configure the serial port.
Run # sudo minicom-S

Select Serial Port setup.
On which setting, type "A", and move the cursor to item A: ttys0 for serial port COM1 and ttys1 for com2 ).

Configure the baud rate, data bit, and stop bit, and enter "E". Set the baud rate to 115200
8n1 (Data bit 8, parity check none, stop bit 1), hard/software flow control respectively type "F" and "g", and select No. After confirming that the configuration is correct, you can press enter to return to the upper-level configuration interface, and
Save it as the default configuration (save setup as DFL ). Finally, select the "exit from minicom" command to exit.

The specific configuration information is as follows:
Serial Port setup
[Enter]
+ ------------------------------------------------------------- +
|
A-serial device:/dev/ttyusb0 |
| B-
Lockfile location:/var/lock |
| C-
Callin program: |
| D-callout
Program-: |
| E-
Bps/PAR/bits: 115200 8n1 |
| F-hardware
Flow Control: No |
| G-software flow
Control: No |
|
|
| Change which setting?
|
+ ------------------------------------------------------------- +

Note:

If the serial port is directly used instead of USB to serial port, then serial
Set device to/dev/ttys0.

Then restart minicom (that is, directly execute The minicom command in shell to access
Minicom console) to make the configuration take effect. After connecting to the serial port of the Development Board, you can print the correct serial port information in minicom. Use keys in the console
CTRL + a z to enter the minicom menu.

Key combination: press Ctrl + a first, then release the two keys, and then press Z. In addition
Common key combinations.
(1) s key: send the file to the target system;
(2) W key: automatic screen scrolling. When more than one line is displayed, the next line is automatically wrapped. This function
It is useful when viewing the startup information of the kernel.
(3) c: Clear the display content on the screen;
(4) Key B: view the historical display of minicom;
(5) x key: Return
Out of minicom, will prompt to confirm to exit.

3. Directory of the configuration file
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 ..
|
| Exit |
+ -------------------------- +

Select "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 file storage location (Development Board --->
PC)
Files on the Development Board will be transmitted to the/home/crliu directory on the PC.
(2) B-Upload
---> Development Board)
The PC sends a file to the Development Board. The file to be sent is in the/tmp directory (the directory on the PC ). After this configuration, each time you send a file to the Development Board
You only need to enter the file name, without entering the absolute path of the directory where the file is located.

Iii. Linux
How to use USB to serial port Devices

For notebook holders who do not have a serial port, hardware development is often troubled by the absence of serial ports, but now there is
USB to serial port device. However, new problems have emerged. For example, there are still some configuration problems in the communication between the PC and the target machine under minicom. Next let's talk about USB conversion in Linux.
Specific configuration and problems:

Note:

By default, the USB to serial port driver (pl2303) is installed in Ubuntu ).

1. # lsmod | grep usbserial
If
USB serial indicates that the system supports USB to serial port.

2. Plug in the USB to serial port and enter the command # dmesg | grep
Ttyusb0. If the connection is successful, the Ubuntu system recognizes the device.

Note:

Ubuntu in a virtual machine environment cannot be automatically identified by default. You need to click
Click "prolific USB-serial controller" and select "Connect (disconnect from
Host) "to be recognized by the Ubuntu system.

3. Set serial device in the configuration of minicom above:
/Dev/ttyusb0. Restart the development board so that you can use minicom to print the serial port information normally.

4. Problems



For example
If the above step minicom still does not work properly, the following error message is displayed:
# Sudo minicom
Minicom: cannot
Open/dev/ttyusb0: the file or directory does not exist.

At this time, you can try to change the USB port and then perform the above procedure again.
If this error is still prompted, you can use the following method to solve it.

This method adds a serial device to the hardware and adds the device under the window to the virtual machine. That is
To obtain the focus in the window
After adding the USB to the serial port, and then add the device to the virtual machine, you can view the device file of the added device under Ubuntu, usually/dev/tty0 or
/Dev/ttys0.

This method uses Windows USB to serial port as the serial port of the virtual machine, so it is tty0
Or ttys0, instead of loading it In ubuntu.

The procedure is as follows:
(1) Open the virtual machine environment and select
Choose "VM --> Settings (CTRL + D )".

(2) Click "add". In the Add hardware wizard, select "Serial
Port ", click" Next ".

(3) Select the first item "use physical port on
Host ", click" Next ".

(4) Select "physical serial port" as "Auto"
Detect, select connect at power on, and click Finish.

(5) then set the serial device in the configuration of minicom above:
/Dev/tty0 or serial device:/dev/ttys0. Restart the Development Board to run minicom normally.

 

This article is reproduced from:

Http://hi.baidu.com/bailiangcn/blog/item/f79917092aba97286a60fb08.html

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.