How to configure an Ethernet connection between iPad and RaspberryPi through USB-C

This tutorial explains how to configure an Ethernet connection between an iPad and a RaspberryPi using the USB-C port.

I recently found out (thanks to this article from Juha-Matti Santala) that not only you can power a RaspberryPi device through the USB-C of an iPad but that you can also get an ethernet connection through it

Requirements

  • an USB-C iPad (I used an iPad Air 4th gen)
  • a USB-C cable (I used the one that comes with the iPad)
  • a RaspberryPi (you need at least a RPI 4. I used a RPi 5)
  • you already have SSH access to the RaspberryPi (I won’t cover this part in this tutorial)
  • an updated bootloader on the RaspberryPi (check this documentation)

Configuration

  1. Connect to the RaspberryPi using SSH
  2. Become super user on the RaspberryPi: sudo su
  3. Edit /boot/firmware/cmdline.txt and add these options after rootwait:
1
modules-load=dwc2,g_ether
  1. Edit /boot/firmware/config.txt and make sure that otg_mode=1 is uncommented. Then add this line after the [all] section:
1
dtoverlay=dwc2
  1. Use this command to add a new connection:
1
nmcli con add type ethernet con-name ethernet-usb0
  1. Edit /etc/NetworkManager/system-connections/ethernet-usb0.nmconnection and make sure you have these settings:
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
[connection]
id=ethernet-usb0
uuid=<random group of characters here>
type=ethernet
autoconnect=true
interface-name=usb0
  
[ethernet]
  
[ipv4]
method=shared
  
[ipv6]
addr-gen-mode=default
method=auto
  
[proxy]
  1. Edit /usr/local/sbin/usb-gadget.sh and add this:
1
2
3
#!/bin/bash

nmcli con up ethernet-usb0
  1. Make the file executable:
1
chmod a+rx /usr/local/sbin/usb-gadget.sh
  1. Edit /lib/systemd/system/usbgadget.service and add this:
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
[Unit]
Description=My USB gadget
After=NetworkManager.service
Wants=NetworkManager.service
  
[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=/usr/local/sbin/usb-gadget.sh
  
[Install]
WantedBy=sysinit.target
  1. Enable the service using this command:
1
systemctl enable usbgadget.service
  1. Reboot the RaspberryPi:
1
reboot

Check the configuration is working

Connect the RaspberryPi to the iPad using the USB-C cable and wait for it to boot. Once it finishes booting up, open Settings on the iPad and check if there is an Ethernet section below the WiFi Connection. If you find the entry, then it means the connection is successful.

References

This tutorial has been written thanks to this other tutorial https://github.com/verxion/RaspberryPi/blob/main/Pi5-ethernet-and-power-over-usbc.md

If you enjoyed this article and want to show your appreciation, consider buying me a coffee using the button below. Your support, even a small gesture, means a lot and will inspire me to continue writing and sharing more articles on my blog ❤️

Buy Me a Coffee at ko-fi.com
source code available on GitHub
Built with Hugo
Theme Stack designed by Jimmy