Raspberry Pis have a single dedicated USB-On-The-Go USB-port, using it means the Pi does then not act as the USB-host, but as USB gadget device.
With this the Pi is said to be usable with OpenWRT, such that the Pi can be directly connected to a host PC via USB cable. If configured properly and attached to PC, a virtual COM-port and/or network adapter is said to appear on the PC, which can then be used for admin access to the Pi device via Putty Serial or SSH connection.
It would be super nice, to have this option as a fallback admin access option on the Pi.
- I see there is a 4 year old other thread talking about this, but that did not help me.
- There are countless recipies on the Internet and the usual AIs explain a lot, how to do this, but none helped for me.
- The most helpful Youtube tutorial for me so far was: https://www.youtube.com/watch?v=BYPsi10kavk, but even then I did not succeed to configure network-over-usb-admin-access.
The first part of the video shows, how to configure Serial over USB via kmod-usb-gadget-serial. This is what actually did work for me.
The second part of the video shows, how to configure both Serial over USB + network over USB.
Sadly. I keep failing on this. I tried twice with Raspberry Pi 4 with vanilla OpenWRT 23.05 and vanilla 25.12rc5.
#packages (“composite” is said to enable both network-over-usb and serial-over-usb)
kmod-usb-dwc2 kmod-usb-gadget-cdc-composite
#/boot/config.txt:
include distroconfig.txt
[all]
dtoverlay=dwc2
#/etc/inittab:
::sysinit:/etc/init.d/rcS S boot
::shutdown:/etc/init.d/rcS K shutdown
::askconsole:/usr/libexec/login.sh
tty1::askfirst:/usr/libexec/login.sh
ttyGS0::askfirst:/usr/libexec/login.sh
#/etc/rc.local:
modprobe g_cdc
sleep 5
ifup otg
exit 0
#/etc/config/system
…other default stuff…
option ttylogin '1' # changed this from 0 to 1
#/etc/config/network:
(running modprobe g_cdc or modprobe g_ether once before committing)config interface 'loopback'
option device 'lo'
option proto 'static'
list ipaddr '127.0.0.1/8'config globals 'globals'
option dhcp_default_duid '00046ef1de018083451eaa7a1372380e531f'
option ula_prefix 'fde4:3233:d255::/48'
option packet_steering '1'config device
option name 'br-lan'
option type 'bridge'
list ports 'eth0'config interface 'lan'
option device 'br-lan'
option proto 'static'
list ipaddr '192.168.1.1/24'
option ip6assign '60'config interface 'wwan'
option proto 'dhcp'config interface 'otg'
option proto 'static'
option device 'usb0'
option auto '0'
option ipaddr '192.168.100.1'
option netmask '255.255.255.0'
#/etc/config/firewall:
…other default stuff…config zone
option name 'lan'
option input 'ACCEPT'
option output 'ACCEPT'
option forward 'ACCEPT'
list network 'lan'
list network 'otg'
#/etc/network/dhcp
…other default stuff…config dhcp 'otg'
option interface 'otg'
option start '100'
option limit '150'
option leasetime '12h'
option dhcpv4 'server'
Result fails so far:
Once connecting to the PC, the PC shows a broken COM port in device manager, but no clues of a network-over-USB interface appearing.
- I can still flawlessly administrate the Pi4 via its regular LAN-port (including installing additional packages via WiFi-WAN). So from my perspective it is not the usual OpenWRT network config that fails, rather it seems neither the serial-over-usb–COM-port and the network-over-usb-LAN adapter do not work, as nothing gets detected on the PC, when connecting via USB-OTG port. Feels like something of the kernel module or its config might be missing.
- when instead of kmod-usb-gadget-cdc-composite using kmod-usb-gadget-serial, I do see a working COM port on the Windows11-PC immediately once USB-connected and can successfully access it via Putty-serial according to the first part of the video, but using kmod-usb-gadget-cdc-composite for a virtual network adapter leeds to a dead end so far. Even other Internet OTG recipies did not help, just show more exotic packages that did not help. Either CDC-composite feels broken or there is some mysterious config secret that i have missed so far.
Has anyone succeed with network over USB-OTG gadget mode on a Raspberry Pi with a recent OpenWRT 23, 24 or 25rc?