minicom is a serial port terminal tool under Linux, mainly used to interact with serial port devices. The following are detailed tutorials on using minicom, including installation, configuration and common operations.
1. Install minicom
On Ubuntu systems, you can install it with the following command:
sudo apt update sudo apt install minicom
2. Check the serial port device
Before using minicom, you need to confirm the serial port device name first, for example:
ls /dev/tty*
Common serial device names:
- Physical serial port: /dev/ttyS0, /dev/ttyS1
- USB to serial port: /dev/ttyUSB0, /dev/ttyUSB1
- ACM class device: /dev/ttyACM0
3. Start minicom
Start minicom with the following command:
sudo minicom
If started without parameters, minicom will use the default configuration file and may not be able to connect to the serial port correctly.
4. Configure serial port parameters
4.1 Configuration mode
Enter configuration mode:
sudo minicom -s
You will enter a text interface menu, with the main options as follows:
port setup (serial port setting)
Press Enter to enter the configuration interface and set the following contents:
A - Serial Device: Enter the serial device path, for example /dev/ttyUSB0
E - Bps/Par/Bits: Set baud rate, check bit, data bit, etc. For example:
Common configuration: 9600 8N1
8N1 means: 8 data bits, no check bits, 1 stop bit.
Other options can be adjusted as required.
After the configuration is complete, press Enter to save and return.
setup as dfl (Save configuration as default) After the configuration is complete, select this item to save as default setting, which will automatically load on the next startup.
: Save and exit the configuration menu.
4.2 Directly specify parameters on the command line
You can also specify the serial port device and baud rate directly at startup:
sudo minicom -D /dev/ttyUSB0 -b 9600
- -D Specify the device path.
- -b Specify the baud rate.
5. Interact with serial devices
5.1 Basic Operation
After startup, the minicom interface will display the interaction information with the serial port device:
Enter the commands required by the device and send them through the keys.
The device displays the return value in the terminal.
5.2 Shortcut key operation
Here are some commonly used Ctrl-A shortcut keys:
shortcut key | Function |
---|---|
Ctrl-A Z | Help menu showing all available shortcut keys |
Ctrl-A X | Exit minicom |
Ctrl-A Q | Exit now (no confirmation is required) |
Ctrl-A O | Open the configuration menu |
Ctrl-A S | Send files to serial port device |
Ctrl-A R | Receive files |
Ctrl-A W | Switch line wrapping mode (display characters beyond width) |
Ctrl-A P | Show current configuration |
6. File transfer
minicom supports multiple file transfer protocols such as Xmodem, Ymodem and Zmodem.
6.1 Send files
Ensure that the device supports file transfer protocol.
Press Ctrl-A S to select the protocol (such as Xmodem).
Select the file to send.
6.2 Receive files
Start sending file on the device side.
Press Ctrl-A R in minicom to select the protocol and receive the file.
7. Exit minicom
Press the shortcut key Ctrl-A X and select Yes to exit.
8. Debugging and troubleshooting
8.1 View serial port permissions
If the runtime prompts that the permission is insufficient, you can check whether the current user has read and write permissions to the serial port device:
ls -l /dev/ttyUSB0
If the current user is not in the group to which the device belongs (usually a dialout), you can add the user to the group:
sudo usermod -a -G dialout $USER
Then log in again or restart to take effect.
8.2 Check whether the device is occupied
Check whether other programs occupy the serial port device:
lsof /dev/ttyUSB0
9. Example: Connecting to the development board
Assuming the development board is connected via /dev/ttyUSB0 and the baud rate is 115200, use minicom to communicate with it:
sudo minicom -D /dev/ttyUSB0 -b 115200
After connecting, you can directly send commands, such as logging into the terminal of the development board or configuring device parameters.
This is the article about the detailed explanation of the use of the serial port debugging tool minicom in Linux. For more related linux minicom serial port debugging content, please search for my previous articles or continue browsing the related articles below. I hope everyone will support me in the future!