eastinside
Posts: 2
Joined: Wed Dec 04, 2019 2:37 pm

Rpi 4 with Ubuntu Server tether network with usb-c

Wed Dec 04, 2019 2:55 pm

I have a Raspberry Pi 4 4GB were I have installed Ubuntu Server 19.10, I'm trying to get network and power over a USB-C cable to an Ipad Pro. I follwed this tutorial https://www.hardill.me.uk/wordpress/201 ... -c-gadget/ to get it working with Raspian Buster and it worked. But I want to utilize the 64-bit support from Ubuntu.

I need help to figure out how to setup the network from the USB-C cable.

Any ideas are welcome :)

- I have check/update the bootloader
- I have added total_mem=3072 to /usercfg.txt so USB is working

Code: Select all

uname -a
Linux ubuntu 5.3.0-1007-raspi2 #8-Ubuntu SMP Thu Oct 10 12:42:47 UTC 2019 aarch64 aarch64 aarch64 GNU/Linux

phase
Posts: 54
Joined: Thu Jun 30, 2016 3:05 am

Re: Rpi 4 with Ubuntu Server tether network with usb-c

Wed Dec 04, 2019 11:38 pm

i browsed over the articles..this is not my forte but you need to run an update the rpi4

Code: Select all

apt update && apt upgrade && apt dist-upgrade
this may be of some help your kernal is old

depmod
Posts: 4
Joined: Thu Feb 20, 2020 10:24 am

Re: Rpi 4 with Ubuntu Server tether network with usb-c

Thu Feb 20, 2020 10:27 am

Hi @eastinside Did you figure out how to do it? I want to do the same.

eastinside
Posts: 2
Joined: Wed Dec 04, 2019 2:37 pm

Re: Rpi 4 with Ubuntu Server tether network with usb-c

Thu Feb 20, 2020 2:11 pm

@depmod, no not yet! Still looking! I have also posted this questions here: https://askubuntu.com/questions/1193871 ... with-usb-c

depmod
Posts: 4
Joined: Thu Feb 20, 2020 10:24 am

Re: Rpi 4 with Ubuntu Server tether network with usb-c

Thu Feb 20, 2020 2:15 pm

@eastinside I will post here if I find out. Please post here as well if you find out through the other post.

mbreese
Posts: 4
Joined: Fri Feb 21, 2020 8:46 am

Re: Rpi 4 with Ubuntu Server tether network with usb-c

Fri Feb 21, 2020 8:48 am

It looks like this is a bug in the Ubuntu RPi kernel. I *think* this patch should fix it, but I haven't tested it myself.

[https://bugs.launchpad.net/ubuntu/+sour ... ug/1861070]

(I've been trying to do the same thing)
Last edited by mbreese on Fri Feb 21, 2020 10:05 am, edited 1 time in total.

mbreese
Posts: 4
Joined: Fri Feb 21, 2020 8:46 am

Re: Rpi 4 with Ubuntu Server tether network with usb-c

Fri Feb 21, 2020 10:04 am

Using the testing PPA, I was able to successfully get this to work using this guide as a starting point: [https://www.hardill.me.uk/wordpress/201 ... -c-gadget/]

I'm tethering an Rpi 4 with Ubuntu server (arm64) to an IPad Pro.

This is really not all that recommended because it's a testing kernel, but if you enable the PPA from here: [https://launchpad.net/~canonical-kernel ... ubuntu/ppa], then you can get the fixed kernel module. If you can be patient for the kernel to finish going through the release process, then I'd recommend that.

But if you're as impatient as me, then this does work.

After you enable the PPA, you can upgrade the `linux-raspi2` package. This will install the fixed kernel module.

There are a few differences from the hardill guide that you'll want to keep in mind.

1) in your `/boot/firmware/usercfg.txt` file, you'll want to add `dtoverlay=dwc2,dr_mode=peripheral`. (I haven't tested it w/o the dr_mode=peripheral argument, so this might still work).

2) Ubuntu by default uses the systemd-resolved, so you'll have to also configure dnsmasq to disable its DNS server.

You can do this by adding the line `port 0` to the /etc/dnsmasq.d/usb file. This disables the DNS server, but keeps the DHCP server.

3) Instead of using the traditional `/etc/network/interfaces.d/usb0`, you can also use the default netplan setup for Ubuntu. Here is an example what what mine looks like (stored as /etc/netplan/99-custom.yaml):

Code: Select all

network:
  version: 2
  renderer: networkd
  wifis:
    wlan0:
      dhcp4: yes
      dhcp6: no
      access-points:
        "my-ssid":
          password: "secret-preshared-key"
  ethernets:
    eth0:
      dhcp4: true
    usb0:
      dhcp4: false
      optional: true
      addresses: [10.55.0.1/29]

4) In the /root/usb.sh script, I think you can remove the last two lines. (the `ifup usb0` and `system dnsmasq restart` lines).

That's what I currently have working. I'm not sure how stable it is yet, but so far, it does seem to be working. Again, this testing kernel PPA isn't recommended, but so far, so good.

Good luck!

depmod
Posts: 4
Joined: Thu Feb 20, 2020 10:24 am

Re: Rpi 4 with Ubuntu Server tether network with usb-c

Fri Feb 21, 2020 11:45 am

Thanks a lot for the detailed explanation @mbreese. Great explanation. Which version of Ubuntu are you using? 18.04 or 19.10? Do you know how long does kernel take to finish going through the release process approximately? Do we need for the next release of Ubuntu? How do we know which stable release to use? Also do you think same instructions would work with other distros like Kali?

mbreese
Posts: 4
Joined: Fri Feb 21, 2020 8:46 am

Re: Rpi 4 with Ubuntu Server tether network with usb-c

Fri Feb 21, 2020 3:10 pm

I’m using 19.10 and this fix is slated to be in (I think) the next stable kernel. (It’s already been pushed out for testing, which is where the PPA version I’m using came from). Because it was effectively just going an ‘apt upgrade’, the process was pretty fast (15-20 min ish). If you had to actually compile the kernel, it would take a few hours I’m guessing. However, the first link does have the instructions for what to change in the kernel config — it’s a kernel config flag that needs to be set, not a code patch.

Not sure about anything other than Ubuntu... but if you have an error, this is a good place to start looking. There is a specific string in the dmesg log to look for. It is also shown in the first link above.

Code: Select all

Configuration mismatch. dr_mode forced to host
If you see this in dmesg, then this will be one of the issues.

jcastroa87
Posts: 3
Joined: Sat May 30, 2020 9:38 pm

Re: Rpi 4 with Ubuntu Server tether network with usb-c

Sat May 30, 2020 9:47 pm

Hi im trying to follow this steps on Ubuntu Server 20.04, but i cant get this works, i dont know how to make /root/usb.sh execute on startup. Thanks in advance.

mbreese
Posts: 4
Joined: Fri Feb 21, 2020 8:46 am

Re: Rpi 4 with Ubuntu Server tether network with usb-c

Mon Jun 01, 2020 4:03 am

jcastroa87 wrote:
Sat May 30, 2020 9:47 pm
Hi im trying to follow this steps on Ubuntu Server 20.04, but i cant get this works, i dont know how to make /root/usb.sh execute on startup. Thanks in advance.

From the hardill.me.uk link above (https://www.hardill.me.uk/wordpress/201 ... -c-gadget/):
Add /root/usb.sh to /etc/rc.local before exit 0 (I really should add a systemd startup script here at some point)
But, this is likely to be out of date with Ubuntu 20.04

lsmith77
Posts: 1
Joined: Mon Jun 01, 2020 9:31 am

Re: Rpi 4 with Ubuntu Server tether network with usb-c

Mon Jun 01, 2020 9:48 am

Just to understand the steps above and try to apply them to Ubuntu Server 20.20. So far it is not yet working for me, but hoping with the summary, we can identify what needs to be adjusted.

Add dtoverlay=dwc2 to the /boot/config.txt
Add modules-load=dwc2 to the end of /boot/cmdline.txt

Replaced by 1) in your `/boot/firmware/usercfg.txt` file, you'll want to add `dtoverlay=dwc2,dr_mode=peripheral`. (I haven't tested it w/o the dr_mode=peripheral argument, so this might still work).

But does this really cover the modules-load bit?

If you have not already enabled ssh then create a empty file called ssh in /boot
Add libcomposite to /etc/modules
Install dnsmasq with sudo apt-get install dnsmasq

Remains the same

Create /etc/dnsmasq.d/usb with following content

Remains the same but add "port 0" at the end

Add denyinterfaces usb0 to /etc/dhcpcd.conf
Create /etc/network/interfaces.d/usb0 with the following content

Replaced by 3) Instead of using the traditional `/etc/network/interfaces.d/usb0`, you can also use the default netplan setup for Ubuntu. Here is an example what what mine looks like (stored as /etc/netplan/99-custom.yaml):

Create /root/usb.sh
Make /root/usb.sh executable with chmod +x /root/usb.sh

Remains the same, though potentially the last 2 lines can be disabled

Add /root/usb.sh to /etc/rc.local before exit 0 (I really should add a systemd startup script here at some point)

Remains the same once rc.local has been setup https://www.linuxbabe.com/linux-server/ ... th-systemd

*Update* Managed to fix the " For now it hangs for several minutes at "A start job is running .."." bit .. was due to not cleaning up the "/etc/netplan/99-custom.yaml" example. Also note one should run "sudo netplan generate; sudo netplan apply" after making changes to the netplan configs.
Last edited by lsmith77 on Tue Jun 02, 2020 6:00 pm, edited 1 time in total.

jcastroa87
Posts: 3
Joined: Sat May 30, 2020 9:38 pm

Re: Rpi 4 with Ubuntu Server tether network with usb-c

Tue Jun 02, 2020 2:14 pm

i surrender with ubuntu, i cant translate steps, then i try with 64bits raspbian viewtopic.php?f=117&t=275370 i can do it, and it works with docker (the reason because i need a 64 bits OS)

jcastroa87
Posts: 3
Joined: Sat May 30, 2020 9:38 pm

Re: Rpi 4 with Ubuntu Server tether network with usb-c

Tue Jun 30, 2020 11:51 pm

today i try this step by step on ubuntu 20.04, i get this on my macbook

Image

i just get "169.254.249.92", i cant get fixed ip working, i want to get 10.55.0.1, but idk what i need to do.

Thanks i advance.

Brestois
Posts: 7
Joined: Wed Jul 22, 2020 7:24 pm

Re: Rpi 4 with Ubuntu Server tether network with usb-c

Fri Jul 24, 2020 10:12 pm

Hi, did you get it working ?
I tried everything in this post, but not able to make it work.
Event though I’m getting an IP address in iPad’s Ethernet section, I cannot RDP inside. And my Ubuntu Mate 20 is not able to access to Internet using my iPad connection.

It’ll be great if someone comes up with a working example, because Ubuntu Mate is running perfectly on Raspberry Pi 4B without any lag.

Rramnel
Posts: 1
Joined: Sat Jul 25, 2020 8:10 pm

Re: Rpi 4 with Ubuntu Server tether network with usb-c

Sat Jul 25, 2020 8:12 pm

If you can see an IP address from your iPad, why are you not able to connect to the raspberry Pi? It should work. Have you tried to ssh into it and install a VNC server?

Return to “Ubuntu”