summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorzhxihu <zhxihu@marvell.com>2016-01-19 19:01:31 -0800
committerzhxihu <zhxihu@marvell.com>2016-01-21 18:29:18 -0800
commitc571742d868a7809767c4974da85235371621475 (patch)
tree4f8424aa3b3d6eb9f48a8a2f950d346d31570ecc
parent54a63711e961fdca27371bce56985719d607a8ca (diff)
downloadmarvell-brillo-m9-release.tar.gz
abox_edge: Add ConfigFS support for ADB gadget function.brillo-m9-release
Add support for ConfigFS ADB function: 1. Add specific usb init script to configure ADB function. 2. Add sepolicy for ConfigFS. This also fix the USB issue in Moblab VM. BUG=26147310 Change-Id: I30dcbadb318ec839ea5f22a9ff36d74f8eb381c3
-rw-r--r--[-rwxr-xr-x]soc/iap140/hal_modules.mk0
-rw-r--r--[-rwxr-xr-x]soc/iap140/init.iap140.rc2
-rw-r--r--soc/iap140/init.iap140.usb.rc55
-rw-r--r--soc/iap140/sepolicy/file.te2
-rw-r--r--soc/iap140/sepolicy/genfs_contexts1
-rw-r--r--soc/iap140/sepolicy/init.te3
-rw-r--r--soc/iap140/soc.mk1
7 files changed, 64 insertions, 0 deletions
diff --git a/soc/iap140/hal_modules.mk b/soc/iap140/hal_modules.mk
index 91a10e4..91a10e4 100755..100644
--- a/soc/iap140/hal_modules.mk
+++ b/soc/iap140/hal_modules.mk
diff --git a/soc/iap140/init.iap140.rc b/soc/iap140/init.iap140.rc
index aef79a2..4eee595 100755..100644
--- a/soc/iap140/init.iap140.rc
+++ b/soc/iap140/init.iap140.rc
@@ -14,6 +14,8 @@
# limitations under the License.
#
+import init.iap140.usb.rc
+
on init
symlink /dev/block/platform/soc.2/d4200000.axi/d4281000.sdh/by-name /dev/block/by-name
setprop ro.board.platform mrvl
diff --git a/soc/iap140/init.iap140.usb.rc b/soc/iap140/init.iap140.usb.rc
new file mode 100644
index 0000000..63a7951
--- /dev/null
+++ b/soc/iap140/init.iap140.usb.rc
@@ -0,0 +1,55 @@
+#
+# Copyright 2016 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+on boot
+ mkdir /dev/usb-ffs 0770 shell shell
+ mkdir /dev/usb-ffs/adb 0770 shell shell
+ mount configfs none /config
+ mkdir /config/usb_gadget/g1 0770 shell shell
+ write /config/usb_gadget/g1/idVendor 0x18d1
+ write /config/usb_gadget/g1/bcdDevice 0x0223
+ write /config/usb_gadget/g1/bcdUSB 0x0200
+ mkdir /config/usb_gadget/g1/strings/0x409 0770
+ write /config/usb_gadget/g1/strings/0x409/serialnumber ${ro.serialno}
+ write /config/usb_gadget/g1/strings/0x409/manufacturer ${ro.product.manufacturer}
+ write /config/usb_gadget/g1/strings/0x409/product ${ro.product.model}
+ mkdir /config/usb_gadget/g1/functions/ffs.adb
+ mkdir /config/usb_gadget/g1/configs/b.1 0770 shell shell
+ mkdir /config/usb_gadget/g1/configs/b.1/strings/0x409 0770 shell shell
+ write /config/usb_gadget/g1/configs/b.1/MaxPower 500
+ write /config/usb_gadget/g1/configs/b.1/strings/0x409/configuration "adb"
+ symlink /config/usb_gadget/g1/functions/ffs.adb /config/usb_gadget/g1/configs/b.1/f1
+ mount functionfs adb /dev/usb-ffs/adb uid=2000,gid=2000
+ setprop sys.usb.configfs 1
+ setprop sys.usb.controller "d4208100.udc"
+
+on property:sys.usb.config=none && property:sys.usb.configfs=1
+ write /config/usb_gadget/g1/UDC "none"
+ stop adbd
+ write /config/usb_gadget/g1/bDeviceClass 0
+ write /config/usb_gadget/g1/bDeviceSubClass 0
+ write /config/usb_gadget/g1/bDeviceProtocol 0
+ setprop sys.usb.state ${sys.usb.config}
+ setprop sys.usb.ffs.ready 0
+
+on property:sys.usb.config=adb && property:sys.usb.configfs=1
+ start adbd
+
+on property:sys.usb.ffs.ready=1 && property:sys.usb.config=adb && property:sys.usb.configfs=1
+ write /config/usb_gadget/g1/idProduct 0x4ee7
+ write /config/usb_gadget/g1/UDC ${sys.usb.controller}
+ setprop sys.usb.state ${sys.usb.config}
+
diff --git a/soc/iap140/sepolicy/file.te b/soc/iap140/sepolicy/file.te
new file mode 100644
index 0000000..485b666
--- /dev/null
+++ b/soc/iap140/sepolicy/file.te
@@ -0,0 +1,2 @@
+# Configfs /config
+type configfs, fs_type;
diff --git a/soc/iap140/sepolicy/genfs_contexts b/soc/iap140/sepolicy/genfs_contexts
new file mode 100644
index 0000000..50c7cd7
--- /dev/null
+++ b/soc/iap140/sepolicy/genfs_contexts
@@ -0,0 +1 @@
+genfscon configfs / u:object_r:configfs:s0
diff --git a/soc/iap140/sepolicy/init.te b/soc/iap140/sepolicy/init.te
new file mode 100644
index 0000000..03a4721
--- /dev/null
+++ b/soc/iap140/sepolicy/init.te
@@ -0,0 +1,3 @@
+# Allow init to create directories and symlinks in /config
+allow init configfs:dir create_dir_perms;
+allow init configfs:{ file lnk_file } create_file_perms;
diff --git a/soc/iap140/soc.mk b/soc/iap140/soc.mk
index 9a13881..63a5408 100644
--- a/soc/iap140/soc.mk
+++ b/soc/iap140/soc.mk
@@ -34,6 +34,7 @@ BOARD_KERNEL_CMDLINE := androidboot.console=ttyS1 console=ttyS1,115200 panic_deb
PRODUCT_COPY_FILES += \
$(LOCAL_PATH)/init.iap140.rc:root/init.iap140.rc \
system/core/rootdir/init.usb.rc:root/init.usb.rc \
+ $(LOCAL_PATH)/init.iap140.usb.rc:root/init.iap140.usb.rc \
system/core/rootdir/ueventd.rc:root/ueventd.rc \
$(LOCAL_PATH)/ueventd.iap140.rc:root/ueventd.iap140.rc