In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly introduces how to use minicom USB serial port under Linux, which is very detailed and has certain reference value. Friends who are interested must finish reading it.
View serial port information under Linux
To see if the serial port is available, you can send data to the serial port, such as com1, echo helloworld > / dev/ttyS0
Check the serial port name using ls-l / dev/ttyS* generally the serial port names are all under dev. If you do not have an external serial port card, the default is ttyS*, under dev, general ttyS0 corresponds to com1,ttyS1 corresponding to com2, of course, it is not necessarily necessary.
View usb device lsusb
Check the serial driver: cat / proc/tty/drivers/serial
[root@dy root] # cat / proc/tty/driver/* serinfo:1.0 driver revision: 0: uart:MPC52xx PSC mmio:0x80011300 irq:40 tx:10 rx:129 CTS | DSR | CD usbserinfo:1.0 driver:2.0
For example, enter: dmesg | grep tty at the terminal to display the information from the system startup to the serial port insertion and unplug, then let me insert a usb to rs232 line on the computer, and then enter: dmesg | grep tty at the terminal, it will display: usb 2-2.1:pl2303 converter now attached to ttyUSB0; can determine the serial number corresponding to my newly inserted serial line through this method.
Minicom is the serial communication software under linux, and its use depends entirely on the operation of the keyboard. Although it is not as easy to use as "HyperTerminal", readers will realize its efficiency and convenience after using it. The following will explain the installation and configuration of minicom.
1. Install minicom:
Use the following command:
# sudo apt-get install minicom
The following are details of the installation:
# sudo apt-get install minicom
Reading package list. Complete
Analyzing dependency tree of software package
Reading status information. Complete
The following additional packages will be installed:
Lrzsz
The following [new] packages will be installed:
Lrzsz minicom
A total of 0 software packages have been upgraded, 2 new packages have been installed, 0 software packages have to be uninstalled, and 2 software have not been upgraded.
You need to download the 270kB package.
Unzipping consumes extra space for 1389kB.
Do you want to continue with the execution? [YPop] y
Get: 1 http://ubuntu.uestc.edu.cn hardy/universe lrzsz 0.12.21-4.1 [97.0kB]
Get: 2 http://ubuntu.uestc.edu.cn hardy/main minicom 2.3~rc1-2 [173kB]
Download 270kB, which takes 1s (184kB/s)
The package lrzsz that has been deselected is selected.
(reading the database. The system currently has 101203 files and directories installed.)
Extracting lrzsz (from... / lrzsz_0.12.21-4.1_i386.deb).
The package minicom that has been deselected is selected.
Extracting minicom (from... / minicom_2.3~rc1-2_i386.deb).
Processing triggers for man-db.
Setting lrzsz (0.12.21-4.1).
Setting minicom (2.3~rc1-2)...
What PS:ubuntu is doing now is quite practical and intelligent. It correlates and installs the relevant lrzsz packages. However, if you use a version prior to ubuntu 8.10, you may have to install the lrzsz package separately (lrzsz includes the x/y/zmodem protocol). In other words, when burning the kernel with the xmodem protocol through the serial port, you will be prompted that there is no xmodem protocol, so it is time to install the lrzsz package:
# sudo apt-get install lrzsz
Then you can normally use minicom to burn the kernel through the serial port.
2. Configure minicom:
1. Before using minicom, first make sure that you have read / write access to the serial port. We know that the device of Linux corresponds to a file in the / dev/ directory, and the serial port COM1 corresponds to ttyS0,COM2 and corresponds to ttyS1. Use the following command to check your permissions on COM1:
$ls-l / dev/ttyS0crw-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 HyperTerminal in Windows, the serial port should be configured before using minicom.
Running
# sudo minicom-s
Select Serial port setup, the cursor shown at this time is over "Change which setting", type "A", and the cursor moves to the corresponding place of item A: serial port COM1 corresponds to ttyS0,COM2 corresponding to ttyS1 (pay attention to selection).
Then configure the baud rate, data bit and stop bit, type "E", select 115200 8N1 (data bit 8, parity none, stop bit 1), hardware / software flow control type "F" and "G" respectively, and select No. After confirming that the configuration is correct, type enter to return to the parent configuration interface and save it as the default configuration (that is, save setup as dfl). *, select the "Exit from Minicom" command to exit.
Note: if minicom is closed abnormally, several files will be created under / var/lock. LCK*, these files prevent minicom from running. Delete them and restore them.
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 you do not use USB to serial port, but directly use serial port, then Serial Device should be configured as / dev/ttyS0.
Then restart minicom (that is, directly execute the minicom command under shell to enter the console of minicom) to make the configuration just take effect, and then connect to the serial port line of the development board, you can print out the correct serial port information in minicom. Under the console, you can enter the minicom menu by using the key combination Ctrl+A Z.
The use of key combinations is to press the Ctrl+A key combination, then release the two keys, and then press the Z key. There are also some common key combinations.
(1) S key: send files to the target system
(2) W key: automatically roll the screen. When more than one line is displayed, the following content is automatically wrapped. This feature is useful when viewing kernel startup information.
(3) C key: clear the display of the screen
(4) B key: browse the historical display of minicom
(5) X key: if you exit mInicom, you will be prompted 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 | +-+ |
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) location of A-download download file (development board-> PC)
The files on the development board will be transferred to the / home/crliu directory on the PC.
(2) B-upload reads uploaded files from here (PC-- > development board)
The PC sends files to the development board, and the files you need to send 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, not the absolute path of the directory where the file is located.
Third, how to use USB to convert serial port equipment under Linux
For notebook owners without serial ports, hardware development often worries about not having serial ports, but now there is a USB-to-serial device. However, new problems have arisen. For example, there are still some configuration problems in the communication between PC and target computer under Minicom. Let's talk about the specific configuration and problems of USB to serial port under linux:
Note: by default, ubuntu has installed the USB to Serial driver (pl2303).
1. # lsmod | grep usbserial
If there is usbserial, the system supports USB to serial port.
2. Plug in the USB to serial port, and enter the command # dmesg | grep ttyUSB0 at the terminal. If the connection success message appears, the ubuntu system has identified the device.
Note: ubuntu in the virtual machine environment is not automatically recognized by default, you need to click "Prolific USB-Serial Controller" in the lower right corner of the virtual machine window, and then select "Connect (Disconnect from Host)" in order to be recognized by the ubuntu system.
3. Set Serial Device: / dev/ttyUSB0 in the configuration of minicom above, restart the development board, so that you can print serial port information using minicom normally.
4. Problems
If minicom does not work properly after the above steps, the following error appears:
# sudo minicom
Minicom: cannot open / dev/ttyUSB0: there is no such file or directory
At this point, you can try to change a USB port, and then do the above process again. If you still prompt for this error, you can use the following methods to solve it.
This method is to add serial devices to the hardware and add the devices under window to the virtual machine. In other words, if you want to add usb to serial port when window gets focus, and then add the device under the virtual machine, you can view the device file of the added device under ubuntu, usually / dev/tty0 or / dev/ttyS0.
This method actually uses window's usb to serial port as the serial port of the virtual machine, so it is tty0 or ttyS0, rather than actually loaded under ubuntu.
The specific steps are as follows:
(1) Open the virtual machine environment and select "VM-- > Settings (Ctrl+D)".
(2) Click "Add", enter the add hardware wizard, select "Serial Port", and click "Next".
(3) Select the * * item "Use physical port on the host" and click "Next".
(4) Select "Physical serial port" as "Auto detect", check "Connect at power on", and click "Finish" to complete.
(5) then set Serial Device: / dev/tty0 or Serial Device: / dev/ttyS0 in the configuration of minicom above, and restart the development board, so that minicom can run normally.
How to use USB to Serial Port device under Linux
For notebook owners without serial ports, hardware development often worries about not having serial ports, but now there is a USB-to-serial device. However, new problems have arisen. For example, there are still some configuration problems in the communication between PC and target computer under Minicom. Let's talk about the specific configuration and problems of USB to serial port under linux:
Note: by default, ubuntu has installed the USB to Serial driver (pl2303).
1. # lsmod | grep usbserial
If there is usbserial, the system supports USB to serial port.
2. Plug in the USB to serial port, and enter the command # dmesg | grep ttyUSB0 at the terminal. If the connection success message appears, the ubuntu system has identified the device.
Note: ubuntu in the virtual machine environment is not automatically recognized by default, you need to click "Prolific USB-Serial Controller" in the lower right corner of the virtual machine window, and then select "Connect (Disconnect from Host)" in order to be recognized by the ubuntu system.
3. Set Serial Device: / dev/ttyUSB0 in the configuration of minicom above, restart the development board, so that you can print serial port information using minicom normally.
4. Problems
If minicom does not work properly after the above steps, the following error appears:
# sudo minicomminicom: cannot open / dev/ttyUSB0: no such file or directory
At this point, you can try to change a USB port, and then do the above process again. If you still prompt for this error, you can use the following methods to solve it.
This method is to add serial devices to the hardware and add the devices under window to the virtual machine. In other words, if you want to add usb to serial port when window gets focus, and then add the device under the virtual machine, you can view the device file of the added device under ubuntu, usually / dev/tty0 or / dev/ttyS0.
This method actually uses window's usb to serial port as the serial port of the virtual machine, so it is tty0 or ttyS0, rather than actually loaded under ubuntu.
The specific steps are as follows:
(1) Open the virtual machine environment and select "VM-- > Settings (Ctrl+D)".
(2) Click "Add", enter the add hardware wizard, select "Serial Port", and click "Next".
(3) Select the * * item "Use physical port on the host" and click "Next".
(4) Select "Physical serial port" as "Auto detect", check "Connect at power on", and click "Finish" to complete.
(5) then set Serial Device: / dev/tty0 or Serial Device: / dev/ttyS0 in the configuration of minicom above, and restart the development board, so that minicom can run normally.
-
Use
Minicom is window-based. To pop up the window for the desired function, press Ctrl-A (following
Use Cmura to represent Ctrl-A), and then press each function key (Amurz or Amurz). Press Cmura first, and then
Press' zonal 'and a help window will appear, providing a brief description of all the commands. Configure minicom
(- s option, or Cmura, O), you can change this escape key, but for now we are still
It's Ctrl-An isn't it?
The following keys are available in all menus:
UP arrow-up or 'k'
DOWN arrow-down or 'j'
LEFT arrow-left or'h'
RIGHT arrow-right or'l'
CHOOSE Enter
CANCEL ESCape.
The screen is divided into two parts: the screen of the upper 24 behavior terminal simulator. ANSI or VT100 escape
The sequence is explained in this window. If there is one line left at the bottom, the status line will be put here.
Otherwise, the status line appears each time you press Cmura. On those terminals that have a special status line
Use this line if the termcap information is complete and the-k flag is added.
The following is an alphabetical list of the available commands:
Pressing Cmura twice will send a Cmura command to the remote system. If you put the "escape character"
If you replace it with a character other than Cmura, it works similarly for that character.
A switch "Add Linefeed" to on/off. If on, each enter key is on the screen
Add a linefeed before it is displayed.
B provides you with a scroll back buffer. You can press u to roll up and d to scroll down
Press b to turn a page and f to turn a page. You can also use arrow keys and page flip keys. S or S keys are available
(case sensitive) look for a text string in the buffer and press the N key to find the next occurrence of the string.
Press c to enter reference mode, the text cursor appears, and you can press Enter to specify the starting line.
Then the rollback mode will end and content with the prefix'> 'will be sent.
C clear the screen.
D dial a number or turn to the dial-up directory.
E switch local echo to on/off (if your minicom version supports it).
F sends the break signal to modem.
G runs the script (Go). Run a login script.
H hang up.
I toggle the type of escape sequence sent by cursor keys between normal and application modes (see also below
Comments about the status line).
J jumps to shell. When returned, the entire screen will be refreshed (redrawn).
K clears the screen, runs kermit, and refreshes the screen when you return.
L file capture switch. When turned on, all output to the screen will also be captured in the file.
M sends the modem initialization string. If you online and the DCD line is set to on, modem is initialized
The former will ask you for confirmation.
O configure minicom. Go to the configuration menu.
P communication parameters. Allows you to change the bps rate, parity and digits.
Q exits modem without resetting minicom. If the macros is changed and the disk is not saved
Will give you a chance to save.
R receives the file. Choose from a variety of protocols (external). If filename selects the window and the bottom
The download directory prompt is available, and a window appears asking you to select a download directory. Otherwise, use the
The download directory defined in the Filenames and Paths menu.
S sends the file. Select the protocol you use in receiving commands. If you do not select the file name
Window is available (set in the File Transfer Protocols menu), you will only be able to click in a
Write the file name in the dialog window. If you make it available, a window pops up showing
The file name in your upload directory. You can use the spacebar to mark or unmark the file name with the
Move the cursor up and down with the cursor key or jthumb k key. The selected file name is highlighted. The directory name is in
Square brackets show that pressing the spacebar twice can move up and down the directory tree. * *, press
Enter sends the file, or press ESC to exit.
T Select terminal analog: ANSI (color) or VT100. You can also change the backspace key here, open or
Close the status line.
W switch linewrap to on/off.
X exits minicom and resets modem. If the macros is changed and is not saved, it will be provided
Your chance to be a save.
Z pops up the help screen.
2.1 modify enter the following instructions in the terminal
[plain] view plaincopyprint?
Sudo nano / boot/cmdline.txt
[plain] view plain copy
Print?
Sudo nano / boot/cmdline.txt
Delete the red part when you open it
Dwc_otg.lpm_enable=0 console=ttyAMA0,115200 kgdboc=ttyAMA0,115200 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline rootwait
After deletion, the result is saved and exited as follows
Dwc_otg.lpm_enable=0 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline rootwait
2.2 modify / etc/inittab
Enter the following instructions at the terminal
$sudo nano / etc/inittab
When you open it, comment out the * line and add a # in front of it.
# T0:23:respawn:/sbin/getty-L ttyAMA0 115200 vt100
3. After the modification, you need to install a minicom on the raspberry pie. The minicom here is a serial port debugging tool on the Linux platform, which is equivalent to the serial port debugging assistant on Windows.
3.1 to install minicom, enter the following command
$sudo apt-get install minicon
3.2 minicom needs to be configured after installation. The configuration file here requires root permission, otherwise the configured parameters cannot be saved, then enter the following command on the command line
$sudo passwd root
After executing this command, the system will prompt you to enter the root password twice, enter the password you want to set, and then execute
$sudo passwd-unlock
This unlocks the root account.
Switch to the root account, open the command line again, and enter the minicom parameter configuration command
$minicom-s
In the third item Serial Port Setup of the main menu, go to the next level menu, select according to the prompt letter of the menu item, and press A to change the serial port device to / dev/ttyAMA0
Press E to change the baud rate to 9600 or the value you need, set it up and return to the main menu and select Save Setup as Dfl
Then select Exit, at this time, if normal, you can send and receive serial port. Here, my raspberry pie is connected to a PC, and I use the serial port debugging software of PC to send and receive successfully.
Tips: press CTRL+A, then press Z to view minicom's help
These are all the contents of this article entitled "how to use minicom USB Serial Port under Linux". Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.