How to use UART2/3 of IMX6Q-Sabresd on Android6.1

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

How to use UART2/3 of IMX6Q-Sabresd on Android6.1

1,040 Views
dennyzhou
Contributor II

Hi NXP engineers and all,

  Here is a question, we wanna use UART2/3 of this board. We have an APP of Android which will use UART2/3 to send and receive some data. Currently, we have done these,

1. Set pin defination of UART2/3 in dts/dtsi,

   pinctrl_uart2: uart2grp {
   fsl,pins = <
    MX6QDL_PAD_EIM_D26__UART2_TX_DATA 0x1b0b1
    MX6QDL_PAD_EIM_D27__UART2_RX_DATA 0x1b0b1
   >;
  };

   pinctrl_uart3_1: uart3grp-1 {
   fsl,pins = <
    MX6QDL_PAD_EIM_D25__UART3_RX_DATA 0x1b0b1
    MX6QDL_PAD_EIM_D24__UART3_TX_DATA 0x1b0b1
    MX6QDL_PAD_EIM_D31__UART3_RTS_B  0x1b0b1
    MX6QDL_PAD_EIM_D23__UART3_CTS_B  0x1b0b1
   >;
  };

   ...

   &uart2 {
 pinctrl-names = "default";
 pinctrl-0 = <&pinctrl_uart2>;
 status = "okay";
};

&uart3 {
 pinctrl-names = "default";
 pinctrl-0 = <&pinctrl_uart3_1>;
 fsl,uart-has-rtscts;
 status = "okay";
};

 

  Meanwhile, we are sure that we do not reconfigure them for other functions. They are only for UART function.

  2. We have added the permisson in ueventd.rc in ~/myandroid/system/core/rootdir/.

   

# uart,ttymxc device node is world writable/readable. GP
/dev/ttymxc*              0666   root       root  
/dev/ttymxc1              0666   root       root
/dev/ttymxc2              0666   root       root

  But it doesn't work. So we also did the third step,

3. we add something in init.rc. But we think maybe it is not needed if we have done the second step.

   

    #test for ttymxc1,2.  GP
    chown root system /dev/ttymxc1
    chown root system /dev/ttymxc2
    chmod 0775 /dev/ttymxc1
    chmod 0775 /dev/ttymxc2
    #test end.

  Unfortunately, the UART2 could not be used yet. It seems that APP could not open UART2.

Would you please give some comments and feedback? Thanks!

BR//

Labels (2)
0 Kudos
2 Replies

620 Views
weidong_sun
NXP TechSupport
NXP TechSupport

Hello Denny,

   My advice is below :

(1) Verifying UART2 &  UART3 are OK

On linux command line, use echo or cat command to send some characters to /dev/ttymxc1/2, at the same time, receive these data on PC by UART software like Port Expert.

(2) Testing UART2/3 by simple program

You can also write a simple program with C ( linux system call function) to open /dev/ttymxc1/2, and send / receive data to each other, for example UART2 sends data, and UART3 receive data, then UART3 sends data, UART2 receives data.

If the test is no problem, it means both devices can normally work.

(3) On how to use uart port in android application.

After above test was done, you should write UART interface by linux system call, for example, ttymxc1_open(), ttymxc1_read(), ttymxc1_write(), ttymxc1_close(), but now, your appcation couldn't load these functions, because your APP is written by JAVA. You should transform abvoe functions to NEW APIs that JAVA can use though NDK, about NDK, you can find many links from internet.


Have a great day,
(weidong)

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos

620 Views
dennyzhou
Contributor II

Hi Wigros,

  Thank you for your comments!

  It has been fixed. I disabled the selinux in bootargs. Then it works! I think it is caused by some security reason.

BR//Denny

0 Kudos