文件相关定义配置
kernel/arch/arm/boot/dts/rk3288.dtsi
aliases {
serial0 = &uart0;
serial1 = &uart1;
serial2 = &uart2;
serial3 = &uart3;
serial4 = &uart4;
};
uart3 {
uart3_xfer: uart3-xfer {
rockchip,pins = <7 7 RK_FUNC_1 &pcfg_pull_up>,
<7 8 RK_FUNC_1 &pcfg_pull_none>;
};
uart3_cts: uart3-cts {
rockchip,pins = <7 9 RK_FUNC_1 &pcfg_pull_up>;
};
uart3_rts: uart3-rts {
rockchip,pins = <7 10 RK_FUNC_1 &pcfg_pull_none>;
};
uart3: serial@ff1b0000 {
compatible = "rockchip,rk3288-uart", "snps,dw-apb-uart";
reg = <0x0 0xff1b0000 0x0 0x100>;
interrupts = ;
reg-shift = <2>;
reg-io-width = <4>;
clocks = <&cru SCLK_UART3>, <&cru PCLK_UART3>;
clock-names = "baudclk", "apb_pclk";
pinctrl-names = "default";
pinctrl-0 = <&uart3_xfer>;
status = "disabled";
};
kernel/arch/arm/boot/dts/rk3288-evb.dtsi
&uart3 {
status = "okay";
pinctrl-names = "default";
pinctrl-0 = <&uart3_xfer>;
dma-names = "tx", "rx"; //使能dma接收
};
test:
adb install E:\tmp\apk\ComAssistant.apk
error:
打开串口后,没有信息
调试信息:
01-18 08:57:49.861 1613 1613 D serial_port: Configuring serial port
01-18 08:57:49.860 1613 1613 I jw.ComAssistant: type=1400 audit(0.0:28): avc: denied { read } for name="ttyS3" dev="tmpfs" ino=11161 scontext=u:r:untrusted_app:s0:c512,
c768 tcontext=u:object_r:serial_device:s0 tclass=chr_file permissive=1
01-18 08:57:49.860 1613 1613 I jw.ComAssistant: type=1400 audit(0.0:29): avc: denied { write } for name="ttyS3" dev="tmpfs" ino=11161 scontext=u:r:untrusted_app:s0:c512
,c768 tcontext=u:object_r:serial_device:s0 tclass=chr_file permissive=1
01-18 08:57:49.860 1613 1613 I jw.ComAssistant: type=1400 audit(0.0:30): avc: denied { open } for path="/dev/ttyS3" dev="tmpfs" ino=11161 scontext=u:r:untrusted_app:s0:
c512,c768 tcontext=u:object_r:serial_device:s0 tclass=chr_file permissive=1
01-18 08:57:49.860 1613 1613 I jw.ComAssistant: type=1400 audit(0.0:31): avc: denied { ioctl } for path="/dev/ttyS3" dev="tmpfs" ino=11161 ioctlcmd=5401 scontext=u:r:un
trusted_app:s0:c512,c768 tcontext=u:object_r:serial_device:s0 tclass=chr_file permissive=1
01-18 08:57:52.976 223 283 D alsa_route: route_set_controls() set route 24
01-18 08:57:52.977 223 283 D AudioHardwareTiny: close device
01-18 08:58:42.730 440 611 E Lights Hal: write_int failed to open /
修改权限:
diff --git a/device/rockchip/common/sepolicy/untrusted_app.te b/device/rockchip/common/sepolicy/untrusted_app.te
index 00fb48e..aa42d6e 100644
--- a/device/rockchip/common/sepolicy/untrusted_app.te
+++ b/device/rockchip/common/sepolicy/untrusted_app.te
@@ -17,3 +17,4 @@ allow untrusted_app { domain -init -kernel}:file { read getattr open };
get_prop(untrusted_app,ctsgts_prop)
allow untrusted_app system_data_file:file r_file_perms;
allow untrusted_app sysfs_lut:file { getattr setattr open write };
+allow untrusted_app serial_device:chr_file rw_file_perms;
diff --git a/device/rockchip/common/ueventd.rockchip.rc b/device/rockchip/common/ueventd.rockchip.rc
index 9cd0b50..acb7151 100755
--- a/device/rockchip/common/ueventd.rockchip.rc
+++ b/device/rockchip/common/ueventd.rockchip.rc
@@ -49,7 +49,7 @@
/dev/compassirq 0660 system system
# for GPS
-#/dev/ttyS3 0600 gps gps
+/dev/ttyS3 0666 gps gps
/dev/gps 0660 gps gps
error:
仍然没有信息
报错信息正常现象
01-18 09:48:10.000 1563 1563 I jw.ComAssistant: type=1400 audit(0.0:30): avc: denied { write } for name="ttyS3" dev="tmpfs" ino=3422 scontext=u:r:untrusted_app:s0:c512,
c768 tcontext=u:object_r:serial_device:s0 tclass=chr_file permissive=1
01-18 09:48:10.006 1563 1563 W linker : /data/app/com.bjw.ComAssistant-1/lib/arm/libserial_port.so has text relocations. This is wasting memory and prevents security h
ardening. Please fix.
01-18 09:48:10.006 1563 1563 D serial_port: Opening serial port /dev/ttyS3 with flags 0x2
01-18 09:48:10.006 1563 1563 D serial_port: open() fd = 57
01-18 09:48:10.006 1563 1563 D serial_port: Configuring serial port
01-18 09:48:14.604 223 264 D alsa_route: route_set_controls() set route 24
01-18 09:48:14.605 223 264 D AudioHardwareTiny: close device
01-18 09:48:18.151 1394 1420 E Ads : Error waiting for future.
01-18 09:48:18.151 1394 1420 E Ads : java.util.concurrent.ExecutionException: java.util.concurrent.TimeoutException
01-18 09:48:18.151 1394 1420 E Ads : at com.google.android.gms.internal.ads.zzbcl.get(Unknown Source)
01-18 09:48:18.151 1394 1420 E Ads : at com.google.android.gms.internal.ads.zzbbq.zza(Unknown Source)
01-18 09:48:18.151 1394 1420 E Ads : at com.google.android.gms.internal.ads.zzatq.zza(Unknown Source)
01-18 09:48:18.151 1394 1420 E Ads : at com.google.android.gms.internal.ads.zzatq.zzb(Unknown Source)
01-18 09:48:18.151 1394 1420 E Ads : at com.google.android.gms.internal.ads.zzats.run(Unknown Source)
01-18 09:48:18.151 1394 1420 E Ads : at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:428)
01-18 09:48:18.151 1394 1420 E Ads : at java.util.concurrent.FutureTask.run(FutureTask.java:237)
01-18 09:48:18.151 1394 1420 E Ads : at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
01-18 09:48:18.151 1394 1420 E Ads : at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
01-18 09:48:18.151 1394 1420 E Ads : at java.lang.Thread.run(Thread.java:761)
01-18 09:48:18.151 1394 1420 E Ads : Caused by: java.util.concurrent.TimeoutException
01-18 09:48:18.151 1394 1420 E Ads : at com.google.android.gms.internal.ads.zzbbu.run(Unknown Source)
01-18 09:48:18.151 1394 1420 E Ads : at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:428)
01-18 09:48:18.151 1394 1420 E Ads : at java.util.concurrent.FutureTask.run(FutureTask.java:237)
01-18 09:48:18.151 1394 1420 E Ads : at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:272)
01-18 09:48:18.151 1394 1420 E Ads : ... 3 more
01-18 09:48:18.152 1394 1420 W Ads : There was a problem getting an ad response. ErrorCode: 0
01-18 09:48:18.153 1394 1394 W Ads : Failed to load ad: 0
01-18 09:48:18.613 1394 1394 W cr_BindingManager: Cannot call determinedVisibility() - never saw a connection for the pid: 1394
01-18 09:48:18.621 1394 1394 W cr_ScreenOrientation: Removing an inexistent observer!
01-18 09:48:18.622 438 583 D ConnectivityService: releasing NetworkRequest [ LISTEN id=5, [ Capabilities: INTERNET&NOT_RESTRICTED&TRUSTED&FOREGROUND] ]
01-18 09:48:18.623 438 583 D ConnectivityService: sending notification RELEASED for NetworkRequest [ LISTEN id=5, [ Capabilities: INTERNET&NOT_RESTRICTED&TRUSTED&FORE
GROUND] ]
01-18 09:48:22.359 223 264 D AudioHardwareTiny: start_output_stream
01-18 09:48:22.360 223 264 D alsa_route: route_info->sound_card 1, route_info->devices 0
01-18 09:48:25.602 223 264 D alsa_route: route_set_controls() set route 24
01-18 09:48:25.603 223 264 D AudioHardwareTiny: close device
^C
排错方法:
1.检查rx tx有没有短接;
2.引脚有没有被占用;
解决占用,串口可用;
二、提供ttyS3给serialmanager使用的方法
diff --git a/device/rockchip/common/init.connectivity.rc b/device/rockchip/common/init.connectivity.rc
index 33aaf0c..93d12b7 100755
--- a/device/rockchip/common/init.connectivity.rc
+++ b/device/rockchip/common/init.connectivity.rc
@@ -21,12 +21,14 @@ on boot
chmod 0660 /dev/ttyS0
chmod 0660 /dev/ttyS1
+ chmod 0660 /dev/ttyS3
chmod 0660 /dev/vflash
chmod 0664 /dev/vendor_storage
chown bluetooth net_bt_stack /dev/vflash
chown bluetooth net_bt_stack /dev/vendor_storage
chown bluetooth net_bt_stack /dev/ttyS1
chown bluetooth net_bt_stack /dev/ttyS0
+ chown system system /dev/ttyS3
chown bluetooth net_bt_stack /sys/class/rfkill/rfkill0/type
chown bluetooth net_bt_stack /sys/class/rfkill/rfkill0/state
chmod 0664 /sys/class/rfkill/rfkill0/state
diff --git a/device/rockchip/common/sepolicy/system_app.te b/device/rockchip/common/sepolicy/system_app.te
index 2e84fc2..04513f2 100755
--- a/device/rockchip/common/sepolicy/system_app.te
+++ b/device/rockchip/common/sepolicy/system_app.te
@@ -16,6 +16,7 @@ allow system_app gpu_device:dir { search };
allow system_app radio_data_file:dir { getattr };
allow system_app vfat:dir create_dir_perms;
allow system_app vfat:file create_file_perms;
+allow system_app serial_device:chr_file rw_file_perms;
#allow system_app system_data_file:dir { rw_dir_perms };
allow system_app cache_recovery_file:dir { search write add_name remove_name };
allow system_app cache_recovery_file:file { create write open read getattr unlink };
diff --git a/device/rockchip/common/ueventd.rockchip.rc b/device/rockchip/common/ueventd.rockchip.rc
index 9cd0b50..a8b2b78 100755
--- a/device/rockchip/common/ueventd.rockchip.rc
+++ b/device/rockchip/common/ueventd.rockchip.rc
@@ -49,7 +49,7 @@
/dev/compassirq 0660 system system
# for GPS
-#/dev/ttyS3 0600 gps gps
+/dev/ttyS3 0660 system system
/dev/gps 0660 gps gps
diff --git a/device/rockchip/rk3288/overlay/frameworks/base/core/res/res/values/config.xml b/device/rockchip/rk3288/overlay/frameworks/base/core/res/res/values/config.xml
index c3c0cc6..a363d7e 100755
--- a/device/rockchip/rk3288/overlay/frameworks/base/core/res/res/values/config.xml
+++ b/device/rockchip/rk3288/overlay/frameworks/base/core/res/res/values/config.xml
@@ -45,5 +45,12 @@
- "pppoe,15,15,5,-1,true"
+
+
+
+ - "/dev/ttyS3"
+
diff --git a/frameworks/base/core/res/res/values/config.xml b/frameworks/base/core/res/res/values/config.xml
index e4839d7..40f7c77 100644
--- a/frameworks/base/core/res/res/values/config.xml
+++ b/frameworks/base/core/res/res/values/config.xml
@@ -871,6 +871,7 @@
for example, /dev/ttyUSB0
-->
+ - "/dev/ttyS3"
diff --git a/frameworks/base/tests/SerialChat/Android.mk b/frameworks/base/tests/SerialChat/Android.mk
index a534e1a..7dfb321 100644
--- a/frameworks/base/tests/SerialChat/Android.mk
+++ b/frameworks/base/tests/SerialChat/Android.mk
@@ -23,4 +23,6 @@ LOCAL_SRC_FILES := $(call all-subdir-java-files)
LOCAL_PACKAGE_NAME := SerialChat
+LOCAL_CERTIFICATE := platform
+
include $(BUILD_PACKAGE)
diff --git a/frameworks/base/tests/SerialChat/AndroidManifest.xml b/frameworks/base/tests/SerialChat/AndroidManifest.xml
index 0efdb58..8d8f660 100644
--- a/frameworks/base/tests/SerialChat/AndroidManifest.xml
+++ b/frameworks/base/tests/SerialChat/AndroidManifest.xml
@@ -15,7 +15,8 @@
-->
+ package="com.android.serialchat"
+ android:sharedUserId="android.uid.system">