Difference between revisions of "Serial ports usage on Linux"

From ArmadeusWiki
Jump to: navigation, search
m
m
Line 3: Line 3:
 
==Generalities==
 
==Generalities==
  
On Linux all serial ports are driven the same way with their device nodes:
+
On Linux all serial ports are driven the same way. Only their device nodes are changing to reflect the port type:
 
* ''/dev/ttySMXn'' for i.MX processor internal ports
 
* ''/dev/ttySMXn'' for i.MX processor internal ports
 
* ''/dev/ttyUSBn'' for USB <-> serial converters
 
* ''/dev/ttyUSBn'' for USB <-> serial converters
Line 12: Line 12:
 
* So: without software modifications this port is not usable to connect a MODEM or any other RS232 device. If you want to use it a normal serial port on Linux then:
 
* So: without software modifications this port is not usable to connect a MODEM or any other RS232 device. If you want to use it 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
 
** be sure that your device won't send data back in response of U-Boot boot's sequence
** change ''console=ttySMX0,115200'' to ''console=ttySMXN,115200'' in U-Boot ''bootargs'' variable (N=1 on APF9328 and 2 on APF27)
+
** change ''console=ttySMX0,115200'' to ''console=ttySMXN,115200'' in U-Boot ''bootargs'' variable (N=1 on APF9328 and N=2 on APF27)
  
 
==Changing port parameters==
 
==Changing port parameters==
Line 25: Line 25:
 
-iexten -echoctl
 
-iexten -echoctl
 
</pre>
 
</pre>
* Change Baud rate to 115200 of port 2:
+
* Change Baud rate of port 2 to 115200 :
 
<pre class=apf>
 
<pre class=apf>
stty -F /dev/ttySMX2 115200
+
# stty -F /dev/ttySMX2 115200
 
</pre>
 
</pre>
  

Revision as of 09:26, 24 June 2009

How to use the APF's serial ports on Linux.

Generalities

On Linux all serial ports are driven the same way. Only their device nodes are changing to reflect the port type:

  • /dev/ttySMXn for i.MX processor internal ports
  • /dev/ttyUSBn for USB <-> serial converters
  • /dev/ttySn for 16550 compatible FPGA's IP

/dev/ttySMX0

  • /dev/ttySMX0 is the default console on which you can interact with the board (U-Boot and Linux).
  • So: without software modifications this port is not usable to connect a MODEM or any other RS232 device. If you want to use it 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 console=ttySMX0,115200 to console=ttySMXN,115200 in U-Boot bootargs variable (N=1 on APF9328 and N=2 on APF27)

Changing port parameters

  • Get current parameters:
# stty -F /dev/ttySMX0
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
  • Change Baud rate of port 2 to 115200 :
# stty -F /dev/ttySMX2 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