VAR-SOM-MX7 UART: Difference between revisions

From Variscite Wiki
No edit summary
 
(3 intermediate revisions by 2 users not shown)
Line 1: Line 1:
<!-- Set release according to "release" parameter in URL and use RELEASE_DUNFELL_V1.1_VAR-SOM-MX7 as default
<!-- Set release according to "release" parameter in URL and use RELEASE_DUNFELL_V1.1_VAR-SOM-MX7 as default
--> {{#vardefine:RELEASE_PARAM|{{#urlget:release|RELEASE_DUNFELL_V1.1_VAR-SOM-MX7}}}} <!--
--> {{INIT_RELEASE_PARAM|RELEASE_DUNFELL_V1.1_VAR-SOM-MX7}} <!--
--> {{#lst:Yocto_Platform_Customization|{{#var:RELEASE_PARAM}}}} <!--
--> {{#lst:Yocto_Platform_Customization|{{#var:RELEASE_PARAM}}}} <!--
--> {{#lst:B2QT_Platform_Customization|{{#var:RELEASE_PARAM}}}} <!--
--> {{#lst:B2QT_Platform_Customization|{{#var:RELEASE_PARAM}}}} <!--
--> {{#lst:Debian_Platform_Customization|{{#var:RELEASE_PARAM}}}} <!--
--> {{#lst:Android_Platform_Customization|{{#var:RELEASE_PARAM}}}} <!--
--> {{#lst:Android_Platform_Customization|{{#var:RELEASE_PARAM}}}} <!--
--> {{PageHeader|{{#var:HARDWARE_NAME}} UART}} {{DocImage|category1=Yocto|category2=Android}}[[Category:Debian]][[Category:{{#var:HARDWARE_NAME}}]] __toc__
--> {{PageHeader|{{#var:HARDWARE_NAME}} UART}} {{DocImage|category1=Yocto|category2=Android}}[[Category:Debian]][[Category:{{#var:HARDWARE_NAME}}]] __toc__
Line 39: Line 40:
'''Note:''' UART3 is used by the Bluetooth module on the SoM. It can be used by the carrier board by disabling the UART buffer on the SoM.
'''Note:''' UART3 is used by the Bluetooth module on the SoM. It can be used by the carrier board by disabling the UART buffer on the SoM.


Disable the Bluetooth buffer on the SoM
Disable the Bluetooth buffer on the SoM:


  # echo 6 > /sys/class/gpio/export
  # echo 6 > /sys/class/gpio/export
  # echo out > /sys/class/gpio/gpio16/direction
  # echo out > /sys/class/gpio/gpio6/direction
  # echo 1 > /sys/class/gpio/gpio16/value
  # echo 1 > /sys/class/gpio/gpio6/value


Short J13.1 with J13.3 and J13.5 with J13.7, then run the following commands:
Short J13.1 with J13.3 and J13.5 with J13.7, then run the following commands:
 
  # stty -F /dev/ttymxc2 -echo -onlcr 115200 crtscts
  # stty -F /dev/ttymxc2 -echo -onlcr 115200 crtscts
  # cat /dev/ttymxc2 &
  # cat /dev/ttymxc2 &

Latest revision as of 19:19, 2 August 2023

Warning: This page is designed to be used with a 'release' URL parameter.

This page is using the default release RELEASE_DUNFELL_V1.1_VAR-SOM-MX7.
To view this page for a specific Variscite SoM and software release, please follow these steps:

  1. Visit variwiki.com
  2. Select your SoM
  3. Select the software release
VAR-SOM-MX7 UART

UART Overview

On VAR-SOM-MX7, UARTS 1-3 are enabled by default.
UART1 is connected to the debug console.
UART2 is connected to the J5 header on VAR-MX7CustomBoard.
UART3 is connected to the Bluetooth module on the SoM.

UART naming under Linux

The Linux devices corresponding to UART1-UART3 are /dev/ttymxc0 - /dev/ttymxc2 respectively.

Testing UART2 on VAR-SOM-MX7

Short J5.5 with J5.7 and J5.6 with J5.8, then run the following commands:

# stty -F /dev/ttymxc1 -echo -onlcr 115200 crtscts
# cat /dev/ttymxc1 &
# echo hello > /dev/ttymxc1

For each time you run this echo command the "hello" string should appear on the terminal.

Testing UART3 on VAR-SOM-MX7

Note: UART3 is used by the Bluetooth module on the SoM. For SoM configurations without the WiFi/BT module installed, UART3 can be used by the carrier board.

Short J13.1 with J13.3 and J13.5 with J13.7, then run the following commands:

# stty -F /dev/ttymxc2 -echo -onlcr 115200 crtscts
# cat /dev/ttymxc2 &
# echo hello > /dev/ttymxc2

For each time you run this echo command the "hello" string should appear on the terminal.

Testing UART3 on VAR-SOM-MX7-5G

Note: UART3 is used by the Bluetooth module on the SoM. It can be used by the carrier board by disabling the UART buffer on the SoM.

Disable the Bluetooth buffer on the SoM:

# echo 6 > /sys/class/gpio/export
# echo out > /sys/class/gpio/gpio6/direction
# echo 1 > /sys/class/gpio/gpio6/value

Short J13.1 with J13.3 and J13.5 with J13.7, then run the following commands:

# stty -F /dev/ttymxc2 -echo -onlcr 115200 crtscts
# cat /dev/ttymxc2 &
# echo hello > /dev/ttymxc2

For each time you run this echo command the "hello" string should appear on the terminal.

Configuring RS485 Half-Duplex

Each UART can be configured for RS485 Half-Duplex mode by using a GPIO pin to drive the receive and transmit enable inputs. This can be configured in the device tree by making the following changes to the uart node and replacing X, Y & Z with the proper values:

&uartX {                                                          /* Add RS485 properties to uartX */
	pinctrl-names = "default";
	pinctrl-0 = <&pinctrl_uartX>, <&pinctrl_uartX_rs485>;     /* Add RS485 GPIO pinctrl */
	rts-gpios = <&gpioY Z GPIO_ACTIVE_LOW>;                   /* Add rts-gpios property */
	linux,rs485-enabled-at-boot-time;                         /* Enable RS485 at boot time to skip using TIOCSRS485 ioctl */
	status = "okay";
};

Next, configure the RS485 GPIO pin by adding pinctrl_uartX_rs485 to iomuxc. Replace X, GPIO_PIN_FUNCTION, and GPIO_PIN_SETTINGS with the proper values:

&iomuxc {
	pinctrl_uartX_rs485: uartXrs485 {
		fsl,pins = <
			GPIO_PIN_FUNCTION  GPIO_PIN_SETTINGS
		>;
	};
};

Note: For more information about configuring pins, please see i.MX Device Tree Pinmux Settings Guide


After making these changes, RS485 mode will be enabled by default and can be verified from the console by running the commands below. Replace N with the proper value, which is typically X-1 relative to the device tree node uartX:

# stty -F /dev/ttymxcN -echo -onlcr 115200
# echo hello > /dev/ttymxcN

The below logic analyzer capture shows the RS485 RX/TX enable line toggling when writing to the UART:

Rs485.png


Please refer to the Linux device tree bindings for more RS485 configuration options.