This is part of a series of blog posts on the Windows Subsystem for Linux (WSL). For background information you may want to read the architectural overview, introduction to pico processes, WSL system calls, and WSL file system blog posts.
How-To set up a serial console on Ubuntu 2 minute read This tutorial will go over the steps to go through in order to set up a serial console on Ubuntu Linux. Unlike most other distros, Ubuntu uses upstart instead of sysvinit and as such, there is a few differences between most of the tutorial that you might find on the internet regarding how to set up a serial console. This is part of a series of blog posts on the Windows Subsystem for Linux (WSL). For background information you may want to read the architectural overview, introduction to pico processes, WSL system calls, and WSL file system blog posts.
Posted on behalf of Stephen Hufnagel
Apr 01, 2011 Cutecom is a graphical serial port communications program, similar to Minicom. The Windows equivalent is Hyperterminal. It's available for all versions of the Ubuntu family. Most embedded Linux / BSD systems such as routers, servers and nas devices comes with console interface (serial port with RS-232). BIOS can uses this, and after boot BIOS screen I/O is redirected so that you can use the device. RS-232 is also used for communicating to headless server, where no.
Summary
First of all, let's assume that you have already connected the serial port of your Linux box to a switch console port via a serial cable. To connect a Linux terminal to the serial port of your Linux system, you can use a command-line screen manager tool called screen. Install screen on Linux. To install screen on Debian, Ubuntu or Linux Mint. My dell dimension 8400 has a serial port on the back. I want to use minicom to interface the serial port on this computer with Ubuntu installed. The output of dmesg grep tty did not give me much useful information however. I could not find anything with the key word 'Serial'.
In Windows Insider build #16176 WSL now allows access to serial devices (COM ports).
This blog post will describe how to use this feature and the work that was involved in exposing this functionality within WSL.
On Windows, COM ports are named COM1 through COM256. On Linux, serial devices can have arbitrary names but are typically character devices with a major number of 4 and a minor number from 64 to 256 represented by /dev/ttyS0 through /dev/ttyS191. By default init will populate this mapping using the
mknod
system call. Alternate mknod
mappings can be created at runtime if needed.In WSL, the lxcore driver maps COM ports to Linux devices by the COM port number so /dev/ttyS<N> is tied to COM<N>. More specifically, the mapping is on the minor number, so minor number 65 (/dev/ttyS1) is COM1, 66 (/dev/ttyS2) is COM2, and so forth. Since pty, tty, and ttyS share a terminal library code base, ttyS will behave similarly but also support the following termios settings which are simply mapped to Windows serial driver ioctls:
- Standard baud rates - B*
- Stop bits - CSTOPB
- Word length - CSIZE
- Parity checking - PARENB, PARODD, CMSPAR, INPCK
- Software flow control - IXON, IXOFF
- Hardware flow control - CRTSCTS, CLOCAL
- Control characters - VSTART, VSTOP, VEOF
To use your favorite serial toollibrary in WSL, just map from the COM port of the device using device manager or the SERIALCOMM registry key (HKEY_LOCAL_MACHINEHARDWAREDEVICEMAPSERIALCOMM).
Figure 1. This diagram shows the basic architecture of WSL exposes Windows COM ports as serial devices in WSL.
Scenarios
The following scenarios were tested and confirmed to be working:
- Programming pixhawk light controller - Thanks @lovettchris!
- Connecting to Raspberry Pi 2 serial terminal using the
cu
tool - Transferring data on various serial configurations:
- Hyper-V virtual COM port
- FTDI USB to serial converter
- Prolific USB to serial converter
- Physical COM port
Please note that some serial drivers have known bugs. These issues exist on both native Windows and within WSL.
The following areas are known to not work. We are tracking updates to future Windows Insider builds to address them.
- Using legacy raw ioctls instead TCGETS or TCSETS* to configure and query the serial device
- Screen and minicom depend on the above so they do not currently work as a serial terminal, but cu is an alternative.
Example
On a Windows 10 machine where a Raspberry Pi is connected on COM5 connect using the following steps:
sudo chmod 666 /dev/ttyS5
- This is required since cu changes it's uid which drops capabilities even when running as root. Not all serial programs have the same behavior.stty -F /dev/ttyS5 -a
. Optionally check your current serial settings before updating.- Set your serial settings, depending on your application this usually will be raw or sane. Either one seems to work fine with cu:
stty -F /dev/ttyS5 sane 9600
stty -F /dev/ttyS5 raw 9600 -echo -echoe -echok -echoctl -echoke -iexten -onlcr cs8 crtscts
cu -l /dev/ttyS5 -s 9600
- Hit enter to refresh the cu console
Feedback
Please let us know on our Github about the specific serial scenarios that you are trying. Your feedback helps us prioritize what we should focus on next.
Active5 months ago
I am running Debian 7 (Linux Crunchbang) and wanted to use The Arduino IDE to program my Arduino UNO. To do that I installed the package
arduino
. When I started the Arduino I was asked to add my user to the dialout
group. So I did with sudo usermod -a -G dialout <my-username>
. However when I start the Arduino IDE using
arduino
in the commandline the IDE opens but I am not able to load my program to the Arduino. The error message is 'Serial port COM1 not found. Did you select the right one from the Tools > Serial Port menu?' And when I went to select the Serial Port, the option 'Tools > Serial Port' is greyed out. I thought it is because I did not grant read and write permissions on my usb port (ttyACM0). So I did
Braiamsudo chmod a+rw /dev/ttyACM0
but the option is still greyed out.3,65699 gold badges3636 silver badges6666 bronze badges
MoonlitMoonlit2,1091010 gold badges4343 silver badges7878 bronze badges
16 Answers
chdmod works for my under debian (proxmox):
For installing arduino IDE:
Add the user to dialout group:
Restart Linux.
Try with the File > Examples > 01.Basic > Blink, change the 2 delays to delay(60) and click the upload button for testing on arduino, led must blink faster. ;)
Braiam3,65699 gold badges3636 silver badges6666 bronze badges
user3104260user3104260
sudo arduino is the only way I get the Arduino IDE working (serial port and upload) on ubuntu 12.04 (64)Indeed the serial port to use is /dev/ttyACM0 in my case too.The other two (ttyS4 and ttyS0) gave an error when trying to upload to Uno.Have fun
user3878345user3878345
Close all instances of the arduino IDEopen ~/.arduino/preferences.txt and look for the line:
and change it to your port:
you may have to log out for it to take effect
chaggychaggy
Try Disconnecting the usb and plugging it back in. Its only grayed out because the ide cannot find any com ports that the uno has been plugged into.
another solution is to try all the com ports and see which one works.
finally if all fails try restarting your computer.
user2375589user2375589
open $arduinoHome/arduino in text editor and modify last string:
to
(set property gnu.io.rxtx.SerialPorts to /dev/ttyACMN,where ttyACMN is name of serial port which you use)
it may temporary fix bug in rxtx library. helped me to upload sketch with arduino1.0.5 IDE.
Maybe would helpful for someone.
SildSild86822 gold badges1010 silver badges1919 bronze badges
In my case I solved this issue by uninstalling the version of Arduino that I installed via
apt-get
and instead installed via the official website.With the latest version of Arduino I didn't have the problem described on Ubuntu 18.04.
Philip KirkbridePhilip Kirkbride9,0412727 gold badges9090 silver badges159159 bronze badges
In my case this turned out to be a bad USB hub.
The 'lsusb' command can be used to display all recognized devices. If the unit is not plugged in the option to set the speed will be disabled.
The lsusb command should output something like the string 'Future Technology Devices International, Ltd Bridge(I2C/SPI/UART/FIFO)' if your device is recognized. Mine was an RFDuino
JayJay11.2k33 gold badges3232 silver badges6060 bronze badges
install rx-tx lib for java run this command in terminal
output port
help regconize usb device
Rakibul HasanRakibul Hasan
So I did with
sudo usermod -a -G dialout <my-username>
.You need to log out after you add yourself to a group so those changes are applied. Just log out and log in again and the menu should be available.
BraiamBraiam3,65699 gold badges3636 silver badges6666 bronze badges
Same comment as Philip Kirkbride. It wasn't a permission issue, but using the Arduino IDE downloaded from their website solved my problem.Thanks!Michael
Michael OpdenackerMichael Opdenacker
The following steps install the IDE and remove the error
java.lang.NullPointerException thrown while loading gnu.io.RXTXCommDriver
which usually comes with arduino installed with apt-get
command in Ubuntu.Install the IDE
for removing java error in IDE
This also shows the Serial Port which was grayed out due to the error.
Ubuntu Serial Port Tool Price
Zoe the transgirl16.2k1212 gold badges6767 silver badges9898 bronze badges
Sheetal guptaSheetal gupta
For a Windows solution I've found that disabling and re-enabling the Arduino in Device Manager, then restarting the Arduino IDE does the trick without fail (no unplugging necessary). Why this error occurs in the first place is beyond me. Perhaps the corresponding method for Linux will fix your problem.
Slightly related (not really), I had an issue with an AVR board a while back which was fixed by setting the device to a new COM port in the driver settings. Again, however you linux bunnies do it, I'm sure it'll be cookies and cream.
Cheers brother,
Eddie SpaghettiEddie Spaghetti
I encountered the same issue. My solution was to install and use java7:
Select the number referring to the java-7 path.
Tones29Tones29
You probably don't have the correct permissions. Try adding yourself to these groups.
Then restart your system and check if you got added to the groups.
Good Luck!
Numbers SanNumbers San
Try to run as an administrator...Run terminal, type sudo arduino, type your root password, and... :)
JunsaJunsa
Serial Port Cable
I found this question while trying to troubleshoot the same 'grayed out' port menu problem, except on a windows machine.
For anyone who finds this question in the same situation, I fixed it by right clicking and choosing 'Run as Administrator'.
funrollfunroll26.5k77 gold badges4545 silver badges5454 bronze badges
protected by Community♦May 5 '15 at 8:57
Parallel Port
Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).
Would you like to answer one of these unanswered questions instead?
Would you like to answer one of these unanswered questions instead?