PPP over UART

Is it possible to use PPP (point-to-point protocol) over UART, for example to connect a Raspberry Pi to a desktop computer by using UART to USB (FTDI) cable? I am trying to do something like this with my pinephone pro project:

- From desktop, connect to USB serial using
Code:
sudo cu -s 115200 -l /dev/ttyU0
- I get a login console on the phone, so I login as root
- Now start a PPP direct session
Code:
ppp -direct myprofile

At this point, it should start spitting out characters like
Code:
~}#!}!}!} }8}(}"}'}"}"}&} } } } }!}$}%}%}&n`u;~
, however nothing shows up and after a while it gives up and exits. If I try this on my desktop PC, I see those characters. On the device, if I run tmux first, then run
Code:
ppp -direct
, then the characters start appearing, but (I am guessing) since tmux interferes with the character stream, this doesn't work. I can't figure out why
Code:
ppp
does not use the console for starting the session? Any ideas? I tried various options in /etc/ttys like "3wire.115200 xterm", "std.115200 vt100" and all variations thereof (std doesn't work since there's no hardware flow control).
 
I should just mention the behavior is the same on both Raspberry Pi serial console and the pinephone pro.
 
That is basically what an old school US Robotics modem would do over the phone lines. Host would do PPP over the UART to the modem, modem would send POTS tones out.
So I think it would be possible.
 
Yes it is possible. PPP was primarily designed with UARTs in mind. By default PPP daemon will expect raw 8bit line discipline and most very likely your login session is using a "cooked" tty mode. You need to research tty I/O modes. Also understand that there will likely be some permission setup required to map the PPP daemon UART control to the systems network/IP layer. ie...daemon probly needs to run as root, or you need to be a member of the correct user group.

and FWIW, 3 wire UART comms are an abomination. ALWAYS use hardware flow control if you can.
 
I tried removing the TTY on the serial port from /etc/ttys, so now I have a clean dumb pipe between the RPi and PC. I can run cu -s 115200 -l /dev/ttyu0 on the Pi and cu -s 115200 -l /dev/ttyU1 on the PC, then if I type on one, it comes out on the other and vice versa. All good. I am running everythign as root. So then I leave the cu running on the PC and run ppp -foreground local on the Pi and nothing appears on the PC. The entire contents of my /etc/ppp/ppp.conf on the Pi is:

Code:
local:
    set device /dev/ttyu0  # Adjust based on your serial device
    set speed 115200        # Adjust speed as necessary
    set ifaddr 192.168.1.1 192.168.1.2  # Local and remote IPs
    set log Phase Connect hdlc

However, if I do the reverse, leave the cu running on the Pi but start ppp on the PC, I then see the handshake characters appear on the Pi. My ppp.conf on the PC is the same as above, just the device set to /dev/ttyU1 and ip addresses swapped. My UART device has blinky lights to tell me if data is being transmitted, and no data is transmitted when starting ppp on the Pi. Why would that be?
 
I thought that maybe it's because there's a serial console on the UART at boot (an hence dmesg output appears on the UART which will anyway interfere with PPP), so I tried removing that (and adding enable_uart=1 to config.txt), but then if I echo hello > /dev/ttyu0 it just hangs.
 
teekay, I think that your setup should be equivalent to a null-modem setup.
Maybe /usr/share/examples/ppp/ppp.conf.sample can be of some help.

Also, I have some snippets of very old configurations in my ppp.conf.
I do not have much recollection of when and where I needed them but they have some explicit commands like
Code:
set cd off
set ctsrts off
 
teekay, I think that your setup should be equivalent to a null-modem setup.
Maybe /usr/share/examples/ppp/ppp.conf.sample can be of some help.

Also, I have some snippets of very old configurations in my ppp.conf.
I do not have much recollection of when and where I needed them but they have some explicit commands like
Code:
set cd off
set ctsrts off
Thank you! The set ctsrts off was the missing piece. It is mentioned in the handbook under "Debugging" but I somehow missed it. It was not in the examples. I've now got PPP running over UART.
 
Although I have a PPP connection working between the device and my PC, I've hit a stumbling block. I cannot resolve DNS entries on the device. I can ping the DNS server (e.g. 8.8.8.8 or my local one), and I can even ping raw ip addresses on the internet, but when I try to ping yahoo.com, I see in the logs:

Code:
ppp[78933]: DNS: INbound query IN A yahoo.com.
ppp[78933]: DNS: INbound query IN AAAA yahoo.com.

And ping fails with Name does not resolve. The correct nameserver IP is in the /etc/resolv.conf file on the device. I tried ppp with the -nat option and without, and various external DNS servers like 8.8.8.8, no difference. I have set sysctl net.inet.ip.forwarding=1 and a pf config to act as a gateway:

Code:
ext_if="re0"                                        
int_if="tun0"                                       
localnet=$int_if:network                            
icmp_types = "{ echoreq unreach }"                  
                                                    
set skip on lo0                                     
scrub in                                            
nat on $ext_if inet from !($ext_if) -> ($ext_if:0)  
block all                                           
pass from {self, $localnet} to any keep state       
pass inet proto icmp icmp-type $icmp_types

Why is DNS resolution failing?
 
Back
Top