How to do change U-Boot output to UART B or UART C on Colibri iMX7?

I’m trying to switch the output and console of U-boot from UART A to UART B or C on an iMX7. I’d prefer to use UART C, but UART B would be a step in the right direction. I found this question which is very similar and tried to follow the patch provided there:

But the U-boot source code for the iMX6 and iMX7 are different enough that this doesn’t seem to work, for example the iMX6 source code defines CONFIG_MXC_UART and CONFIG_MXC_UART_BASE but the iMX7 code does not.

Following the patch for the iMX6 in the other question I changed the pin mux code in the file board/toradex/colibri_imx7/colibri_imx7.c from:

static iomux_v3_cfg_t const uart1_pads[] = {
        MX7D_PAD_UART1_RX_DATA__UART1_DTE_TX | MUX_PAD_CTRL(UART_PAD_CTRL),
        MX7D_PAD_UART1_TX_DATA__UART1_DTE_RX | MUX_PAD_CTRL(UART_PAD_CTRL),
        MX7D_PAD_SAI2_TX_BCLK__UART1_DTE_CTS | MUX_PAD_CTRL(UART_PAD_CTRL),
        MX7D_PAD_SAI2_TX_SYNC__UART1_DTE_RTS | MUX_PAD_CTRL(UART_PAD_CTRL),
}

to:

static iomux_v3_cfg_t const uart2_pads[] = {
       MX7D_PAD_UART2_RX_DATA__UART2_DTE_TX | MUX_PAD_CTRL(UART_PAD_CTRL),
       MX7D_PAD_UART2_TX_DATA__UART2_DTE_RX | MUX_PAD_CTRL(UART_PAD_CTRL),
       MX7D_PAD_SAI2_TX_DATA__UART2_DTE_CTS | MUX_PAD_CTRL(UART_PAD_CTRL),
       MX7D_PAD_SAI2_RX_DATA__UART2_DTE_RTS | MUX_PAD_CTRL(UART_PAD_CTRL),
 };

and I also updated this function as shown:

static void setup_iomux_uart(void)
{
   imx_iomux_v3_setup_multiple_pads(uart2_pads, ARRAY_SIZE(uart2_pads));
}

But this didn’t have any effect, U-boot’s output still appeared on UART A. I must be missing something else.

I am able to edit the U-boot source code to remove all the output on UART A by enabling the silent feature, which gives me confidence that I am able to edit, build and deploy U-boot. But I would like to preserve U-boot’s functionality for future use - just not on UART A.

Can you provide a patch file for the iMX7D which is equivalent to the one in the other question for the iMX6?

Code changes looks OK. Let me test it next Monday.

Thanks @alex.tx, I’m looking forward to hearing what you find when you get a chance to test this.

Hi @MikeS

Is the issue solved now? I did have a look, these are changes you have to do in U-Boot to change the Linux Console output from UART_A to UART_B:

diff --git a/board/toradex/colibri_imx7/colibri_imx7.c b/board/toradex/colibri_imx7/colibri_imx7.c
index 36214e2bc1..7565ab629a 100644
--- a/board/toradex/colibri_imx7/colibri_imx7.c
+++ b/board/toradex/colibri_imx7/colibri_imx7.c
@@ -61,6 +61,13 @@ static iomux_v3_cfg_t const uart1_pads[] = {
        MX7D_PAD_SAI2_TX_SYNC__UART1_DTE_RTS | MUX_PAD_CTRL(UART_PAD_CTRL),
 };
 
+ static iomux_v3_cfg_t const uart2_pads[] = {
+       MX7D_PAD_UART2_RX_DATA__UART2_DTE_TX | MUX_PAD_CTRL(UART_PAD_CTRL),
+       MX7D_PAD_UART2_TX_DATA__UART2_DTE_RX | MUX_PAD_CTRL(UART_PAD_CTRL),
+       MX7D_PAD_SAI2_TX_DATA__UART2_DTE_CTS | MUX_PAD_CTRL(UART_PAD_CTRL),
+       MX7D_PAD_SAI2_RX_DATA__UART2_DTE_RTS | MUX_PAD_CTRL(UART_PAD_CTRL),
+  };
+
 #ifdef CONFIG_USB_EHCI_MX7
 static iomux_v3_cfg_t const usb_cdet_pads[] = {
        MX7D_PAD_ENET1_CRS__GPIO7_IO14 | MUX_PAD_CTRL(NO_PAD_CTRL),
@@ -185,7 +192,7 @@ static void setup_iomux_fec(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(uart2_pads, ARRAY_SIZE(uart2_pads));
 }
 
 #ifdef CONFIG_FEC_MXC
diff --git a/include/configs/colibri_imx7.h b/include/configs/colibri_imx7.h
index 2acd7459eb..ed66b29915 100644
--- a/include/configs/colibri_imx7.h
+++ b/include/configs/colibri_imx7.h
@@ -24,6 +24,8 @@
 
 #define CONFIG_TFTP_TSIZE
 
+#define CONFIG_MXC_UART_BASE            UART2_IPS_BASE_ADDR
+
 /* ENET1 */
 #define IMX_FEC_BASE                   ENET_IPS_BASE_ADDR
 
@@ -110,7 +112,7 @@
        MODULE_EXTRA_ENV_SETTINGS \
        "boot_file=zImage\0" \
        "bootubipart=ubi\0" \
-       "console=ttymxc0\0" \
+       "console=ttymxc1\0" \
        "defargs=\0" \
        "fdt_board=eval-v3\0" \
        "fdt_fixup=;\0" \

Further you have to disable the getty.device on ttymxc0 by launching the following command:
systemctl disable serial-getty@ttymxc0.service

Regarding the U-Boot Console, I am still looking what to change.

Best regards,
Jaski

HI @MikeS

You need to do the following changes in U-Boot 2019.07 to redirect Console in Linux and U-Boot from UART_A to UART_B:

diff --git a/arch/arm/dts/imx7-colibri-emmc.dts b/arch/arm/dts/imx7-colibri-emmc.dts
index bc0d10c716..4195f72a4a 100644
--- a/arch/arm/dts/imx7-colibri-emmc.dts
+++ b/arch/arm/dts/imx7-colibri-emmc.dts
@@ -19,7 +19,7 @@
        };
 
        chosen {
-               stdout-path = &uart1;
+               stdout-path = &uart2;
        };
 
        reg_5v0: regulator-5v0 {
diff --git a/arch/arm/dts/imx7-colibri.dtsi b/arch/arm/dts/imx7-colibri.dtsi
index 308e0b2a63..82d0d3dfa6 100644
--- a/arch/arm/dts/imx7-colibri.dtsi
+++ b/arch/arm/dts/imx7-colibri.dtsi
@@ -38,6 +38,14 @@
        status = "okay";
 };
 
+&uart2 {
+       pinctrl-names = "default";
+       pinctrl-0 = <&pinctrl_uart2>;
+       uart-has-rtscts;
+       fsl,dte-mode;
+       status = "okay";
+};
+
 &usdhc1 {
        pinctrl-names = "default";
        pinctrl-0 = <&pinctrl_usdhc1 &pinctrl_cd_usdhc1>;
@@ -78,6 +86,17 @@
                >;
        };
 
+
+       pinctrl_uart2: uart2-grp {
+                       fsl,pins = <
+                               MX7D_PAD_UART2_TX_DATA__UART2_DTE_RX 0x79
+                               MX7D_PAD_UART2_RX_DATA__UART2_DTE_TX 0x79
+                               MX7D_PAD_SAI2_RX_DATA__UART2_DTE_RTS 0x79
+                               MX7D_PAD_SAI2_TX_DATA__UART2_DTE_CTS 0x79
+                       >;
+               };
+
+
        pinctrl_usdhc1: usdhc1-grp {
                fsl,pins = <
                        MX7D_PAD_SD1_CMD__SD1_CMD       0x59
diff --git a/include/configs/colibri_imx7.h b/include/configs/colibri_imx7.h
index 2acd7459eb..0e01d04792 100644
--- a/include/configs/colibri_imx7.h
+++ b/include/configs/colibri_imx7.h
@@ -110,7 +110,7 @@
        MODULE_EXTRA_ENV_SETTINGS \
        "boot_file=zImage\0" \
        "bootubipart=ubi\0" \
-       "console=ttymxc0\0" \
+       "console=ttymxc1\0" \
        "defargs=\0" \
        "fdt_board=eval-v3\0" \
        "fdt_fixup=;\0" \

Additionally don’t forget to disable getty.device on ttymxc0 in Linux by launching the following command: systemctl disable serial-getty@ttymxc0.service.

Best regards,
Jaski

MX7D_PAD_SAI2_RX_DATA__UART2_DTE_RTS ,MX7D_PAD_SAI2_TX_DATA__UART2_DTE_CTS are NOT declared.
Remove these MX7D_PAD_SAI2_RX_DATA__UART2_DTE_RTS ,MX7D_PAD_SAI2_TX_DATA__UART2_DTE_CTS flags and build the image.

stemctl disable serial-getty@ttymxc0.service should be executed from ttymxc1 and reset.

Works fine !!!

Hi @Jack2405

Thanks for your Input.

Best regards,
Jaski