Trouble Enabling UART_E on Khadas VIM

Hello Khadas Community,

I’m working on a project involving a Khadas VIM4 board and an Xsens MTi-670 Development Kit. My goal is to establish UART communication between the VIM4 and the Xsens device to receive sensor data using the Xsens ROS 2 driver. The Xsens device communicates over UART at a baud rate of 921600. I have connected the Xsens MTi-670 DK to the Khadas VIM4 GPIO header, using the UART_E interface on pins 18 (UART_RX) and 19 (UART_TX) for UART communication, and have connected the grounds between the devices.

Wire the UART Connections:

Xsens Pin 15 (UART_TxD) ➔ Khadas Pin 18 (UART_RX)
Xsens Pin 16 (UART_RxD) ➔ Khadas Pin 19 (UART_TX)
Xsens Pin 2 (GND) ➔ Khadas Pin 9 (GND)

To configure the UART_E interface, I edited the file /boot/dtb/amlogic/kvim4.dtb.overlay.env to include fdt_overlays=uart_e and verified that the uart_e.dtbo file exists in /boot/dtb/amlogic/kvim4.dtb.overlays/. I attempted a UART loopback test by connecting pins 18 and 19 together and used picocom and cat/echo commands to test communication, but no data was echoed back during the tests. I installed ROS 2 and the Xsens ROS 2 driver, compiling the XDA library for ARM64 architecture.

Noticing that the &uart_E node is missing in the decompiled Device Tree Source (kvim4.dts), I created a uart_e.dts file to define and enable the uart_E node. When attempting to compile uart_e.dts to uart_e.dtbo using dtc -I dts -O dtb -o uart_e.dtbo uart_e.dts, I encountered a syntax error: Error: uart_e.dts:13.33-34 syntax error; FATAL ERROR: Unable to parse input tree. I tried including header files in uart_e.dts to define CLKID_UART_E and also replaced CLKID_UART_E with the numeric value 196 in the clocks property, but I’m unsure if this is correct. Despite these attempts, UART_E still did not function after applying the overlay.

/dts-v1/;
/plugin/;

/ {
    fragment@0 {
        target-path = "/";
        __overlay__ {
            uart_E: serial@fe080000 {
                compatible = "amlogic,meson-axg-uart";
                reg = <0x0 0xfe080000 0x0 0x18>;
                reg-shift = <2>;
                interrupts = <59>;
                clocks = <&clkc CLKID_UART_E>;
                clock-names = "baud";
                status = "okay";
                pinctrl-names = "default";
                pinctrl-0 = <&uart_e_pins>;
            };
        };
    };

    fragment@1 {
        target = <&pinctrl>;
        __overlay__ {
            uart_e_pins: uart_e_pins {
                mux {
                    groups = "uart_e_tx", "uart_e_rx";
                    function = "uart_e";
                };
            };
        };
    };
};

I’m uncertain whether GPIOH_4 and GPIOH_5 are correctly assigned to UART_E on the VIM4 and whether these GPIO pins are being used by other functions. I’m also unsure about the correct values for clocks, interrupts, and other properties in the Device Tree Overlay. I have tried testing at different baud rates (115200 and 921600) without success and verified that my user is part of the dialout group for serial port permissions.

I would appreciate guidance on properly defining and enabling the uart_E node in the Device Tree for the Khadas VIM4 and on successfully performing the UART loopback test on UART_E. Specifically, I need assistance with the correct values for clocks, interrupts, and other properties in the DTO; confirmation on whether GPIOH_4 and GPIOH_5 are the correct pins for UART_E on the VIM4; and steps to ensure these GPIO pins are not used by other functions. Any advice on potential pitfalls or required configurations when interfacing the VIM4 with the Xsens MTi-670 DK over UART would also be greatly appreciated.

Thank you in advance for your time and assistance. I’m looking forward to any suggestions or solutions you might offer to help me enable UART_E on the Khadas VIM4 and establish communication with the Xsens MTi-670 DK.

You need to look at the linux debug port as it is booting. Need to capture that file and look and see if the overlay is actually loading.

If you have any of the wrong names for a node it will not load. I have not worked with the vim4 for a long time, however, out of the box it should have a uart enabled on the 40 pin header. As for the other stuff, I could not find enough information to continue on with it for the project it was intended for.

With the overlay you should not have to call out the interrupts and register address. That should be in the base .dtsi file. You might only need to callout status “okay”. Look over the base tree and see if the mux is in place. Since we don’t actively use vim4 I sure don’t remember all the details, sorry not much more help.

FYI, if you have not already found out it is best to use SD card booting when working with device tree. It is extremely easy to break things and it is simple to fix it when its on SD not emmc.

1 Like

Hello @Manolis_Chrysanidis

Please don’t use PIN18 & PIN19 which is the default serial debug console. You can use PIN15 and PIN16 of UART_E, but you need to enable it via the overlays.

https://docs.khadas.com/products/sbc/vim4/applications/gpio/uart

1 Like