Dev/Host

From Embeded Linux (and more) Wiki by Nathael
< Dev
Revision as of 02:57, 17 October 2019 by Drizzt (talk | contribs) (Created page with "== Tools == === Minicom === Minicom is a serial communication program with many many features which make it very usefull to connect to targets. ==== Configure ==== Despite wh...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Tools

Minicom

Minicom is a serial communication program with many many features which make it very usefull to connect to targets.

Configure

Despite what you will read on many places : you do not need to be root to run or configure minicom !!! (but you will need a well configured system).

First, you must add the users which should be allowed to run minicom to a group with read and write access to the ttys you want to use, which are most of the time under the "dialout" group (ttyS*, ttyUSB*, ttyACM*, ...). This, of course, is done by the system administrator (root or any user allowed to run the adduser command) :

adduser username dialout

This will only be effective for the next login of the user "username". So if you are already logged in a graphical session and do not want to logout and login back, you can simply use the command "su username" in a terminal to get a new session in which you are in the dialout group for the current session and have access (in this terminal) to the ttys which are in the dialout group.

Then you may want to be able to store new configurations.
Indeed, one option is to run "minicom -s" as root, change the configuration, and "Save setup as.." to store the configuration under /etc/minicom/.
But this will create system-wide configurations (Ok, you may be the only user of your system ... but that's not an excuse to do things the wrong way)

When you run minicom with a configuration name, for example "minicom [options] my_config" then minicom will also look for a configuration file named "$HOME/.minirc.my_config" ... in your home directory !
Of course, you can try to create your config manually by looking at examples in /usr/share/doc/minicom/examples or looking over the web for sample configurations, but there's a much more simple way :

  • Create a file called, for example "$HOME/.minirc.ttyUSB0" which contains the following line : "pu port /dev/ttyUSB0" (replace "/dev/ttyUSB0" by the name of the tty you want to use).
echo "pu port /dev/ttyUSB0" > ~/.minirc.ttyUSB0

I'm using "ttyUSB0" as the config name for the "/dev/ttyUSB0" tty as I feel like it's easy to remember, but the config name can be anything you would remember. Then run minicom with this config name (the tty must be present, plug your USB-serial adapter if it's not the case yet) :

minicom ttyUSB0

You can now configure minicom by hitting "Ctrl+a" and "o" ... and instead of "Save setup as dfl" you get "Save setup as ttyUSB0". Make the required changes to your configuration, and use this menu entry to save your configuration.

Now, to create many configurations (say, for ttyUSB1, ttyUSB2, you can simply copy the "~/.minirc.ttyUSB0" file and even edit the copy directly and change the "pu port" line to get the same config for these other ttys.

Usage

A simple way to start minicom is, as regular user:

minicom -ow -D /dev/ttyUSB0 [-C log_file]

But if you've followed the steps of the previous section and saved your configuration under "ttyUSB0", then you can simply

minicom ttyUSB0 [-C log_file]

The "-C log_file" option is not required, but if present it will create a file called "log_file" and log all trafic to it (or append to it if the file exists)