Enable UART4 on the verdin

Hi,

My goal is to enable the UART4 interface on the Verdin. Both the online UART article and the manual list that this uart is used a the debug port of the Cortex-M4, unless you properly modify the device tree.
My question is about properly modifying the device tree.

The device tree in the toradex git folder for the verdin has the following UART4 entry:

		serial@30a60000 {
			compatible = "fsl,imx8mm-uart\0fsl,imx6q-uart";
			reg = <0x30a60000 0x10000>;
			interrupts = <0x00 0x1d 0x04>;
			clocks = <0x02 0xbf 0x02 0xbf>;
			clock-names = "ipg\0per";
			dmas = <0x2a 0x1c 0x04 0x00 0x2a 0x1d 0x04 0x00>;
			dma-names = "rx\0tx";
			status = "disabled";
			pinctrl-names = "default";
			pinctrl-0 = <0x3e>;
		};

This is very similar to the other uart entries, besides the status being disabled. Updating the status to “okay” results in kernal panic during the boot sequency. I am wondering where it is specified that this is the debug interface for the Cortex-M4 and what modifications I should make to properly modify the device tree.

Greetings @StevenMedusa.

UART4 is allocated to the M4 core by default. If you try to enable this on the device tree, you’ll get a kernel oops just like you experienced. This is documented on imx8mm-verdin-v1.1.dtsi:

/* Verdin UART_4 */
/*
 * resource allocated to M4 by default, must not be accessed from A-35 or you
 * get an OOPS
 */
&uart4 {
	pinctrl-names = "default";
	pinctrl-0 = <&pinctrl_uart4>;
};

This is the default behavior for the i.MX 8M Mini SoC. To change this, you should edit the resource allocation. For these new SoCs, this is done on the Arm Trusted Firmware. This is probably the corresponding line that is responsible for assigning UART4 for the M4 core: imx8mm_bl31_setup.c « imx8mm « imx8m « imx « plat - imx-atf.git - Reference implementation of ARM secure world software for i.MX

If you really need to use UART4 for the A53 core, you should recompile ATF and ship that with your image. If you’re building a custom image using Yocto, you can bbappend the imx-atf recipe and patch the file above.

We also have some documentation on building this manually: Build U-Boot and Linux Kernel from Source Code | Toradex Developer Center

1 Like

Some time has passed but at this point I want to confirm this answer because I have verified that it works and it might help somebody else.

As suggested by @gustavo.tx the line:

RDC_PDAPn(RDC_PDAP_UART4, D1R | D1W),

should be replaced by:

RDC_PDAPn(RDC_PDAP_UART4, D0R | D0W),

Just create a boot container as is explained in the documentation mentioned by @gustavo.tx as well. If you use the default device tree provided by Toradex you can just put the status of the newly freed serialport to “okay”. Which then looks something like this:

serial@30a60000 {
				compatible = "fsl,imx8mm-uart\0fsl,imx6q-uart";
				reg = <0x30a60000 0x10000>;
				interrupts = <0x00 0x1d 0x04>;
				clocks = <0x02 0xbf 0x02 0xbf>;
				clock-names = "ipg\0per";
				dmas = <0x2a 0x1c 0x04 0x00 0x2a 0x1d 0x04 0x00>;
				dma-names = "rx\0tx";
				status = "okay";
				pinctrl-names = "default";
				pinctrl-0 = <0x3e>;
			};
1 Like

Glad your problem solved. Thank you very much for the update!

Hey there,

I have been working on this same issue on an IMX8MM 2GB IT and keep running into a kernel panic after enabling UART4. The Yocto environment I am using is a bit unique due to company firewalls, so I did my best to translate these steps to our situation.

We have an offline version of the imx-atf.git repository as a tar.gz file, and the Yocto system points to this location for all of its build resources. I noticed that two git patches are applied by the imx-atf recipe, so I attempted to generate another and add it to the list.

Should I be able to make this process work? Am I missing any key steps? Thank you.

Hi @sarrasmi!

Could you please create a new question?

Since the original question was solved using those methods, most probably your issue is different.

You can reference this question on your new one.

Best regards,

Hi @StevenMedusa and @gustavo.tx,

is the solution with patching the file imx8mm_bl31_setup.c still valid for BSPv6.0?
I used this disable-uart4.patch:

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

and this layers/meta-custom/recipes-bsp/imx-atf/imx-atf_%.bbappend:

FILESEXTRAPATHS:prepend := "${THISDIR}/files/:"
SRC_URI:append = " file://disable-uart4.patch"

When I call bitbake imx-atf -c compile I see in build/tmp/work/verdin_imx8mm-tdx-linux/imx-atf/2.6+gitAUTOINC+c6a19b1a35-r0/git/plat/imx/imx8m/imx8mm_bl31_setup.c that the patch is used successfully. Nevertheless I get a kernel panic on bootup, when UART_4 is enabled in the default device tree.

Best regards,
Markus

Hi @Mowlwurf !

This thread is 3 years old. Could you please create a new topic?

You can of course refer to this topic. :slight_smile:

Best regards,