Skip to content

Commit 2f4b943

Browse files
SuperKaliigorpecovnik
authored andcommitted
arduino-uno-q: add USB gadget network fallback for Ubuntu
Use adbd on Debian where available, fall back to USB gadget network with unudhcpd on Ubuntu where adbd is not packaged.
1 parent 08d63b9 commit 2f4b943

File tree

1 file changed

+24
-5
lines changed

1 file changed

+24
-5
lines changed

config/boards/arduino-uno-q.csc

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,18 +17,37 @@ function post_family_tweaks__arduino-uno-q() {
1717
do_with_retries 3 chroot_sdcard_apt_get_update
1818
do_with_retries 3 chroot_sdcard_apt_get_install \
1919
rmtfs qrtr-tools protection-domain-mapper tqftpserv \
20-
bluetooth bluez gdisk adbd qbootctl
20+
bluetooth bluez gdisk qbootctl
2121

22-
# ADB branding
23-
chroot_sdcard sed -i 's/"Debian"/"Armbian"/' /usr/lib/android-sdk/platform-tools/adbd-usb-gadget
24-
chroot_sdcard sed -i 's/"ADB device"/"Arduino UNO Q"/' /usr/lib/android-sdk/platform-tools/adbd-usb-gadget
22+
# USB access: adbd on Debian, USB gadget network on Ubuntu (adbd not available)
23+
if [[ "${DISTRIBUTION}" == "Debian" ]]; then
24+
do_with_retries 3 chroot_sdcard_apt_get_install adbd
25+
chroot_sdcard sed -i 's/"Debian"/"Armbian"/' /usr/lib/android-sdk/platform-tools/adbd-usb-gadget
26+
chroot_sdcard sed -i 's/"ADB device"/"Arduino UNO Q"/' /usr/lib/android-sdk/platform-tools/adbd-usb-gadget
27+
chroot_sdcard systemctl enable adbd.service
28+
else
29+
# unudhcpd is in the Armbian repo
30+
mv "${SDCARD}"/etc/apt/sources.list.d/armbian.sources.disabled "${SDCARD}"/etc/apt/sources.list.d/armbian.sources
31+
do_with_retries 3 chroot_sdcard_apt_get_update
32+
do_with_retries 3 chroot_sdcard_apt_get_install unudhcpd
33+
mv "${SDCARD}"/etc/apt/sources.list.d/armbian.sources "${SDCARD}"/etc/apt/sources.list.d/armbian.sources.disabled
34+
do_with_retries 3 chroot_sdcard_apt_get_update
35+
chroot_sdcard systemctl enable usbgadget-rndis.service
36+
fi
2537

2638
# Enable services
27-
chroot_sdcard systemctl enable adbd.service
2839
chroot_sdcard systemctl enable qbootctl.service
2940
chroot_sdcard systemctl enable armbian-resize-filesystem-qcom.service
3041
}
3142

43+
function post_family_tweaks_bsp__arduino-uno-q_usb_gadget() {
44+
[[ "${DISTRIBUTION}" != "Ubuntu" ]] && return 0
45+
display_alert "Installing USB gadget network scripts" "${BOARD}" "info"
46+
install -Dm755 "$SRC/packages/bsp/usb-gadget-network/setup-usbgadget-network.sh" "$destination/usr/local/bin/setup-usbgadget-network.sh"
47+
install -Dm755 "$SRC/packages/bsp/usb-gadget-network/remove-usbgadget-network.sh" "$destination/usr/local/bin/remove-usbgadget-network.sh"
48+
install -Dm644 "$SRC/packages/bsp/usb-gadget-network/usbgadget-rndis.service" "$destination/usr/lib/systemd/system/usbgadget-rndis.service"
49+
}
50+
3251
function post_family_tweaks_bsp__arduino-uno-q_resize_rootfs() {
3352
display_alert "Installing rootfs resize script" "${BOARD}" "info"
3453
install -Dm755 "$SRC/packages/bsp/arduino/armbian-resize-filesystem-qcom" "$destination/usr/lib/armbian/armbian-resize-filesystem-qcom"

0 commit comments

Comments
 (0)