Enable UART4 on i.MX8M Mini A53

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Enable UART4 on i.MX8M Mini A53

Enable UART4 on i.MX8M Mini A53

Overview

The purpose of this document is to provide a guide on how to enable UART 4 on i.MX8M Mini on Cortex A53. By default on i.MX-ATF is set on Cortex M4 Domain, i.MX-ATF helps ensure that i.MX processors boot securely. Reference: imx-atf.

Requirements:

Arm Toolchain: sudo apt-get install gcc-aarch64-linux-gnu

1. Build imx-boot image

For a better reference how to build imx-boot image, go to Section 4.5.13 How to build imx-boot image by using imx-mkimage available on i.MX Linux User's Guide.

 

$ cd  ~ 
$ git clone https://github.com/nxp-imx/uboot-imx -b lf_v2023.04
$ cd uboot-imx/
$ git checkout lf-6.6.23-2.0.0
$ make -j $(nproc --all) ARCH=arm CROSS_COMPILE=aarch64-linux-gnu- imx8mm_evk_defconfig
$ export ARCH=arm64

$ cd  ~ 
$ git clone https://github.com/nxp-imx/imx-mkimage.git
$ cd imx-mkimage/
$ git checkout lf-6.6.23-2.0.0

$ cd ~
$ git clone https://github.com/nxp-imx/imx-atf.git
$ cd imx-atf/
$ git checkout lf-6.6.23-2.0.0

 

The master domain for the UART4 is assigned to the Cortex M4, so, make the following changes to assign it to the A53 processor instead:

diff --git a/plat/imx/imx8m/imx8mm/imx8mm_bl31_setup.c b/plat/imx/imx8m/imx8mm/imx8mm_bl31_setup.c
index 179b6226f..b0427afff 100644
--- a/plat/imx/imx8m/imx8mm/imx8mm_bl31_setup.c
+++ b/plat/imx/imx8m/imx8mm/imx8mm_bl31_setup.c
@@ -114,10 +114,11 @@ static const struct imx_csu_cfg csu_cfg[] = {
 #else
 static const struct imx_rdc_cfg rdc[] = {
        /* Master domain assignment */
-       RDC_MDAn(RDC_MDA_M4, DID1),
+       RDC_MDAn(RDC_MDA_A53, DID0),

        /* 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),

 

After applying the changes, set your toolchain and then, compile with the following command:

$ make PLAT=imx8mm bl31

 

In case you have the following error:

Gaby_dlfnt_0-1728074472389.png

Use this command to unset the flags and compile again:

$ unset LDFLAGS

 

Then, copy the corresponding files to imx-mkimage/iMX8M. For more information, please check section 4.5.13 on i.MX Linux User's Guide.

*NOTE: Some of this files are located on a link which you can access with the following command, for more information check the Release Notes, in this case for version 6.6.23-2.0.0 on Embedded Linux for i.MX Applications Processors.

$ wget https://www.nxp.com/lgfiles/NMG/MAD/YOCTO/firmware-imx-8.24-fbe0a4c.bin
$ chmod +x firmware-imx-8.24-fbe0a4c.bin
$ ./firmware-imx-8.24-fbe0a4c.bin

 

Finally, copy flash.bin located on: imx-mkimage/iMX8M to a folder to flash your board as follows:

You can download the uuu.exe from mfgtools and the .wic file from the prebuild images from: Embeded Linux for i.MX Applications Processors

uuu.exe -b emmc_all flash.bin imx-image-full-imx8mmevk.wic

 

2. Change DTB to enable UART4

First, copy and rename the imx8mm-evk.dts to identify there is a change for enabling UART4:

$ cd linux-imx
$ cp arch/arm64/boot/dts/freescale/imx8mm-evk.dts arch/arm64/boot/dts/freescale/imx8mm-evk-uart4.dts
$ vi arch/arm64/boot/dts/freescale/imx8mm-evk-uart4.dts

And make the following changes:

&ecspi2 {
        status = "disabled";

};


&uart4 {
        pinctrl-names = "default";
        pinctrl-0 = <&pinctrl_uart4>;
        assigned-clocks = <&clk IMX8MM_CLK_UART4>;
        assigned-clock-parents = <&clk IMX8MM_SYS_PLL1_80M>;
        fsl,uart-has-rtscts;
        status = "okay";
};

&iomuxc {
        pinctrl_uart4: uart4grp {
                fsl,pins = <
                        MX8MM_IOMUXC_ECSPI2_SCLK_UART4_DCE_RX           0x140
                        MX8MM_IOMUXC_ECSPI2_MOSI_UART4_DCE_TX           0x140
                        MX8MM_IOMUXC_ECSPI2_SS0_UART4_DCE_RTS_B         0x140
                        MX8MM_IOMUXC_ECSPI2_MISO_UART4_DCE_CTS_B        0x140
                >;
        };
}

 

After applying the changes, set your toolchain and then, compile with the following commands:

$ make imx_v8_defconfig
$ make freescale/imx8mm-evk-uart4.dtb

Finally, copy the DTB to your board, reboot it and change the DTB in the u-boot environment, boot your board and take a look to see if the UART4 is correctly enabled.

Gaby_dlfnt_0-1728421498540.png

 

 

%3CLINGO-SUB%20id%3D%22lingo-sub-1967129%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3EEnable%20UART4%20on%20i.MX8M%20Mini%20A53%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1967129%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%0A%3CH4%20id%3D%22toc-hId--480617903%22%20id%3D%22toc-hId-200969363%22%3E%3CSTRONG%3EOverview%3C%2FSTRONG%3E%3C%2FH4%3E%0A%3CP%3EThe%20purpose%20of%20this%20document%20is%20to%20provide%20a%20guide%20on%20how%20to%20enable%20UART%204%20on%20i.MX8M%20Mini%20on%20Cortex%20A53.%20By%20default%20on%20i.MX-ATF%20is%20set%20on%20Cortex%20M4%20Domain%2C%20i.MX-ATF%20helps%20ensure%20that%20i.MX%20processors%20boot%20securely.%20Reference%3A%20%3CA%20href%3D%22https%3A%2F%2Fgithub.com%2Fnxp-imx%2Fimx-atf%22%20target%3D%22_self%22%20rel%3D%22nofollow%20noopener%20noreferrer%22%3Eimx-atf%3C%2FA%3E.%3C%2FP%3E%0A%3CH4%20id%3D%22toc-hId-2006894930%22%20id%3D%22toc-hId--1606485100%22%3ERequirements%3A%3C%2FH4%3E%0A%3CP%3EArm%20Toolchain%3A%20%3CSTRONG%3Esudo%20apt-get%20install%20gcc-aarch64-linux-gnu%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CH3%20id%3D%22toc-hId-1996391826%22%20id%3D%22toc-hId--1616988204%22%3E1.%20Build%20imx-boot%20image%3C%2FH3%3E%0AFor%20a%20better%20reference%20how%20to%20build%20imx-boot%20image%2C%20go%20to%20%3CSTRONG%3ESection%204.5.13%20How%20to%20build%20imx-boot%20image%20by%20using%20imx-mkimage%3C%2FSTRONG%3E%20available%20on%20%3CA%20href%3D%22https%3A%2F%2Fwww.nxp.com%2Fdocs%2Fen%2Fuser-guide%2FIMX_LINUX_USERS_GUIDE.pdf%22%20target%3D%22_self%22%20rel%3D%22nofollow%20noopener%20noreferrer%22%3Ei.MX%20Linux%20User's%20Guide%3C%2FA%3E.%0A%3CBR%20%2F%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-csharp%22%3E%3CCODE%3E%24%20cd%20%20~%20%0A%24%20git%20clone%20https%3A%2F%2Fgithub.com%2Fnxp-imx%2Fuboot-imx%20-b%20lf_v2023.04%0A%24%20cd%20uboot-imx%2F%0A%24%20git%20checkout%20lf-6.6.23-2.0.0%0A%24%20make%20-j%20%24(nproc%20--all)%20ARCH%3Darm%20CROSS_COMPILE%3Daarch64-linux-gnu-%20imx8mm_evk_defconfig%0A%24%20export%20ARCH%3Darm64%0A%0A%24%20cd%20%20~%20%0A%24%20git%20clone%20https%3A%2F%2Fgithub.com%2Fnxp-imx%2Fimx-mkimage.git%0A%24%20cd%20imx-mkimage%2F%0A%24%20git%20checkout%20lf-6.6.23-2.0.0%0A%0A%24%20cd%20~%0A%24%20git%20clone%20https%3A%2F%2Fgithub.com%2Fnxp-imx%2Fimx-atf.git%0A%24%20cd%20imx-atf%2F%0A%24%20git%20checkout%20lf-6.6.23-2.0.0%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CBR%20%2F%3E%0A%3CP%3EThe%20master%20domain%20for%20the%20UART4%20is%20assigned%20to%20the%20Cortex%20M4%2C%20so%2C%20make%20the%20following%20changes%20to%20assign%20it%20to%20the%20A53%20processor%20instead%3A%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-csharp%22%3E%3CCODE%3Ediff%20--git%20a%2Fplat%2Fimx%2Fimx8m%2Fimx8mm%2Fimx8mm_bl31_setup.c%20b%2Fplat%2Fimx%2Fimx8m%2Fimx8mm%2Fimx8mm_bl31_setup.c%0Aindex%20179b6226f..b0427afff%20100644%0A---%20a%2Fplat%2Fimx%2Fimx8m%2Fimx8mm%2Fimx8mm_bl31_setup.c%0A%2B%2B%2B%20b%2Fplat%2Fimx%2Fimx8m%2Fimx8mm%2Fimx8mm_bl31_setup.c%0A%40%40%20-114%2C10%20%2B114%2C11%20%40%40%20static%20const%20struct%20imx_csu_cfg%20csu_cfg%5B%5D%20%3D%20%7B%0A%20%23else%0A%20static%20const%20struct%20imx_rdc_cfg%20rdc%5B%5D%20%3D%20%7B%0A%20%20%20%20%20%20%20%20%2F*%20Master%20domain%20assignment%20*%2F%0A-%20%20%20%20%20%20%20RDC_MDAn(RDC_MDA_M4%2C%20DID1)%2C%0A%2B%20%20%20%20%20%20%20RDC_MDAn(RDC_MDA_A53%2C%20DID0)%2C%0A%0A%20%20%20%20%20%20%20%20%2F*%20peripherals%20domain%20permission%20*%2F%0A-%20%20%20%20%20%20%20RDC_PDAPn(RDC_PDAP_UART4%2C%20D1R%20%7C%20D1W)%2C%0A%2B%20%20%20%20%20%20%20RDC_PDAPn(RDC_PDAP_UART4%2C%20D0R%20%7C%20D0W)%2C%0A%20%20%20%20%20%20%20%20RDC_PDAPn(RDC_PDAP_UART2%2C%20D0R%20%7C%20D0W)%2C%0A%20%20%20%20%20%20%20%20RDC_PDAPn(RDC_PDAP_UART1%2C%20D0R%20%7C%20D0W)%2C%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CBR%20%2F%3E%0A%3CP%3EAfter%20applying%20the%20changes%2C%20set%20your%20toolchain%20and%20then%2C%20compile%20with%20the%20following%20command%3A%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-csharp%22%3E%3CCODE%3E%24%20make%20PLAT%3Dimx8mm%20bl31%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CBR%20%2F%3E%0A%3CP%3EIn%20case%20you%20have%20the%20following%20error%3A%3C%2FP%3E%0A%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22Gaby_dlfnt_0-1728074472389.png%22%20style%3D%22width%3A%20999px%3B%22%3E%3Cspan%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22Gaby_dlfnt_0-1728074472389.png%22%20style%3D%22width%3A%20999px%3B%22%3E%3Cimg%20src%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F302779i6C36D0BC2A03B1C0%2Fimage-size%2Flarge%3Fv%3Dv2%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%22Gaby_dlfnt_0-1728074472389.png%22%20alt%3D%22Gaby_dlfnt_0-1728074472389.png%22%20%2F%3E%3C%2Fspan%3E%3C%2FSPAN%3E%0A%3CP%3EUse%20this%20command%20to%20unset%20the%20flags%20and%20compile%20again%3A%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-csharp%22%3E%3CCODE%3E%24%20unset%20LDFLAGS%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CBR%20%2F%3E%0A%3CP%3EThen%2C%20copy%20the%20corresponding%20files%20to%20imx-mkimage%2FiMX8M.%20For%20more%20information%2C%20please%20check%20section%204.5.13%20on%20%3CA%20href%3D%22https%3A%2F%2Fwww.nxp.com%2Fdocs%2Fen%2Fuser-guide%2FIMX_LINUX_USERS_GUIDE.pdf%22%20target%3D%22_self%22%20rel%3D%22nofollow%20noopener%20noreferrer%22%3Ei.MX%20Linux%20User's%20Guide%3C%2FA%3E.%3C%2FP%3E%0A%3CP%3E*NOTE%3A%20Some%20of%20this%20files%20are%20located%20on%20a%20link%20which%20you%20can%20access%20with%20the%20following%20command%2C%20for%20more%20information%20check%20the%20Release%20Notes%2C%20in%20this%20case%20for%20version%206.6.23-2.0.0%20on%20%3CA%20href%3D%22https%3A%2F%2Fwww.nxp.com%2Fdesign%2Fdesign-center%2Fsoftware%2Fembedded-software%2Fi-mx-software%2Fembedded-linux-for-i-mx-applications-processors%3AIMXLINUX%22%20target%3D%22_self%22%20rel%3D%22nofollow%20noopener%20noreferrer%22%3EEmbedded%20Linux%20for%20i.MX%20Applications%20Processors%3C%2FA%3E.%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-csharp%22%3E%3CCODE%3E%24%20wget%20https%3A%2F%2Fwww.nxp.com%2Flgfiles%2FNMG%2FMAD%2FYOCTO%2Ffirmware-imx-8.24-fbe0a4c.bin%0A%24%20chmod%20%2Bx%20firmware-imx-8.24-fbe0a4c.bin%0A%24%20.%2Ffirmware-imx-8.24-fbe0a4c.bin%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CBR%20%2F%3E%0A%3CP%3EFinally%2C%20copy%20%3CSTRONG%3Eflash.bin%3C%2FSTRONG%3E%20located%20on%3A%20%3CEM%3Eimx-mkimage%2FiMX8M%3C%2FEM%3E%20to%20a%20folder%20to%20flash%20your%20board%20as%20follows%3A%3C%2FP%3E%0A%3CP%3EYou%20can%20download%20the%20uuu.exe%20from%20%3CA%20href%3D%22https%3A%2F%2Fgithub.com%2Fnxp-imx%2Fmfgtools%2Freleases%2Ftag%2Fuuu_1.5.182%22%20target%3D%22_self%22%20rel%3D%22nofollow%20noopener%20noreferrer%22%3Emfgtools%3C%2FA%3E%20and%20the%20.wic%20file%20from%20the%20prebuild%20images%20from%3A%20%3CA%20href%3D%22https%3A%2F%2Fwww.nxp.com%2Fdesign%2Fdesign-center%2Fsoftware%2Fembedded-software%2Fi-mx-software%2Fembedded-linux-for-i-mx-applications-processors%3AIMXLINUX%22%20target%3D%22_self%22%20rel%3D%22nofollow%20noopener%20noreferrer%22%3EEmbeded%20Linux%20for%20i.MX%20Applications%20Processors%3C%2FA%3E%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-csharp%22%3E%3CCODE%3Euuu.exe%20-b%20emmc_all%20flash.bin%20imx-image-full-imx8mmevk.wic%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CH3%20id%3D%22toc-hId-188937363%22%20id%3D%22toc-hId-870524629%22%3E%26nbsp%3B%3C%2FH3%3E%0A%3CH3%20id%3D%22toc-hId--1618517100%22%20id%3D%22toc-hId--936929834%22%3E2.%20Change%20DTB%20to%20enable%20UART4%3C%2FH3%3E%0A%3CP%3EFirst%2C%20copy%20and%20rename%20the%20%3CEM%3Eimx8mm-evk.dts%3C%2FEM%3E%20to%20identify%20there%20is%20a%20change%20for%20enabling%20UART4%3A%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-csharp%22%3E%3CCODE%3E%24%20cd%20linux-imx%0A%24%20cp%20arch%2Farm64%2Fboot%2Fdts%2Ffreescale%2Fimx8mm-evk.dts%20arch%2Farm64%2Fboot%2Fdts%2Ffreescale%2Fimx8mm-evk-uart4.dts%0A%24%20vi%20arch%2Farm64%2Fboot%2Fdts%2Ffreescale%2Fimx8mm-evk-uart4.dts%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3EAnd%20make%20the%20following%20changes%3A%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-csharp%22%3E%3CCODE%3E%26amp%3Becspi2%20%7B%0A%20%20%20%20%20%20%20%20status%20%3D%20%22disabled%22%3B%0A%0A%7D%3B%0A%0A%0A%26amp%3Buart4%20%7B%0A%20%20%20%20%20%20%20%20pinctrl-names%20%3D%20%22default%22%3B%0A%20%20%20%20%20%20%20%20pinctrl-0%20%3D%20%26lt%3B%26amp%3Bpinctrl_uart4%26gt%3B%3B%0A%20%20%20%20%20%20%20%20assigned-clocks%20%3D%20%26lt%3B%26amp%3Bclk%20IMX8MM_CLK_UART4%26gt%3B%3B%0A%20%20%20%20%20%20%20%20assigned-clock-parents%20%3D%20%26lt%3B%26amp%3Bclk%20IMX8MM_SYS_PLL1_80M%26gt%3B%3B%0A%20%20%20%20%20%20%20%20fsl%2Cuart-has-rtscts%3B%0A%20%20%20%20%20%20%20%20status%20%3D%20%22okay%22%3B%0A%7D%3B%0A%0A%26amp%3Biomuxc%20%7B%0A%20%20%20%20%20%20%20%20pinctrl_uart4%3A%20uart4grp%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20fsl%2Cpins%20%3D%20%26lt%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20MX8MM_IOMUXC_ECSPI2_SCLK_UART4_DCE_RX%20%20%20%20%20%20%20%20%20%20%200x140%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20MX8MM_IOMUXC_ECSPI2_MOSI_UART4_DCE_TX%20%20%20%20%20%20%20%20%20%20%200x140%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20MX8MM_IOMUXC_ECSPI2_SS0_UART4_DCE_RTS_B%20%20%20%20%20%20%20%20%200x140%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20MX8MM_IOMUXC_ECSPI2_MISO_UART4_DCE_CTS_B%20%20%20%20%20%20%20%200x140%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%26gt%3B%3B%0A%20%20%20%20%20%20%20%20%7D%3B%0A%7D%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CBR%20%2F%3E%0A%3CP%3EAfter%20applying%20the%20changes%2C%20set%20your%20toolchain%20and%20then%2C%20compile%20with%20the%20following%20commands%3A%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-csharp%22%3E%3CCODE%3E%24%20make%20imx_v8_defconfig%0A%24%20make%20freescale%2Fimx8mm-evk-uart4.dtb%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3EFinally%2C%20copy%20the%20DTB%20to%20your%20board%2C%20reboot%20it%20and%20change%20the%20DTB%20in%20the%20u-boot%20environment%2C%20boot%20your%20board%20and%20take%20a%20look%20to%20see%20if%20the%20UART4%20is%20correctly%20enabled.%3C%2FP%3E%0A%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22Gaby_dlfnt_0-1728421498540.png%22%20style%3D%22width%3A%20474px%3B%22%3E%3Cspan%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22Gaby_dlfnt_0-1728421498540.png%22%20style%3D%22width%3A%20474px%3B%22%3E%3Cimg%20src%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F303518iCDA46354288803A9%2Fimage-dimensions%2F474x46%3Fv%3Dv2%22%20width%3D%22474%22%20height%3D%2246%22%20role%3D%22button%22%20title%3D%22Gaby_dlfnt_0-1728421498540.png%22%20alt%3D%22Gaby_dlfnt_0-1728421498540.png%22%20%2F%3E%3C%2Fspan%3E%3C%2FSPAN%3E%0A%3CBR%20%2F%3E%0A%3CBR%20%2F%3E%0A%3C%2FLINGO-BODY%3E
No ratings
Version history
Last update:
‎10-08-2024 02:57 PM
Updated by: