Skip to content

Commit 213e201

Browse files
committed
Implemented configurable ncm gadget from /etc/default/usbgx
1 parent f4c639f commit 213e201

File tree

7 files changed

+36
-2
lines changed

7 files changed

+36
-2
lines changed

recipes-devtools/android-tools/android-tools/arduino-android-gadget-setup

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ start()
55
if [[ $(cat /sys/class/typec/port0/data_role) == "[device]" ]]; then
66
echo "Creating Arduino usb gadgets..."
77

8+
. /etc/default/usbgx
9+
810
PID=0061
911
VID=2341
1012
BOARDNAME="Portenta X8"
@@ -35,7 +37,11 @@ start()
3537

3638
# populate config, optional
3739
mkdir configs/c.1/strings/0x409
38-
echo \"adb+acm\" > configs/c.1/strings/0x409/configuration
40+
CFG_STRING="adb+acm"
41+
if [[ $ENABLED_SCHEMAS="*ncm*" ]]; then
42+
CFG_STRING="adb+acm+ncm"
43+
fi
44+
echo $CFG_STRING > configs/c.1/strings/0x409/configuration
3945
echo 900 > configs/c.1/MaxPower
4046

4147
# create a generic ffs for adb
@@ -44,6 +50,14 @@ start()
4450
# create the acm (serial) function
4551
mkdir functions/acm.GS0
4652

53+
if [[ $ENABLED_SCHEMAS="*ncm*" ]]; then
54+
# create the ncm function
55+
mkdir functions/ncm.usb0
56+
57+
# assign ncm function to configuration
58+
ln -s functions/ncm.usb0/ configs/c.1
59+
fi
60+
4761
# assign acm function to configuration
4862
ln -s functions/acm.GS0 configs/c.1
4963

recipes-samples/images/lmp-devel-arduino-image.bb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ ARDUINO = " \
5555
automount-boot \
5656
m4-proxy \
5757
udev-rules-portenta \
58+
libusbgx-config \
5859
"
5960

6061
VIDEOTOOLS = " \

recipes-samples/images/lmp-partner-arduino-image.bb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ ARDUINO = " \
5858
arduino-ootb \
5959
m4-proxy \
6060
udev-rules-portenta \
61+
libusbgx-config \
6162
"
6263

6364
CORE_IMAGE_BASE_INSTALL += " \

recipes-support/arduino-ootb/arduino-ootb.bb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda
55
SRC_URI = " \
66
file://connection-status-led.timer \
77
file://connection-status-led.service \
8+
file://ncm-network.service \
89
file://secure-device.service \
910
file://create-docker-envfile.service \
1011
file://offline-update.service \
@@ -15,12 +16,13 @@ SRC_URI = " \
1516

1617
inherit systemd
1718

18-
SYSTEMD_SERVICE:${PN} = "connection-status-led.timer connection-status-led.service secure-device.service create-docker-envfile.service offline-update.service ec200a-eu.service compose-apps-aklite-offline-run.service"
19+
SYSTEMD_SERVICE:${PN} = "connection-status-led.timer connection-status-led.service ncm-network.service secure-device.service create-docker-envfile.service offline-update.service ec200a-eu.service compose-apps-aklite-offline-run.service"
1920

2021
do_install() {
2122
install -d ${D}${systemd_system_unitdir}
2223
install -m 0644 ${WORKDIR}/connection-status-led.timer ${D}${systemd_system_unitdir}/
2324
install -m 0644 ${WORKDIR}/connection-status-led.service ${D}${systemd_system_unitdir}/
25+
install -m 0644 ${WORKDIR}/ncm-network.service ${D}${systemd_system_unitdir}/
2426
install -m 0644 ${WORKDIR}/secure-device.service ${D}${systemd_system_unitdir}/
2527
install -m 0644 ${WORKDIR}/create-docker-envfile.service ${D}${systemd_system_unitdir}/
2628
install -m 0644 ${WORKDIR}/offline-update.service ${D}${systemd_system_unitdir}/
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
[Unit]
2+
Description=Configure link-local connection on usb ncm interface
3+
BindsTo=sys-subsystem-net-devices-usb0.device
4+
After=android-tools-adbd.service sys-subsystem-net-devices-usb0.device
5+
6+
[Service]
7+
Type=simple
8+
RemainAfterExit=yes
9+
ExecStart=/bin/sh -c '/usr/bin/nmcli c delete usbncm; /usr/bin/nmcli c add type ethernet ifname usb0 ipv4.method shared ipv4.addresses 10.11.99.1/29 ipv6.method disabled con-name usbncm && /usr/bin/nmcli c up usbncm'
10+
ExecStop=/bin/sh -c '/usr/bin/nmcli c down usbncm && /usr/bin/nmcli c delete usbncm'
11+
12+
[Install]
13+
WantedBy=usb-gadget.target
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
FILESEXTRAPATHS:prepend := "${THISDIR}/${PN}:"
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
IMPORT_SCHEMAS="acm ffs"
2+
ENABLED_SCHEMAS="$IMPORT_SCHEMAS"

0 commit comments

Comments
 (0)