-
Notifications
You must be signed in to change notification settings - Fork 44
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
atx
wants to merge
2
commits into
AsteroidOS:master
Choose a base branch
from
atx:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 5 additions & 0 deletions
5
recipes-android/android-tools/android-tools/android-tools-adbd.service
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
38 changes: 38 additions & 0 deletions
38
recipes-asteroid/asteroid-usbsetup/asteroid-usbsetup/asteroid-usbsetup.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | ||
|
||
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 |
10 changes: 10 additions & 0 deletions
10
recipes-asteroid/asteroid-usbsetup/asteroid-usbsetup/usb-setup.service
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
18
recipes-asteroid/asteroid-usbsetup/asteroid-usbsetup_1.0.bb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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/" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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?