Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[RFC] Composite USB device #15

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion classes/asteroid-image.bbclass
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ LICENSE = "GPL-2.0"
IMAGE_FEATURES += "splash package-management"

IMAGE_INSTALL += " \
base-files base-passwd systemd busybox iproute2 connman pam-plugin-loginuid bluez5 pulseaudio-server openssh-sshd openssh-sftp-server openssh-scp statefs dsme mce ngfd timed sensorfw android-init mapplauncherd-booster-qtcomponents usb-moded \
base-files base-passwd systemd busybox iproute2 connman pam-plugin-loginuid bluez5 pulseaudio-server openssh-sshd openssh-sftp-server openssh-scp statefs dsme mce ngfd timed sensorfw android-init mapplauncherd-booster-qtcomponents asteroid-usbsetup mtp-server \
supported-languages asteroid-launcher asteroid-calculator asteroid-calendar asteroid-stopwatch asteroid-settings asteroid-timer asteroid-alarmclock asteroid-weather asteroid-music asteroid-btsyncd"

EXTRA_USERS_PARAMS = "groupadd system; \
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
[Unit]
Description=Android Debug Bridge
Requires=usb-setup.service
After=usb-setup.service

[Service]
Type=simple
Restart=on-failure
ExecStart=/usr/bin/adbd
StandardOutput=null

[Install]
WantedBy=multi-user.target
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#! /bin/sh

set -e

ANDROID_USB="/sys/class/android_usb/android0"

log_info () {
echo "[INFO] $@"
}

start_usb () {
echo "0" > $ANDROID_USB/enable

log_info "Starting adb mode"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why indicating "adb mode" when you actually activate ffs ecm and mtp?


manufacturer="$(cat /system/build.prop | grep -o 'ro.product.manufacturer=.*' | cut -d'=' -f 2)"
model="$(cat /system/build.prop | grep -o 'ro.product.model=.*' | cut -d'=' -f 2)"
serial="$(cat /proc/cmdline | sed 's/.*androidboot.serialno=//' | sed 's/ .*//')"

echo $manufacturer > $ANDROID_USB/iManufacturer
echo $model > $ANDROID_USB/iProduct
echo $serial > $ANDROID_USB/iSerial

echo 18d1 > $ANDROID_USB/idVendor
echo 0a03 > $ANDROID_USB/idProduct

mkdir -p /dev/usb-ffs/adb
mount -t functionfs adb /dev/usb-ffs/adb

echo adb > $ANDROID_USB/f_ffs/aliases
echo ffs,ecm,mtp > $ANDROID_USB/functions

echo "1" > $ANDROID_USB/enable

log_info "Initialized android_usb with $manufacturer $model $serial"
}

start_usb
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[Unit]
Description=Asteroid USB setup service

[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=/usr/sbin/asteroid-usbsetup.sh

[Install]
WantedBy=multi-user.target
18 changes: 18 additions & 0 deletions recipes-asteroid/asteroid-usbsetup/asteroid-usbsetup_1.0.bb
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
DESCRIPTION = "This installs the usb-setup service Asteroid uses to initialize USB connection"
PR = "r0"
SRC_URI = "file://asteroid-usbsetup.sh \
file://usb-setup.service"

LICENSE = "Apache-2.0"
LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/Apache-2.0;md5=89aea4e17d99a7cacdbeed46a0096b10"

do_install() {
install -d ${D}/usr/sbin/
install -m 0755 ${WORKDIR}/asteroid-usbsetup.sh ${D}/usr/sbin/asteroid-usbsetup.sh

install -d ${D}/lib/systemd/system/multi-user.target.wants/
install -m 0644 ${WORKDIR}/usb-setup.service ${D}/lib/systemd/system/usb-setup.service
ln -s ../usb-setup.service ${D}/lib/systemd/system/multi-user.target.wants/usb-setup.service
}

FILES_${PN} += " /lib/systemd/system/"
1 change: 1 addition & 0 deletions recipes-core/systemd/systemd/65-android.rules
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ ACTION=="add", KERNEL=="event[0-9]*", GROUP="system", MODE="0660"
# misc devices
ACTION=="add", KERNEL=="alarm", GROUP="system", MODE="0664"
ACTION=="add", KERNEL=="uhid", GROUP="system", MODE="0660"
ACTION=="add", KERNEL=="mtp_usb", GROUP="mtp", MODE="0664"

# memory
ACTION=="add", KERNEL=="ashmem", GROUP="system", MODE="0666"
Expand Down
15 changes: 15 additions & 0 deletions recipes-core/systemd/systemd/70-asteroid-ecm.network
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
[Match]
Name=ecm*

[Network]
Description=USB CDC ECM interface
DHCPServer=yes
Address=192.168.2.1/30
Gateway=192.168.2.2

[DHCPServer]
PoolSize=2
EmitDNS=no
EmitNTP=no
EmitRouter=no
EmitTimezone=no
5 changes: 4 additions & 1 deletion recipes-core/systemd/systemd_%.bbappend
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:"
SRC_URI_append = " file://50-video.rules \
file://65-android.rules \
file://70-asteroid-ecm.network \
file://dbus.service \
file://dbus.socket \
file://dbus.conf "
Expand All @@ -9,6 +10,8 @@ do_install_append() {
# Setup udev rules for the rights of Android and graphic cards specific devices
install -m 0644 ${WORKDIR}/50-video.rules ${D}${sysconfdir}/udev/rules.d/50-video.rules
install -m 0644 ${WORKDIR}/65-android.rules ${D}${sysconfdir}/udev/rules.d/65-android.rules
# Setup systemd-networkd rules
install -m 0644 ${WORKDIR}/70-asteroid-ecm.network ${D}/lib/systemd/network/70-asteroid-ecm.network

# Enables auto-login for ceres
install -d ${D}/var/lib/systemd/linger
Expand All @@ -30,7 +33,7 @@ do_install_append() {

FILES_${PN} += "/home/ceres/.config/systemd/user/default.target.wants/"

PACKAGECONFIG_append += "pam"
PACKAGECONFIG_append += "pam networkd"

RRECOMMENDS_${PN}_remove = "udev-hwdb"

Expand Down
9 changes: 0 additions & 9 deletions recipes-nemomobile/usb-moded/usb-moded_git.bb
Original file line number Diff line number Diff line change
Expand Up @@ -49,15 +49,6 @@ do_install_append() {
touch ${D}/etc/modprobe.d/g_ether.conf
touch ${D}/etc/udhcpd.conf

install -d ${D}/lib/systemd/system/multi-user.target.wants/
install -m 644 -D ../usb-moded.service ${D}/lib/systemd/system/usb-moded.service
ln -s ../usb-moded.service ${D}/lib/systemd/system/multi-user.target.wants/usb-moded.service
install -m 644 -D ../udhcp-daemon.service ${D}/lib/systemd/system/udhcp-daemon.service
install -m 644 -D ../buteo-session.service ${D}/lib/systemd/system/buteo-session.service

install -d ${D}/usr/share/dbus-1/services/
install -m 644 -D ../com.meego.usb_moded.service ${D}/usr/share/dbus-1/services/com.meego.usb_moded.service

install -m 644 -D systemd/usb-moded.conf ${D}/etc/tmpfiles.d/usb-moded.conf

install -m 755 -D systemd/adbd-functionfs.sh ${D}/usr/sbin/adbd-functionfs.sh
Expand Down
Loading