Repository navigation
Networking for the PlayStation 2
Although drivers for PlayStation 2 Ethernet hardware have not been implemented yet (see issue #19), it’s easy to use a corresponding Ethernet USB adapter, for example a D-Link DUB-1312, having USB id 0b95:1790, based on Asix Electronics AX88179 gigabit Ethernet hardware. It’s preconfigured as a loadable module with CONFIG_USB_NET_AX88179_178A=m in linux/arch/mips/configs/ps2_defconfig, installed as initramfs/lib/modules/5.4.221+/kernel/drivers/net/usb/ax88179_178a.ko in the INITRAMFS.
Enable the AX88179 driver by editing initramfs/etc/init.d/rcS, adding at the end:
modprobe cdc_mbim
modprobe ax88179_178a
Alternatively, or in addition to Ethernet, it’s possible to configure Wi-Fi for the PlayStation 2 with an appropriate USB adapter. Note that Wi-Fi is significantly more complex to configure than Ethernet.
The PlayStation 2 can obtain an IP address in several ways. One of the simplest is to configure a fixed IP address, by editing initramfs/etc/init.d/rcS. Assuming your network prefix is 10.0.1.0, and that 10.0.1.201 is a suitable IP address for your PlayStation 2, add at the end:
ip_set_addr() {
local subn=10.0.1
local addr=$subn.201
ip addr add "$addr"/24 dev eth0
ip link set eth0 up
ip route add default via $subn.1
ip route add $subn.0/24 via $subn.1 dev eth0
}
ip_has_addr() { ip addr | grep -q inet; }
ip_has_link() { ip link | grep -q eth0; }
ip_daemon() {
while :
do
ip_has_link && (ip_has_addr || ip_set_addr)
sleep 10
done
}
sleep 1
ip_daemon &On your workstation, you should now be able to ping the PlayStation 2 with:
$ ping 10.0.1.201
PING 10.0.1.201 (10.0.1.201) 56(84) bytes of data.
64 bytes from 10.0.1.201: icmp_seq=1 ttl=64 time=0.567 ms
64 bytes from 10.0.1.201: icmp_seq=2 ttl=64 time=0.576 ms
64 bytes from 10.0.1.201: icmp_seq=3 ttl=64 time=0.569 ms
...
Adding a line 10.0.1.201 ps2.local to your workstation’s /etc/hosts file allows host names, as in:
$ ping ps2.local
PING ps2.local (10.0.1.201) 56(84) bytes of data.
64 bytes from ps2.local (10.0.1.201): icmp_seq=1 ttl=64 time=0.531 ms
64 bytes from ps2.local (10.0.1.201): icmp_seq=2 ttl=64 time=0.561 ms
64 bytes from ps2.local (10.0.1.201): icmp_seq=3 ttl=64 time=0.538 ms
...
Note
A similar script could be made using Busybox’s ifplugd command instead.
Note
To save space, CONFIG_IPV6 is currently not set in linux/arch/mips/configs/ps2_defconfig, so only IPv4 is available in the Linux kernel.
The INITRAMFS is preinstalled with Dropbear, for secure shell (SSH) services, with initramfs/etc/inetd.conf and programs compiled and installed in initramfs/usr/bin:
dropbear -> dropbearmulti
dropbearmulti
scp -> dropbearmulti
ssh -> dropbearmulti
Generate your PlayStation 2 host key with:
$ mkdir initramfs/etc/dropbear
$ dropbearmulti dropbearkey -t ed25519 -f initramfs/etc/dropbear/dropbear_ed25519_host_key
Copy your workstation’s ~/.ssh/id_ed25519.pub (generate it with ssh-keygen -t ed25519 if it’s missing) to initramfs/root/.ssh/authorized_keys:
$ chmod 700 initramfs/root
$ ls -ld initramfs/root
drwx------ .... initramfs/root
$ mkdir initramfs/root/.ssh
$ chmod 700 initramfs/root/.ssh
$ ls -ld initramfs/root/.ssh
drwx------ .... initramfs/root/.ssh
$ cp ~/.ssh/id_ed25519.pub initramfs/root/.ssh/authorized_keys
$ chmod 600 initramfs/root/.ssh/authorized_keys
$ ls -l initramfs/root/.ssh/authorized_keys
-rw------- .... initramfs/root/.ssh/authorized_keys
Note
Dropbear is sensitive to file and directory permissions, so make sure these are correct.
If there are problems, grep dropbear /var/log/messages on the PlayStation 2 might reveal reasons. Adding a -v flag to ssh might also explain problems, as in ssh -v root@ps2.local.
Now, try to login:
$ ssh root@ps2.local
machine: SCPH-37000 L
Linux (none) 5.4.221+ ... mips GNU/Linux
~ #
Note
The displayed login message can be removed by editing initramfs/etc/profile, which is especially useful when running commands via ssh.
Note
The User root directive can be added to your workstation’s ~/.ssh/config file, to login with simply ssh ps2.local (omitting the root@):
Host ps2.local
User root
Note
As an alternative to having 10.0.1.201 ps2.local in your workstation’s /etc/hosts file, the Hostname 10.0.1.201 directive can be added to your workstation’s ~/.ssh/config file:
Host ps2.local
Hostname 10.0.1.201
User root
Note that for example the ping command ignores the Hostname directive in the ~/.ssh/config file, which makes the /etc/hosts file more useful.
With the simplifications noted just above, we can now run for example the cat /proc/cpuinfo command via ssh from the workstation to the PlayStation 2:
$ ssh ps2.local cat /proc/cpuinfo
system type : Sony PlayStation 2
machine : SCPH-37000 L
processor : 0
cpu model : R5900 V3.1
BogoMIPS : 291.58
wait instruction : no
microsecond timers : yes
tlb_entries : 48
extra interrupt vector : yes
hardware watchpoint : no
isa : mips1 mips3
ASEs implemented : toshiba-mmi
shadow register sets : 1
kscratch registers : 0
package : 0
core : 0
VCED exceptions : not available
VCEI exceptions : not available
Copying files via scp on your workstation is a bit involved, due to the fact that Dropbear doesn’t have a built-in sftp-server. However, rather than using scp on your workstation, scp can be used on the PlayStation 2. This requires two additional configuration steps:
- make a symlink
dbclient -> dropbearmultiininitramfs/usr/bin; - generate a key with
dropbearmulti ssh-keygen -t ed25519 -f initramfs/root/.ssh/id_dropbear, and then appendinitramfs/root/.ssh/id_dropbear.pubto your workstation’s~/.ssh/authorized_keys.
Now, try copying on the PlayStation 2:
$ ssh ps2.local
~ # echo 'Hello, from the PlayStation 2!' >/tmp/hello.ps2
~ # scp /tmp/hello.ps2 USER@WS_IP_ADDR:/tmp/
where USER is the username on your workstation, and WS_IP_ADDR is the IP address of your workstation. Copying can be done in the other direction as well:
$ echo 'Hello, from the workstation!' >/tmp/hello.ws
$ ssh ps2.local
~ # scp USER@WS_IP_ADDR:/tmp/hello.ws /tmp/
rsync can be cross-compiled for the PlayStation 2, and easily used from your workstation (as opposed to scp, described above), in either direction:
$ rsync -av /tmp/hello.ws ps2.local:/tmp/
$ rsync -av ps2.local:/tmp/hello.ps2 /tmp/
Note that rsync is a fairly large program. When statically cross-compiled with Musl, it’s about 1 MiB in size.
Tip
If you’ve installed an R5900 cross compiler with Gentoo it’s easy to cross-compile rsync for the PlayStation 2:
# LDFLAGS=-static USE=-xxhash emerge-mipsr5900el-unknown-linux-musl -av net-misc/rsync
The rsync MIPS program file can then be installed for the PlayStation 2. However, due to its large size, about 1 MiB,
it probably won’t fit within the INITRAMFS; if the INITRAMFS is too large, booting the Linux kernel fails. You can still install rsync on a USB memory, which you will have to mount on your PlayStation 2. For example, assuming you’ve mounted a USB memory on your workstation’s /mnt/usb directory, and that you have a /mnt/usb/usr/bin directory on it:
$ file /usr/mipsr5900el-unknown-linux-musl/usr/bin/rsync
rsync: ELF 32-bit LSB executable, MIPS, MIPS-III version 1 (SYSV), statically linked, stripped
$ cp /usr/mipsr5900el-unknown-linux-musl/usr/bin/rsync /mnt/usb/usr/bin/
Wi-Fi for the PlayStation 2 requires a supported USB Wi-Fi adapter. The USB ID 148f:3070 Ralink Technology RT2870/RT3070 Wireless Adapter has been verified to work. It requires
- a firmware file
rt2870.bin, and - a Linux device driver patch to reduce its memory requirements.
Enable the RT2870 driver by editing initramfs/etc/init.d/rcS, adding at the end:
modprobe rt2800usb
Two tools need to be cross-compiled for the PlayStation 2: iw and wpa_supplicant.
Tip
If you’ve installed an R5900 cross compiler with Gentoo it’s easy to cross-compile iw for the PlayStation 2:
# LDFLAGS=-static ACCEPT_KEYWORDS='*' emerge-mipsr5900el-unknown-linux-musl -av net-wireless/iw
The size is fairly large, about 600 KiB. Install the cross-compiled iw program for the PlayStation 2:
$ file /usr/mipsr5900el-unknown-linux-musl/usr/sbin/iw
iw: ELF 32-bit LSB executable, MIPS, MIPS-III version 1 (SYSV), statically linked, stripped
Tip
If you’ve installed an R5900 cross compiler with Gentoo it’s somewhat easy to cross-compile wpa_supplicant for the PlayStation 2:
# LDFLAGS=-static USE='static-libs -asm -quic -ap -fils -mbo -mesh' emerge-mipsr5900el-unknown-linux-musl -av net-wireless/wpa_supplicant
The size is very large, for version 2.11, about 7 MiB. Version 2.6 can be compiled to about 800 KiB, which is almost ten times smaller. Install the cross-compiled wpa_supplicant program for the PlayStation 2:
$ file /usr/mipsr5900el-unknown-linux-musl/usr/sbin/wpa_supplicant
wpa_supplicant: ELF 32-bit LSB executable, MIPS, MIPS-III version 1 (SYSV), statically linked, stripped
On the PlayStation 2, you should now be able to see your Wi-Fi device, using the iw command:
~ # iw dev
phy#0
Interface wlan0
ifindex 3
wdev 0x1
addr xx:xx:xx:xx:xx:xx
type managed
txpower 0.00 dBm
And using the ip command:
~ # ip link show wlan0
3: wlan0: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN qlen 1000
link/ether xx:xx:xx:xx:xx:xx brd ff:ff:ff:ff:ff:ff
Configure the file initramfs/etc/wpa_supplicant.conf by filling in the values for ssid and psk (using the wpa_passphrase tool), similar to:
network={
ssid="My SSID"
proto=WPA2
scan_ssid=1
psk=5235823618236823678213671237923721937213782937981237891237893197
}
The PlayStation 2 can obtain an IP address in several ways. One of the simplest is to configure a fixed IP address, by editing initramfs/etc/init.d/rcS. Assuming your network prefix is 10.0.1.0, and that 10.0.1.202 is a suitable IP address for your PlayStation 2, add at the end:
sleep 5
ip addr add 10.0.1.202/24 dev wlan0
wpa_supplicant -B -c/etc/wpa_supplicant.conf -iwlan0On the PlayStation 2, the wlan0 device should now come up:
~ # ip addr show wlan0
3: wlan0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP qlen 1000
link/ether xx:xx:xx:xx:xx:xx brd ff:ff:ff:ff:ff:ff
inet 10.0.1.202/24 scope global wlan0
valid_lft forever preferred_lft forever
And the wlan0 device should be associated:
~ # dmesg | grep wlan0
wlan0: authenticate with xx:xx:xx:xx:xx:xx
wlan0: send auth to xx:xx:xx:xx:xx:xx (try 1/3)
wlan0: authenticated
wlan0: associate with xx:xx:xx:xx:xx:xx (try 1/3)
wlan0: RX AssocResp from xx:xx:xx:xx:xx:xx (capab=0x1431 status=0 aid=1)
wlan0: associated
wlan0: Limiting TX power to 30 (30 - 0) dBm as advertised by xx:xx:xx:xx:xx:xx
See #19.