DART-6UL UART

From Variscite Wiki
DART-6UL - UART

1 Test external UART

By default, Variscite enabled in the device tree the following UARTs.

configuration 6UL Custom Board Concerto Board Symphony Board
UART UART3 UART5 UART7
device /dev/ttymxc2 /dev/ttymxc4 /dev/ttymxc6
RX pin J9.5 J26.4 J18.9
TX pin J9.7 J26.2 J18.7

To test you can use minicom to connect.
Set the serial to the right device.
You can use a loopback or connect to anther computer.

2 Example: configure UART4, ttymxc3 (using DART-6UL)

In the kernel source code, edit the following device tree file:
arch/arm/boot/dts/imx6ul-imx6ull-var-dart-common.dtsi
(In earlier releases the file is named: arch/arm/boot/dts/imx6ul-var-dart.dtsi)

Look for:

/* ttymxc2 UART */
&uart3 {
	pinctrl-names = "default";
	pinctrl-0 = <&pinctrl_uart3>;
	fsl,uart-has-rtscts;
	status = "okay";
};

Duplicate it and change the name and the pinctrl. For Example:

&uart4 {
	pinctrl-names = "default";
	pinctrl-0 = <&pinctrl_uart4>;
	fsl,uart-has-rtscts;
	status = "okay";
};

Duplicate the corresponding pinctrl. Copy :

		pinctrl_uart2: uart2grp {
			fsl,pins = <
				MX6UL_PAD_UART2_TX_DATA__UART2_DCE_TX	0x1b0b1
				MX6UL_PAD_UART2_RX_DATA__UART2_DCE_RX	0x1b0b1
				MX6UL_PAD_UART2_CTS_B__UART2_DCE_CTS	0x1b0b1
				MX6UL_PAD_UART2_RTS_B__UART2_DCE_RTS	0x1b0b1
			>;
		};

Into:

		pinctrl_uart4: uart4grp {
			fsl,pins = <
                                MX6UL_PAD_UART4_TX_DATA__UART4_DCE_TX   0x1b0b1
                                MX6UL_PAD_UART4_RX_DATA__UART4_DCE_RX   0x1b0b1
				MX6UL_PAD_ENET1_RX_DATA1__UART4_DCE_CTS	0x1b0b1
				MX6UL_PAD_ENET1_RX_DATA0__UART4_DCE_RTS	0x1b0b1
			>;
		};

Note: The pins here were set arbitrarily. You should set them based on your hardware design, and make sure they are not conflicting with other devices in the device tree.

Continue following the "Build Linux from source code" guide to build only the device trees and to copy them to your SD card.

3 Use UART3 for console (instead of UART1)

In the following example we use UART3 for console.
Other UART ports can be used, similarly.

For Debian, the only changes needed are in U-Boot.

Note:
See the notes on pages 6 & 7 on the dart-6ul customboard schematics file:
http://www.variscite.com/images/stories/DataSheets/DART-6UL/VAR-6UL_CUSTOMBOARD_SCH_V1_23_Doc_V1_8.pdf

- "Pull down resistor and delay circuitry is added on DEBUG_UART_RTS_B to allow reboot
   from SD Card using POR signal, since DEBUG_UART_RTS_B is used as SD1_CD_B by Boot ROM.

   In case DEBUG_UART_RTS_B signal is not required, the delay mechanism is redundant and can be depopulated.
   DEBUG_UART_RTS_B however should be always pulled down to ground using a 10K resistor to simulate SD Card detect."

- "Watchdog circuitry is required for proper SW reboot!"

3.1 Changes needed in U-Boot

Subject: [PATCH] mx6ul_var_dart: Use UART3 for console (instead of UART1)

---
 board/variscite/mx6ul_var_dart/mx6ul_var_dart.c | 8 ++++----
 include/configs/mx6ul_var_dart.h                | 4 ++--
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/board/variscite/mx6ul_var_dart/mx6ul_var_dart.c b/board/variscite/mx6ul_var_dart/mx6ul_var_dart.c
index 63a75ec..9d70851 100755
--- a/board/variscite/mx6ul_var_dart/mx6ul_var_dart.c
+++ b/board/variscite/mx6ul_var_dart/mx6ul_var_dart.c
@@ -162,9 +162,9 @@ int dram_init(void){
 }
 
 
-static iomux_v3_cfg_t const uart1_pads[] = {
-	MX6_PAD_UART1_TX_DATA__UART1_DCE_TX | MUX_PAD_CTRL(UART_PAD_CTRL),
-	MX6_PAD_UART1_RX_DATA__UART1_DCE_RX | MUX_PAD_CTRL(UART_PAD_CTRL),
+static iomux_v3_cfg_t const uart3_pads[] = {
+	MX6_PAD_UART3_TX_DATA__UART3_DCE_TX | MUX_PAD_CTRL(UART_PAD_CTRL),
+	MX6_PAD_UART3_RX_DATA__UART3_DCE_RX | MUX_PAD_CTRL(UART_PAD_CTRL),
 };
 
 static iomux_v3_cfg_t const usdhc1_pads[] = {
@@ -253,7 +253,7 @@ static void setup_gpmi_nand(void)
 
 static void setup_iomux_uart(void)
 {
-	imx_iomux_v3_setup_multiple_pads(uart1_pads, ARRAY_SIZE(uart1_pads));
+	imx_iomux_v3_setup_multiple_pads(uart3_pads, ARRAY_SIZE(uart3_pads));
 }
 
 static struct fsl_esdhc_cfg usdhc_cfg[2] = {
diff --git a/include/configs/mx6ul_var_dart.h b/include/configs/mx6ul_var_dart.h
index 5313d17..88bc1a0 100755
--- a/include/configs/mx6ul_var_dart.h
+++ b/include/configs/mx6ul_var_dart.h
@@ -55,7 +55,7 @@
 #define CONFIG_MXC_GPIO
 
 #define CONFIG_MXC_UART
-#define CONFIG_MXC_UART_BASE		UART1_BASE
+#define CONFIG_MXC_UART_BASE		UART3_BASE
 
 /* MMC Configs */
 #ifdef CONFIG_FSL_USDHC
@@ -169,7 +169,7 @@
         BOOT_ENV_SETTINGS \
 	"script=boot.scr\0" \
 	"image=zImage\0" \
-	"console=ttymxc0\0" \
+	"console=ttymxc2\0" \
 	"fdt_high=0xffffffff\0" \
 	"initrd_high=0xffffffff\0" \
 	"var_auto_fdt_file=Y\0" \
-- 
1.9.1

You can follow the "Build U-Boot from source code" guide to get the U-Boot source code and build it.

3.2 Changes needed in Yocto

Edit the file: sources/meta-variscite-imx/conf/machine/imx6ul-var-dart.conf
and change the line:
SERIAL_CONSOLE = "115200 ttymxc0"
to:
SERIAL_CONSOLE = "115200 ttymxc2"

(or you can change it on the target in /etc/inittab)

4 Disable the console

Disabling the serial console completely is not recommended, as it makes it hard or even impossible to analyze errors such as a user interface crash or to get control of the system if it doesn't boot successfully.
If you need to do it anyway, this is how.

For Debian, the only changes needed are in U-Boot.

4.1 Changes needed in U-Boot

Applying the first patch only will still allow you to stop the boot process at U-Boot and get to the U-Boot command line.
Applying the second patch will eliminate that also.

Subject: [PATCH 1/2] mx6ul_var_dart: Silence console

---
 board/variscite/mx6ul_var_dart/mx6ul_var_dart.c | 2 ++
 include/configs/mx6ul_var_dart.h                | 8 +++++++-
 2 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/board/variscite/mx6ul_var_dart/mx6ul_var_dart.c b/board/variscite/mx6ul_var_dart/mx6ul_var_dart.c
index 59c4da7f8a..139b5bc216 100755
--- a/board/variscite/mx6ul_var_dart/mx6ul_var_dart.c
+++ b/board/variscite/mx6ul_var_dart/mx6ul_var_dart.c
@@ -966,8 +966,10 @@ void board_init_f(ulong dummy)
 	/* setup GP timer */
 	timer_init();
 
+#ifndef CONFIG_SPL_NO_CONSOLE
 	/* UART clocks enabled and gd valid - init serial console */
 	preloader_console_init();
+#endif
 
 	setup_i2c(0, CONFIG_SYS_I2C_SPEED, 0x7f, &i2c_pad_info1);
 	setup_i2c(1, CONFIG_SYS_I2C_SPEED, 0x7f, &i2c_pad_info2);
diff --git a/include/configs/mx6ul_var_dart.h b/include/configs/mx6ul_var_dart.h
index 5313d17c21..abbcb11620 100755
--- a/include/configs/mx6ul_var_dart.h
+++ b/include/configs/mx6ul_var_dart.h
@@ -93,6 +93,11 @@
 #define CONFIG_POWER_PFUZE3000_I2C_ADDR  0x08
 #endif
 
+#define CONFIG_SYS_DEVICE_NULLDEV
+#define CONFIG_SILENT_CONSOLE
+#define CONFIG_SILENT_CONSOLE_UPDATE_ON_RELOC
+#define CONFIG_SPL_NO_CONSOLE
+
 #define CONFIG_SYS_MMC_IMG_LOAD_PART	1
 
 #define NAND_BOOT_ENV_SETTINGS \
@@ -169,7 +174,8 @@
         BOOT_ENV_SETTINGS \
 	"script=boot.scr\0" \
 	"image=zImage\0" \
-	"console=ttymxc0\0" \
+	"silent=1\0" \
+	"console=null\0" \
 	"fdt_high=0xffffffff\0" \
 	"initrd_high=0xffffffff\0" \
 	"var_auto_fdt_file=Y\0" \
-- 
2.11.0
Subject: [PATCH 2/2] mx6ul_var_dart: Autoboot with no delay and no check for
 abort

---
 include/configs/mx6ul_var_common.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/configs/mx6ul_var_common.h b/include/configs/mx6ul_var_common.h
index 8556b257be..6139ec6d55 100644
--- a/include/configs/mx6ul_var_common.h
+++ b/include/configs/mx6ul_var_common.h
@@ -72,7 +72,7 @@
 #define CONFIG_SYS_LOAD_ADDR	CONFIG_LOADADDR
 
 #ifndef CONFIG_BOOTDELAY
-#define CONFIG_BOOTDELAY	1
+#define CONFIG_BOOTDELAY	-2
 #endif
 
 /* allow to overwrite serial and ethaddr */
-- 
2.11.0

4.2 Changes needed in Yocto

Edit the file: sources/meta-variscite-imx/conf/machine/imx6ul-var-dart.conf
and change the line:
SERIAL_CONSOLE = "115200 ttymxc0"
to:
SERIAL_CONSOLE = ""

(or you can change it on the target in /etc/inittab)


5 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.