Difference between revisions of "Serial ports usage on Linux"
From ArmadeusWiki
(→Console port) |
(→Changing port parameters) |
||
Line 19: | Line 19: | ||
** change U-Boot ''consoledev'' envt variable, to tell Linux to display console on the LCD (for example): <pre class="apf> BIOS> setenv consoledev tty0</pre> | ** change U-Boot ''consoledev'' envt variable, to tell Linux to display console on the LCD (for example): <pre class="apf> BIOS> setenv consoledev tty0</pre> | ||
− | ==Changing | + | ==Changing serial ports configuration== |
− | * To get current | + | * To get current configuration (adapt serial port device name depending on your board, here ''ttymxc0''): |
<pre class=apf> | <pre class=apf> | ||
− | # stty -F /dev/ | + | # stty -F /dev/ttymxc0 |
speed 115200 baud; | speed 115200 baud; | ||
intr = ^C; quit = ^\; erase = ^?; kill = ^U; eof = ^D; eol = ^J; | intr = ^C; quit = ^\; erase = ^?; kill = ^U; eof = ^D; eol = ^J; | ||
Line 32: | Line 32: | ||
* To only get actual speed: | * To only get actual speed: | ||
<pre class=apf> | <pre class=apf> | ||
− | # stty -F /dev/ | + | # stty -F /dev/ttymxc0 speed |
115200 | 115200 | ||
</pre> | </pre> | ||
− | * By default serial ports are configured as terminal emulator. If you want to use them as "raw" serial port you will have to do first (example for port 1): | + | * By default serial ports are configured as terminal emulator (canonical mode). If you want to use them as "raw" serial port you will have to do first (example for port 1): |
<pre class=apf> | <pre class=apf> | ||
− | # stty -F /dev/ | + | # stty -F /dev/ttymxc1 raw -echo -echoe -echok |
− | + | ||
</pre> | </pre> | ||
* To change baudrate of port 2 to 115200 : | * To change baudrate of port 2 to 115200 : | ||
<pre class=apf> | <pre class=apf> | ||
− | # stty -F /dev/ | + | # stty -F /dev/ttymxc2 115200 |
</pre> | </pre> | ||
Revision as of 22:47, 20 July 2017
How to use the APF's serial ports on Linux.
Contents
[hide]Generalities
On Linux, all serial ports are driven the same way. Only their device nodes are changing to reflect the port type:
- i.MX processor internal ports:
- /dev/ttyUSBN for USB <-> serial converters
- /dev/ttySnN for 16550 compatible FPGA's IP
Console port
- Console port is the default serial port on which you can interact with the board (U-Boot and Linux):
- So, without software modifications, this port is not available to connect a MODEM or any other RS-232 device. If you want to use it as a normal serial port on Linux then:
- be sure that your device won't send data back in response of U-Boot boot's sequence
- change U-Boot consoledev envt variable, to tell Linux to display console on the LCD (for example):
BIOS> setenv consoledev tty0
Changing serial ports configuration
- To get current configuration (adapt serial port device name depending on your board, here ttymxc0):
# stty -F /dev/ttymxc0 speed 115200 baud; intr = ^C; quit = ^\; erase = ^?; kill = ^U; eof = ^D; eol = ^J; eol2 = <undef>; start = ^Q; stop = ^S; susp = ^Z; rprnt = ^R; werase = ^W; lnext = ^V; flush = ^O; min = 1; time = 0; -brkint ixoff -imaxbel -iexten -echoctl
- To only get actual speed:
# stty -F /dev/ttymxc0 speed 115200
- By default serial ports are configured as terminal emulator (canonical mode). If you want to use them as "raw" serial port you will have to do first (example for port 1):
# stty -F /dev/ttymxc1 raw -echo -echoe -echok
- To change baudrate of port 2 to 115200 :
# stty -F /dev/ttymxc2 115200
Sending/Receiving data
- It is simple as opening the device as a file and writing data to it:
# echo "HELLO" > /dev/ttySMX0
- To receive data (ASCII in that case):
# cat /dev/ttySMX0