Changing Console UART
The Developer Kits are configured to use UART-A on the carrier boards for the SPL/U-Boot/Linux console. Which actual UART is used depends on the COM/uCOM board as can bee seen in this table.
Changing to use one of the other UARTs as console instead, likely due to the design choices on your custom carrier board, requires changes in several places and this page will help with that.
The code changes below are for iMX8M Mini uCOM which uses UART2 as the default console which will be changed to UART4.
The hexadecimal values below for the UARTs come from the imx8mm.dtsi
file:
Serial - UART link | UART Address |
---|---|
serial0 = &uart1 | uart1: serial@30860000 |
serial1 = &uart2 | uart2: serial@30890000 |
serial2 = &uart3 | uart3: serial@30880000 |
serial3 = &uart4 | uart4: serial@30a60000 |
The important values for now are the old: uart2 / 30890000 and the new: uart4 / 30a60000.
note
The instructions below are for the iMX8M Mini uCOM but it is very similar to the iMX8M Nano uCOM so to do the UART change for an iMX8M Nano uCOM, simply replace the imx8mm with imx8mn in all paths and filenames below.
note
Swapping to a different UART than the UART4 is very similar but requires different changes to the dts files. Use these instructions as a starting point and to know where to change but exactly what to change, what pins to use etc. will be board dependent and is out of scope for this page.
U-Boot
Enable the UART and make it the console.
Open arch/arm/dts/imx8mm-ea-ucom-kit_v2-u-boot.dtsi
:
-&pinctrl_uart2 {
+&pinctrl_uart4 {
u-boot,dm-spl;
};
-&uart2 {
+&uart4 {
u-boot,dm-spl;
};
Open arch/arm/dts/imx8mm-ea-ucom-kit_v2.dts
:
chosen {
- bootargs = "console=ttymxc1,115200 earlycon=ec_imx6q,0x30890000,115200";
- stdout-patch = &uart2;
+ bootargs = "console=ttymxc3,115200 earlycon=ec_imx6q,0x30a60000,115200";
+ stdout-patch = &uart4;
};
-&uart2 { /* console */
+&uart2 { /* old console */
pinctrl-names = "default";
pinctrl-0 = <&pinctrl_uart2>;
+ status = "disabled";
+};
+
+&uart4 { /* new console on UART-B */
+ pinctrl-names = "default";
+ pinctrl-0 = <&pinctrl_uart4>;
status = "okay";
};
+ pinctrl_uart4: uart4grp {
+ fsl,pins = <
+ MX8MM_IOMUXC_UART4_RXD_UART4_DCE_RX 0x49
+ MX8MM_IOMUXC_UART4_TXD_UART4_DCE_TX 0x49
+ >;
+ };
+
Open board/embeddedartists/mx8mmea-ucom/mx8mmea-ucom.c
:
static iomux_v3_cfg_t const uart_pads[] = {
- IMX8MM_PAD_UART2_RXD_UART2_RX | MUX_PAD_CTRL(UART_PAD_CTRL),
- IMX8MM_PAD_UART2_TXD_UART2_TX | MUX_PAD_CTRL(UART_PAD_CTRL),
+ IMX8MM_PAD_UART4_RXD_UART4_RX | MUX_PAD_CTRL(UART_PAD_CTRL),
+ IMX8MM_PAD_UART4_TXD_UART4_TX | MUX_PAD_CTRL(UART_PAD_CTRL),
};
imx_iomux_v3_setup_multiple_pads(uart_pads, ARRAY_SIZE(uart_pads));
- init_uart_clk(1);
+ init_uart_clk(3); //3=UART4
return 0;
}
Open include/configs/mx8mmea-ucom.h
:
"fdt_addr=0x43000000\0" \
"fdt_high=0xffffffffffffffff\0" \
"mtdparts=" MFG_NAND_PARTITION "\0" \
- "console=ttymxc1,115200 earlycon=ec_imx6q,0x30890000,115200\0" \
- "bootargs=console=ttymxc1,115200 earlycon=ec_imx6q,0x30890000,115200 ubi.mtd=5 " \
+ "console=ttymxc3,115200 earlycon=ec_imx6q,0x30a60000,115200\0" \
+ "bootargs=console=ttymxc3,115200 earlycon=ec_imx6q,0x30a60000,115200 ubi.mtd=5 " \
"root=ubi0:nandrootfs rootfstype=ubifs " \
MFG_NAND_PARTITION \
"\0" \
"bsp_script=boot.scr\0" \
"image=Image\0" \
"splashimage=0x50000000\0" \
- "console=ttymxc1,115200\0" \
+ "console=ttymxc3,115200\0" \
"fdt_addr_r=0x43000000\0" \
"fdt_addr=0x43000000\0" \
"fdt_high=0xffffffffffffffff\0" \
-#define CONFIG_MXC_UART_BASE UART2_BASE_ADDR
+#define CONFIG_MXC_UART_BASE UART4_BASE_ADDR
Linux
Enable the UART and make it the console. Open arch/arm64/boot/dts/freescale/imx8mm-ea-ucom-kit_v3.dts
:
chosen {
- bootargs = "console=ttymxc1,115200 earlycon=ec_imx6q,0x30890000,115200";
- stdout-path = &uart2;
+ bootargs = "console=ttymxc3,115200 earlycon=ec_imx6q,0x30a60000,115200";
+ stdout-path = &uart4;
};
+ pinctrl_uart4: uart4grp {
+ fsl,pins = <
+ MX8MM_IOMUXC_UART4_RXD_UART4_DCE_RX 0x140
+ MX8MM_IOMUXC_UART4_TXD_UART4_DCE_TX 0x140
+ >;
+ };
+/* By default UART4 is owned by the M core not the A53 and enabling it here
+ without also removing the ownership from the M core will result in a
+ kernel panic. */
+&uart4 {
+ pinctrl-names = "default";
+ pinctrl-0 = <&pinctrl_uart4>;
+ status = "okay";
+};
Yocto - Machine Configuration
Change the SERIAL_CONSOLES
variable in Yocto. It affects which UART can be used for login.
Open ea-bsp/sources/meta-ea/conf/machine/imx8mmea-ucom.conf
and change this line:
-SERIAL_CONSOLES = "115200;ttymxc1"
+SERIAL_CONSOLES = "115200;ttymxc3"
Yocto - imx-atf
This step is only needed for iMX8M Mini or iMX8M Nano boards as they both use the imx-boot
Yocto recipe to package U-Boot, SPL, ARM Trusted Firmware, DDR Firmware and HDMI Firmware
into one binary. The imx-boot
recipe uses imx-atf
for one of the steps, and it contains
the code that sets up the Resource Domain Controller (RDC). By default, the RDC assigns UART4
to the Cortex-M.
In your build folder, e.g. ea-bsp/b_8mm
, run this command to check out the correct version
of the imx-atf repo:
devtool modify imx-atf
The repo will be checked out locally under ea-bsp/b_8mm/workspaces/sources/imx-atf
.
Open plat/imx/imx8m/imx8mm/imx8mm_bl31_setup.c
and change in two locations (with and without Android):
diff --git a/plat/imx/imx8m/imx8mm/imx8mm_bl31_setup.c b/plat/imx/imx8m/imx8mm/imx8mm_bl31_setup.c
index 8702d5160..c5bb66040 100644
--- a/plat/imx/imx8m/imx8mm/imx8mm_bl31_setup.c
+++ b/plat/imx/imx8m/imx8mm/imx8mm_bl31_setup.c
@@ -61,7 +61,7 @@ static const struct imx_rdc_cfg rdc[] = {
RDC_MDAn(RDC_MDA_M4, DID1),
/* peripherals domain permission */
- RDC_PDAPn(RDC_PDAP_UART4, D1R | D1W),
+ RDC_PDAPn(RDC_PDAP_UART4, D0R | D0W),
RDC_PDAPn(RDC_PDAP_UART2, D0R | D0W),
RDC_PDAPn(RDC_PDAP_UART1, D0R | D0W),
@@ -108,7 +108,7 @@ static const struct imx_rdc_cfg rdc[] = {
RDC_MDAn(RDC_MDA_M4, DID1),
/* peripherals domain permission */
- RDC_PDAPn(RDC_PDAP_UART4, D1R | D1W),
+ RDC_PDAPn(RDC_PDAP_UART4, D0R | D0W),
RDC_PDAPn(RDC_PDAP_UART2, D0R | D0W),
RDC_PDAPn(RDC_PDAP_UART1, D0R | D0W),
Change UART_BASE - 5.15 distribution
Modify plat/imx/imx8m/imx8mm/platform.mk
:
diff --git a/plat/imx/imx8m/imx8mm/platform.mk b/plat/imx/imx8m/imx8mm/platform.mk
index bfbcaed38..901bfe024 100644
--- a/plat/imx/imx8m/imx8mm/platform.mk
+++ b/plat/imx/imx8m/imx8mm/platform.mk
@@ -153,7 +153,7 @@ $(eval $(call add_define,BL32_BASE))
BL32_SIZE ?= 0x2000000
$(eval $(call add_define,BL32_SIZE))
-IMX_BOOT_UART_BASE ?= 0x30890000
+IMX_BOOT_UART_BASE ?= 0x30a60000
$(eval $(call add_define,IMX_BOOT_UART_BASE))
$(eval $(call add_define,IMX8M_DDR4_DVFS))
Change UART_BASE - 6.1 distribution
In the 6.1 distribution the UART_BASE can be changed in <build dir>/conf/local.conf
.
Open local.conf and add:
ATF_BOOT_UART_BASE = "0x30a60000"