-
Notifications
You must be signed in to change notification settings - Fork 10
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_178aThe 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, adding at the end, assuming your network prefix is 10.0.1.0, and that 10.0.1.201 is a suitable IP address for your PlayStation 2:
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_set_addr
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 copied to 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/
See #19.