PX4 -> QGC connection through USB for VOXL2
-
Is there a way to connect VOXL2 PX4 to QGC via USB? On the VOXL Flight this was done through the J1006 connector.
In addition to this, is there a J1003 (Connector on the VOXL Flight) equivalent on the VOXL2. This would allow me to connect a Crossfire Nano RX to it.
Thanks!
-
Not at this time.... but it's something I'm wanting to try out!!
I'm not clear if it's possible, but what I'm thinking of trying is UDP tunneling over ADB.
ADB supports TCP port forwarding, but our traffic from vehicle to QGC is UDP.... so I believe we can try a tunnel?
Here's the two links I was looking at trying:
https://developer.android.com/studio/command-line/adb#forwardports
http://www1.cs.columbia.edu/~lennox/udptunnel/Throwing it out here in case someone already knows if this is possible or not! If it is, I think it's an easy way to get the connection going....
-
@rohitpillai Not exactly what you're looking for but you could also use one of the supported ethernet dongles attached via. USB to JST to a VOXL2 add-on board and route PX4 traffic through there to your ground station. As seen here: https://docs.modalai.com/voxl2-hardware-setup/#ethernet-connectivity
-
Thank you for your replies! I will check these links out.
-
@modaltb Hii, is there any update on this?
-
@Sarika-Sharma It's not something we currently support
-
We discussed this internally and we will make an effort to formalize enabling the instructions (in a script) in the near future, but there is a relatively short way of enabling TCP/IP communication between VOXL2 and a QGC host. Please try these instructions and let us know if that works for you or what issue you run in to.
Basically, there is a command to enable the usb gadget in the kernel and this creates the network interface which you then have to configure on both sides. You can change the IP range if necessary.
Alex
# VOXL2 Setup # Begin by configuring the usb gadget sed -i '/ln -s functions\/ffs.adb configs\/c.1\/f2/a \ ln -s functions\/ncm.0 configs\/c.1\/f3 2>\/dev\/null | true' /sbin/usb/compositions/901D # Next setup a udev rule to give our NCM device a static IP (192.168.7.2) echo 'ACTION=="add", SUBSYSTEM=="net", KERNEL=="usb0", RUN+="/bin/sh -c '"'"'sleep 2; /sbin/ifconfig usb0 192.168.7.2 netmask 255.255.255.0 up'"'"'"' > /etc/udev/rules.d/80-usb-ncm.rules # Reboot VOXL2 # Check usb0 network device voxl2:/$ ifconfig usb0 usb0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500 inet 192.168.7.2 netmask 255.255.255.0 broadcast 192.168.7.255 inet6 fe80::935f:1a09:ab1d:d2fb prefixlen 64 scopeid 0x20<link> ether 56:77:2d:6c:84:9b txqueuelen 1000 (Ethernet) RX packets 0 bytes 0 (0.0 B) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 0 bytes 0 (0.0 B) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 # Host Side Configuration - note that a network manager may rename the device from usb0 to something else.. ifconfig usb0 usb0: flags=4098<BROADCAST,MULTICAST> mtu 1500 ether fa:74:5a:f3:2b:88 txqueuelen 1000 (Ethernet) RX packets 0 bytes 0 (0.0 B) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 0 bytes 0 (0.0 B) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 #bring up the interface and set it to static ip sudo ip addr add 192.168.7.1/24 dev usb0 sudo ip link set usb0 up # Can also use Network manager to configure the network interface for a static configuration - address 192.168.7.1 - netmask 255.255.255.0 - gateway 192.168.7.1 # ping VOXL2 from linux host - ping 192.168.7.2 #set up QGC - use ip address:port : 192.168.7.2:14550 You can also use other network tools like ssh, etc, to communicate to the host, but this setup does not enable you to communicate from VOXL2 to outside world (using NAT to enable internet access via the host) -
Thankyou so much @Alex-Kushleyev
This setup solves my use case where Wi-Fi is not available. Thanks for the support — looking forward to the scripted version in the future.Best regards,
Sarika -
What is the recommended workflow to switch between usb0 and wlan0 ????
as when i tried to use voxl-wifi in station mode ,it configured succesfully.
But current IP is still:
voxl2-mini-test-fixture (TF-M0104):~$ voxl-my-ip
usb0: 192.168.7.2
voxl2-mini-test-fixture (TF-M0104):~$ -
If you have multiple active network interfaces, then you need to set up routing rules using standard linux network tools (
ip route ..). You can check the current routes usingip route liston voxl2.voxl-my-ipscript probably just returns the first available ip address. you can useifconfigto check all the interfaces.As an example... assuming your wifi ip range is 192.168.10.x (192.168.10.1 is the wifi router's ip address) and usb0 is 192.168.7.x
# route to the Linux host (192.168.7. subnet) via usb0 sudo ip route add 192.168.7.0/24 via 192.168.7.1 dev usb0 # default route for all other traffic via wlan0 sudo ip route add default via 192.168.10.1 dev wlan0If you want to make these routes persistent you will have to edit
/etc/network/interfaces.. Please check Linux networking documentation.Alex
-
@Alex-Kushleyev Should this work on a Voxl to Windows computer connection? I ran the sed and udev rule commands and how the voxl does indeed come up as an ethernet device upon connecting (UsbNcm Host Device) and I can set up the static IPs appropriately, but I cannot ping one to the other for some reason. I can still use the port as an ADB interface and I thought maybe that was the issue but doing adb kill-server on the windows side still doesn't do the trick
-
@Alex-Kushleyev I saw a post from @tom from a few years ago discussing how there should be the necessary drivers to support an RNDIS gadget so I assume that is my issue. Any insight on how to enable that?
[Apr 1 19:15] configfs-gadget gadget: Wrong NDP SIGN [ +12.232553] usbpd usbpd0: Type-C Source (default) connected [ +0.019411] usbpd usbpd0: USB Type-C disconnect [ +0.004363] android_work: sent uevent USB_STATE=DISCONNECTED [ +0.001100] msm-dwc3 a600000.ssusb: DWC3 in low power mode [ +3.492478] usbpd usbpd0: Type-C Source (medium - 1.5A) connected [ +0.113740] msm-usb-ssphy-qmp 88e8000.ssphy: USB DP QMP PHY: Update TYPEC CTRL(3) [ +0.057403] msm-dwc3 a600000.ssusb: DWC3 exited from low power mode [ +0.068603] usbpd usbpd0: Type-C Source (high - 3.0A) connected [ +0.238255] android_work: sent uevent USB_STATE=CONNECTED [ +0.041534] configfs-gadget gadget: high-speed config #1: c [ +0.000644] android_work: sent uevent USB_STATE=CONFIGURED [ +0.195765] usbpd usbpd0: Type-C Source (medium - 1.5A) connected [ +0.021780] usbpd usbpd0: Type-C Source (high - 3.0A) connected [ +0.179818] configfs-gadget gadget: Wrong NDP SIGN [ +0.000172] configfs-gadget gadget: Wrong NDP SIGN [ +0.069075] configfs-gadget gadget: Wrong NDP SIGN [ +0.002827] configfs-gadget gadget: Wrong NDP SIGN [ +0.176097] configfs-gadget gadget: Wrong NDP SIGN [ +0.001314] configfs-gadget gadget: Wrong NDP SIGN [ +0.001331] configfs-gadget gadget: Wrong NDP SIGN [ +0.250721] configfs-gadget gadget: Wrong NDP SIGN [ +0.491456] configfs-gadget gadget: Wrong NDP SIGN [ +0.000164] configfs-gadget gadget: Wrong NDP SIGN [ +0.000446] configfs-gadget gadget: Wrong NDP SIGN [ +0.067507] configfs-gadget gadget: Wrong NDP SIGN [ +0.000984] configfs-gadget gadget: Wrong NDP SIGN [ +0.012649] configfs-gadget gadget: Wrong NDP SIGN [ +0.183993] configfs-gadget gadget: Wrong NDP SIGN [ +0.001107] configfs-gadget gadget: Wrong NDP SIGN [ +0.211788] configfs-gadget gadget: Wrong NDP SIGN [ +0.030077] configfs-gadget gadget: Wrong NDP SIGN -
@bendraper , If you see an ethernet connection to VOXL2 show up on your Windows host, then the usb gadget is properly configured on VOXL2. Perhaps something else is going on. Are you assigning a static ip on your host that is on the same subnet as VOXL2?
You should try to repeat the same test on a linux machine (or virtual machine) to see if you can get a working connection.
Alex
-
@Alex-Kushleyev Yea I can get a connection on a linux machine with no issue. I do need to get it working on a Windows machine for my purposes though. I definitely have the static IP setup correctly. I tried populating the gateway and also not populating it. I confirmed in powershell that there is indeed a route present for that traffic, but they do not want to communicate with each other. Some quick research seems to suggest Windows is very finicky with the CDC NCM protocol and it is more suited to work with an RNDIS interface. Were you able to ping/ssh to a voxl via an ethernet interface on the usb-c port to a windows machine using just the commands you listed above in this post?
-
@bendraper , I just tried this on a Windows 11 VM and even though i was able to see a network device appear in the VM and i configured the IPv4 properties, I cannot ping or ssh. It seems consistent with what you are seeing.
-
@Alex-Kushleyev It looks like someone on the forums maybe had success setting up the interface as an RNDIS gadget. I'll try to mess with it some more but let me know if you find a solution. Thanks!
-
@bendraper , I will ask around.
-
@Alex-Kushleyev So I can see a gadget functionality called gsi.rndis (I'd expect something called rndis.0 or something but maybe that is irrelevant) but when I change the line in /sbin/usb/compositions/901D to use gsi.rndis instead of ncm.0, my network interface on windows disappears and I can no longer ADB. I'd imagine there's something at the kernal level that doesn't like that but I'm out of my wheelhouse there. Setting it back to ncm.0 returns to the previous state but still cannot ping. Wireshark doesn't even see anything happening over that interface
-
Hi All - gonna spend a bit of time looking into this today so I can get some context on the problem.
Zach
-
To enable the NCM gadget on drone (an ethernet over usb protocol), I created a systemclt service on the drone and on the PC.
That's not perfect, but in my case with my pc ubuntu it works. I can use the usb-c wire to communicate with the drone via NCM protocol. I did that to have a better data rate and it is the case since I have now 40 M Bytes/s.I can't share files but here are the code blocks without any warranty. I hope it can help (sorry for the very long message :)) :
./config-voxl-usb-ncm.sh
#!/usr/bin/env bash set -euo pipefail # Minimal orchestrator for PC and Drone install/uninstall. # - PC: installs systemd service, setup script, and NetworkManager drop-in # - Drone: pushes files via adb and enables systemd service # FLAGS: # --pc Only operate on the PC # --drone Only operate on the drone (via adb) # --uninstall Uninstall instead of install # # Defaults: if neither --pc nor --drone is provided, both are processed. ROOT_DIR="$(dirname "$(realpath "$0")")" ON_PC_DIR="${ROOT_DIR}/on_pc" ON_DRONE_DIR="${ROOT_DIR}/on_drone" SERVICE="voxl-usb-ncm.service" SETUP="voxl-usb-ncm-setup.sh" show_help() { echo "Usage: $0 [OPTION]" echo echo "Minimal orchestrator for PC and Drone install/uninstall." echo "- PC: installs systemd service, setup script, and NetworkManager drop-in" echo "- Drone: pushes files via adb and enables systemd service" echo echo "Options:" echo " --pc Install configuration on PC only" echo " --drone Install configuration on Drone only (requires adb)" echo " --uninstall Remove configuration from both PC and Drone" echo " --help Show this help message" echo echo "Examples:" echo " $0 Install on both PC and Drone" echo " $0 --pc Install only on PC" echo " $0 --uninstall Remove all configuration" } do_pc_install() { echo "[INFO][PC] Installing setup script..." sudo install -m 0755 "${ON_PC_DIR}/${SETUP}" /usr/local/sbin/ echo "[INFO][PC] Installing systemd service..." sudo install -m 0644 "${ON_PC_DIR}/${SERVICE}" /etc/systemd/system/ echo "[INFO][PC] Reloading systemd and enabling service..." sudo systemctl daemon-reload sudo systemctl enable --now "${SERVICE}" echo "[INFO][PC] Adding NetworkManager unmanaged config..." sudo install -d -m 0755 /etc/NetworkManager/conf.d sudo install -m 0644 "${ON_PC_DIR}/unmanaged.conf" /etc/NetworkManager/conf.d/ echo "[INFO][PC] Restarting NetworkManager..." sudo systemctl restart NetworkManager echo "[INFO][PC] Install complete." } do_pc_uninstall() { echo "[INFO][PC] Uninstalling..." sudo systemctl disable --now "${SERVICE}" || true sudo rm -f /etc/systemd/system/"${SERVICE}" sudo rm -f /usr/local/sbin/${SETUP} sudo rm -f /etc/NetworkManager/conf.d/unmanaged.conf sudo systemctl daemon-reload sudo systemctl restart NetworkManager echo "[INFO][PC] Uninstall complete." } do_drone_install() { echo "[INFO][DRONE] Preparing adb (root + remount)..." adb root adb remount echo "[INFO][DRONE] Pushing setup script..." adb push "${ON_DRONE_DIR}/${SETUP}" /data/local/tmp/${SETUP} adb shell "mkdir -p /usr/local/sbin && cp /data/local/tmp/${SETUP} /usr/local/sbin/ && chmod 0755 /usr/local/sbin/${SETUP}" echo "[INFO][DRONE] Pushing systemd service..." adb push "${ON_DRONE_DIR}/${SERVICE}" /data/local/tmp/${SERVICE} adb shell "cp /data/local/tmp/${SERVICE} /etc/systemd/system/${SERVICE} && chmod 0644 /etc/systemd/system/${SERVICE}" echo "[INFO][DRONE] Enabling service..." adb shell "systemctl daemon-reload && systemctl enable --now ${SERVICE}" echo "[INFO][DRONE] Install complete." } do_drone_uninstall() { echo "[INFO][DRONE] Uninstalling..." adb root adb remount adb shell "systemctl disable --now ${SERVICE} || true" adb shell "rm -f /etc/systemd/system/${SERVICE} /usr/local/sbin/${SETUP} || true" adb shell "systemctl daemon-reload" echo "[INFO][DRONE] Uninstall complete." } # Arg parsing TARGET_PC=false TARGET_DRONE=false DO_UNINSTALL=false for arg in "$@"; do case "$arg" in --help) show_help; exit 0 ;; --pc) TARGET_PC=true ;; --drone) TARGET_DRONE=true ;; --uninstall) DO_UNINSTALL=true ;; *) echo "[ERROR] Unknown argument: $arg"; show_help; exit 1 ;; esac done # Default to both if none selected if ! $TARGET_PC && ! $TARGET_DRONE; then TARGET_PC=true TARGET_DRONE=true fi # Execute if $DO_UNINSTALL; then $TARGET_PC && do_pc_uninstall $TARGET_DRONE && do_drone_uninstall else $TARGET_PC && do_pc_install $TARGET_DRONE && do_drone_install fi echo "[INFO] All done."./on_drone/voxl-usb-ncm-setup.sh
#!/bin/bash # ────────────────────────────────────────────────────────────────────────────── # Variables # ────────────────────────────────────────────────────────────────────────────── PTH_USB="/sys/kernel/config/usb_gadget/g1" PTH_USB_CONF="$PTH_USB/configs/c.1" PTH_USB_NCM="$PTH_USB/functions/ncm.0" # Network point-to-point USB NCM DRONE_IP_CIDR="${DRONE_IP_CIDR:-10.55.0.1/30}" # IP/mask drone usb0 MTU="${MTU:-1500}" # After some tests, 1500 seems to be the maximum for NCM in USB2.1 # ────────────────────────────────────────────────────────────────────────────── log(){ echo "[voxl-usb-ncm] $*"; } for i in {1..20}; do if [ -d "$PTH_USB" ] && [ -d "$PTH_USB_CONF" ]; then break fi [ $i -eq 1 ] && log "Wait configfs/gadget…" sleep 0.5 done [ -d "$PTH_USB" ] || { log "Don't find gadget $PTH_USB"; exit 1; } [ -d "$PTH_USB_CONF" ] || { log "Don't find config $PTH_USB_CONF"; exit 1; } # Create NCM function if it doesn't exist [ -d "$PTH_USB_NCM" ] || mkdir -p "$PTH_USB_NCM" # Link NCM function to USB gadget config if it's not already done if [ ! -L "$PTH_USB_CONF/ncm" ]; then log "Symlink NCM → config" ln -s "$PTH_USB_NCM" "$PTH_USB_CONF/ncm" fi # Update USB gadget to take into account the new NCM function echo "" > "$PTH_USB/UDC" check_usb0="ip link show usb0 > /dev/null 2>&1" if ! eval "$check_usb0"; then sleep 0.5 if ! eval "$check_usb0"; then log "usb0 doesn't exist after NCM setup" exit 1 fi fi log "usb0 added successfully after NCM setup" # Config network usb0 (idempotente) log "Configuration network usb0: $DRONE_IP_CIDR (mtu=$MTU)" ip link set usb0 up || true ip addr flush dev usb0 || true ip addr add "$DRONE_IP_CIDR" dev usb0 ip link set usb0 mtu "$MTU" || true # Small TCP optimisations [ -w /proc/sys/net/ipv4/tcp_mtu_probing ] && echo 1 > /proc/sys/net/ipv4/tcp_mtu_probing || true [ -w /proc/sys/net/core/rmem_max ] && echo 16777216 > /proc/sys/net/core/rmem_max || true [ -w /proc/sys/net/core/wmem_max ] && echo 16777216 > /proc/sys/net/core/wmem_max || true log "USB NCM configuration done !" exit 0./on_drone/voxl-usb-ncm.service
[Unit] Description=VOXL USB NCM setup (add NCM function and bring up usb0) After=multi-user.target sys-kernel-config.mount Requires=sys-kernel-config.mount [Service] Type=oneshot RemainAfterExit=yes ExecStart=/usr/local/sbin/voxl-usb-ncm-setup.sh [Install] WantedBy=multi-user.target./on_pc/unmanaged.conf
[keyfile] unmanaged-devices=interface-name:enx*./on_pc/voxl-usb-ncm-setup.sh
#!/bin/bash IP="10.55.0.2/30" CONFIGURED_IFACE="" LOGGER_TAG="[voxl-usb-ncm]" log() { /usr/bin/logger -t "$LOGGER_TAG" "$1" } log "Service started" while true; do IFACE=$(ls /sys/class/net | grep '^enx' | head -n1) if [ -n "$IFACE" ]; then if [ "$IFACE" != "$CONFIGURED_IFACE" ]; then log "Detected new interface: $IFACE" /usr/sbin/ip addr flush dev "$IFACE" || log "Failed to flush IP addresses on $IFACE" /usr/sbin/ip addr add "$IP" dev "$IFACE" || log "Failed to assign IP $IP to $IFACE" /usr/sbin/ip link set "$IFACE" up || log "Failed to bring up $IFACE" /usr/sbin/ip route del default dev "$IFACE" 2>/dev/null || log "No default route to delete for $IFACE" log "Configured $IFACE with $IP" CONFIGURED_IFACE="$IFACE" fi else if [ -n "$CONFIGURED_IFACE" ]; then log "Interface $CONFIGURED_IFACE disconnected" fi CONFIGURED_IFACE="" fi sleep 2 done./on_pc/voxl-usb-ncm.service
[Unit] Description=Watch for USB NCM interface and configure it After=network.target ConditionPathExists=/usr/local/sbin/voxl-usb-ncm-setup.sh [Service] Type=simple ExecStart=/usr/local/sbin/voxl-usb-ncm-setup.sh Restart=always RestartSec=2 [Install] WantedBy=multi-user.target