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
- Connect to the RaspberryPi using SSH
- Become super user on the RaspberryPi:
sudo su
- Edit
/boot/firmware/cmdline.txt
and add these options after rootwait
:
1
|
modules-load=dwc2,g_ether
|
- Edit
/boot/firmware/config.txt
and make sure that otg_mode=1
is uncommented.
Then add this line after the [all]
section:
- Use this command to add a new connection:
1
|
nmcli con add type ethernet con-name ethernet-usb0
|
- 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]
|
- Edit
/usr/local/sbin/usb-gadget.sh
and add this:
1
2
3
|
#!/bin/bash
nmcli con up ethernet-usb0
|
- Make the file executable:
1
|
chmod a+rx /usr/local/sbin/usb-gadget.sh
|
- 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
|
- Enable the service using this command:
1
|
systemctl enable usbgadget.service
|
- Reboot the RaspberryPi:
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