Modem Emulation and Networking

driver1998 edited this page Nov 29, 2018 · 17 revisions

You'll need the following stuff.

  • Raspberry Pi running WoA

MiniUART is now useable on WoA, you can get the drivers (pi_miniuart.sys) in this repo.

  • a Linux system with Internet connection
  • tcpser for modem emulation, you can use my fork of it (Support up to 921600bps)
  • pppd PPP daemon
  • telnetd and xinetd for Telnet services
  • an USB to TTL adapter

These adapters are known to work:
CH340 series: Up to 460800bps
CP2102: Up to 921600bps
Since MiniUART on the RPi side supports up to 921600bps, there is no point to go faster than that.
Of course, when PL011 UART is free, we can try to get even faster.

Test the connection between RPi and your Linux box first!
You can use tools like putty on each end. (ARM64 putty build is available on XDA)

The following instructions is based on the PiModem Project.

Set up a PPP-over-Telnet service

tcpser connects to a telnet server when "dialing" into a remote system, so we need to set up a PPP-over-Telnet service in order to connect to Internet.

1.Install pppd and set the setuid bit, which allows it to run as root.

$ sudo chmod a+s /usr/sbin/pppd

2.Configure pppd by editing the following files:

Here your Linux box will be 192.168.100.1, and RPi will be 192.168.100.2.
And we assume your DNS is 192.168.1.1.

/etc/ppp/options

# We will be doing PPP over Telnet - disable serial control.
local

# Terminate connection if remote side stops responding.
lcp-echo-interval 30
lcp-echo-failure 4

# Debug adds a lot of detail into the system logs regarding PPP negotiation.
# This is helpful in debugging client issues.
debug

# IP addresses to use in local:remote format.  We use NAT to share
# the Wi-Fi connection, make sure these are outside of your real subnet.
192.168.100.1:192.168.100.2

# DNS server for Windows clients.
ms-dns 192.168.1.1

# Other sensible options
asyncmap 0
passive
noipx

/etc/ppp/pap-secrets

# Allow any username/password
*	*	""	*

3.Configure a telnet server for PPP-over-telnet

Here we'll create a special user ppp, and replace its shell with pppd.
And we'll configure telnetd so that when we telnet to the service, it will automatically log in as ppp.
That way when we "dial into" the Linux box, pppd will start up smoothly for the rest of the things.

Create /etc/xinetd.d/pppd for the telnet server.

service pppd
{
    type = UNLISTED
    flags  = REUSE
    socket_type = stream
    wait  = no
    user  = root
    server  = /usr/sbin/in.telnetd
    server_args = -h -L /usr/local/bin/ppplogin
    disable  = no
    bind  = 127.0.0.1
    port = 4074
}

And the script /usr/local/bin/ppplogin that the telnet server runs when connected.

#!/bin/bash
/bin/login -f ppp

Set the executable bit of ppplogin, and create the ppp user.

$ sudo chmod +x /usr/local/bin/ppplogin
$ sudo useradd -m ppp
$ sudo usermod -aG dip ppp
$ sudo usermod -s /usr/sbin/pppd ppp
$ sudo touch /home/ppp/.hushlogin

Enable and restart xinetd, so the telnet server will be up.

sudo systemctl enable xinetd
sudo systemctl restart xinetd

Now when we telnet to 127.0.0.1:4074, pppd will show up for the rest of the connection process.

Set up NAT and routing for Internet access

Here we assume your network card to Internet is eth0.

First, enable IPv4 forwarding with the following command.

$ sudo sh -c "echo 1 > /proc/sys/net/ipv4/ip_forward"

Then enable NAT for your RPi.

$ sudo iptables -t nat -A POSTROUTING -o eth0 -s 192.168.100.0/24 -j MASQUERADE

Finally, Set up tcpser for modem emulation

Build tcpser, then run it with the following command:

$ sudo tcpser -s 115200 -d /dev/ttyUSB0 -l4 -n "30624700=127.0.0.1:4074"

-s 115200 - Connection speed, up to 921600bps.

-d /dev/ttyUSB0 - Device file for your USB to TTL adapter

-l4 - Debug level 4, for something to look at :)

-n "30624700=127.0.0.1:4074" - Phone book, which is a list of pseudo phone numbers to dial. So when we dial 30624700, 127.0.0.1:4074 will be connected.

Modem Installation and Settings in WoA

Grab WINDOWS\Inf\mdmgen.inf from a AMD64 Windows build with the same build number, and replace any amd64 reference in it with arm64, then copy it to your WoA install.

Open Device Manager, select Action - Install Legacy Hardware and Install "Standard 33600 bps Modem"

Run rasphone.exe, add a dial up (PPP, not PPPoE for Broadband) connection with the phone number 30624700, empty username and password, but don't connect for now.

Click Properties in the RASPHONE window, then click Options in the opened dialog, select 115200bps speed, disable hardware flow control, error control and compression.

Dialup Settings

Then try to dial to your Linux box, if everything works, you should be connected to the Internet.

Going Beyond 115200bps (Up to 921600bps)

By default, the modem driver is limited to 115200bps. if you select anything higher than that, it'll still try to initialize the modem at 115200bps, then switch to a higher speed. And tcpser does not support this operation.

To workaround, edit mdmgen.inf, look for the following lines:

[Gen336Reg]
HKR,, Properties, 1, 80,01,00,00, 00,00,00,00, 00,00,00,00, 00,00,00,00, 00,00,00,00, 10,01,00,00, 00,C2,01,00, 40,83,00,00

Change the 00,C2,01,00 at the end to 00,10,0e,00, like this.

[Gen336Reg]
HKR,, Properties, 1, 80,01,00,00, 00,00,00,00, 00,00,00,00, 00,00,00,00, 00,00,00,00, 10,01,00,00, 00,10,0e,00, 40,83,00,00

Then remove and reinstall the modem.

In this way, you can see there are higher speeds to select in the modem properties.

Modem Properties

Then go to dialup settings in rasphone, and change the speed over there, make sure these two speeds are identical.

Clone this wiki locally
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.