I want to use uart in Android

Hello sir,

I’m using two boards (VIM3 an VIM1) and trying to communicate to our board using uart and android_serialport_api.
VIM3 was good work, but VIM1 is not work.
I can’t open the uart port(ttyS4) in VIM1.
First, I received error message as follow,
“java.lang.RuntimeException: Unable to resume activity {com.masts.xxxx/com.masts.xxxx.MainActivity}: java.lang.SecurityException”

then,I try the code of “Check access permission” to disable.
I got the error messages as follow,
“E/serial_port: Cannot open port”
“E/SerialPort: native open returns null”

How can I use uart in VIM3?

Can you help me?

Ask the khadas members for help, maybe @frank or @Terry, could help you, Also try to provide the full proper log as it is a bit easier to help debugging

Did you means VIM3 or VIM1?


I can’t open the uart port in VIM1.
I received error message in " mFd = open(device.getAbsolutePath(), baudrate, flags); ".

What’s the version of your system? Did you try to change the /dev/ttyS4 permission?

#adb shell
# su
# chmod 777  /dev/ttyS4
1 Like

Thanks a lot for your advice.

I got the uart port in VIM1.

I got another problem.
After rebooting, the /dev/ttyS4 permission is reset.
How can I change the permission permanently?

You need to modify the file /vendor/ueventd.rc, and add the line /dev/ttyS4 0666 system system into it.

# adb root
# adb remount
# adb shell
# vi /vendor/ueventd.rc
# reboot
1 Like