Last active
February 16, 2022 20:49
-
-
Save donluca/9f05387b9321a3ae4fd98360ef1edded to your computer and use it in GitHub Desktop.
How to install Debian on the Playstation Classic
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Version 0.02 | |
Changelog: | |
Version 0.01: initial commit, install Debian and get a working environment | |
Version 0.02: more information on the install process and added a new section to get a desktop environment going (LXQT) | |
What you need: | |
• A modded PSClassic with Project Eris, the current limitation on the USB ports removed | |
( https://modmyclassic.com/wiki/index.php?title=PlayStation_Classic#USB_Current_Limiting ) OR a *good* powered USB | |
hub, two solder pads on the mainboard bridged to enable serial access, a working and configured USB networking card. | |
(if you don't know what I'm talking about, then you should not be doing this) | |
• A (little more than) basic knowledge of how Linux works and how to configure it | |
• Access to the command line shell of the PSC via either serial port (you have to solder it) or SSH (you need networking, | |
ie: a USB network dongle) | |
• The 15GB partition holding your games (it will be gone and used for Linux) | |
• A supported USB network card (wired, for the ease of configuration, or wireless) already working in your Project Eris | |
setup (make a note of the interface name: ifconfig -a) and, eventually, the needed drivers/modules/firmware to make | |
them work | |
• A PC or VM with a Debian based distro installed (Debian, Ubuntu, Pop_OS!, etc...) | |
• A way to transfer files from your host machine to the PSC (I use networking and rsync, but you can use a usb pen drive | |
as well, although not as convenient. If you go this route, always make sure to tar/archive/zip whatever you want to | |
transfer to not lose file permissions and extended attributes) | |
• ...or you can get creative and do without most of this by using lolhax and a well prepared usb pen drive with scripts | |
to do everything. | |
Setup the chroot on your host PC: | |
• Install debootstrap and qemu-user-static on your Debian system: | |
apt install debootstrap qemu-user-static | |
• Open a terminal and become root: | |
sudo -s | |
• Create an empty folder for the chroot of your PSC Linux | |
(ex.: mkdir PSCDebian – we'll be using this as a reference throughout the guide) | |
• Enter the folder you've just created: | |
cd PSCDebian | |
• Start debootstrap: | |
debootstrap --arch=armhf --foreign <version> . | |
• <version> can be any version you like from either Debian or Ubuntu. In this guide, I recommend using Debian, so you can | |
use, for example, buster, bullseye or, if you feel adventurous, sid | |
• Copy the qemu binary to the chroot: | |
cp /usr/bin/qemu-arm-static usr/bin | |
• Enter the chroot: | |
chroot . /bin/bash | |
• Now you have to start the second phase of debootstrap to complete the creation of the chroot and its initial | |
configuration: | |
/debootstrap/debootstrap --second-stage | |
• When it has finished, set the password for the root user: | |
passwd | |
• Set the hostname: | |
echo "nameOfYourChoice" > /etc/hostname | |
• Install a text editor (so you don't end up embarrassing yourself by googling "how do I get out of vi" later): | |
apt install nano | |
• Relevant keyboard shortcuts of nano are: Control+o = save; Control+x = exit; Control+w = search for a word | |
• Configure fstab: | |
nano /etc/fstab | |
• Delete whatever it's in there and add: | |
none /tmp tmpfs defaults,noatime,mode=1777 0 0 | |
/dev/mmcblk0p9 / ext4 defaults 0 1 | |
proc /proc proc defaults 0 0 | |
devpts /dev/pts devpts gid=4,mode=620 0 0 | |
shm /dev/shm tmpfs defaults 0 0 | |
• Enable serial console (if something goes wrong, at least you won't get locked out): | |
systemctl enable [email protected] | |
• Install and enable OpenSSH: | |
apt install openssh-server | |
• Configure OpenSSH to accept root login: | |
nano /etc/ssh/sshd_config | |
• Look for the line with "PermitRootLogin" and change it to "PermitRootLogin yes" | |
• Now you have to configure your ethernet interface. This configuration will use DHCP to automatically retrieve all | |
the parameters (ip, gateway, dns, etc.) from your router: | |
nano /etc/network/interfaces | |
• At the end of the file add: | |
auto lo eth0 | |
allow-hotplug eth0 | |
iface lo inet loopback | |
iface eth0 inet dhcp | |
where "eth0" is the name of your usb interface, so change it accordingly. Please note that Sony, in their infinite | |
wisdom, decided to compile the kernel with a flag that changes the classic ethX naming convention to monstrosities | |
like enx0000e80005ac. So don't give for granted that you can just put eth0 and call it a day. Actually, quite the | |
opposite. | |
• Add more repositories to apt: | |
nano /etc/apt/sources.list | |
• Delete whatever is in there and add the following: | |
deb http://deb.debian.org/debian/ <version> main contrib non-free | |
deb-src http://deb.debian.org/debian/ <version> main contrib non-free | |
deb http://deb.debian.org/debian/ <version>-updates main contrib non-free | |
deb-src http://deb.debian.org/debian/ <version>-updates main contrib non-free | |
deb http://deb.debian.org/debian-security/ <version>/updates main contrib non-free | |
deb-src http://deb.debian.org/debian-security/ <version>/updates main contrib non-free | |
where <version> is the version you chose before. Remember that sid has security packages by default, so you don't need | |
to specify them. | |
• Update apt: | |
apt update | |
• Just to make our lives even more miserable, whoever compiled the kernel decided to enable the ANDROID_PARANOID_NETWORKING | |
flag, which means you'll have to do some modifications to group and user permissions to use networking: | |
nano /etc/group | |
• Scroll to the end and add the following: | |
inet:x:3003:root | |
net_raw:x:3004:root | |
• Run the following commands to make those users part of the groups we just created: | |
usermod -g 3003 _apt | |
usermod -g 3003 systemd-network | |
usermod -g 3003 systemd-resolve | |
• The PSClassic doesn't have an RTC (Real Time Clock) so you'll have to use an NTP service to keep your time synchronized | |
with the internet otherwise you'll end up with a myriad of issues (mainly due to SSL): | |
apt install ntp | |
usermod -g 3003 ntp | |
systemctl enable ntp | |
• Create the needed directory structure for the custom modules you're going to need (ie: network card drivers): | |
mkdir -p /lib/modules/4.4.22 | |
cd /lib/modules/4.4.22 | |
touch modules.builtin | |
touch modules.order | |
• Copy all your modules to this folder: | |
cp -va <source of your modules> /lib/modules/4.4.22 | |
where <source of your modules> is the directory with the needed modules | |
• Double check everything as you won't have a second chance once you've transferred the chroot over to your PSC and made | |
the necessary change to the kernel command line options | |
• Exit the chroot: | |
exit | |
• Delete the qemu binary: | |
rm usr/bin/qemu-arm-static | |
• Leave this terminal open and don't touch anything else, we're going to get back here later. | |
Setup the PSC: | |
• Ideally you have access to a command line shell on your PSC either via serial port or SSH. | |
• Login as root | |
• Unmount the 15GB partition with the games: | |
umount -f /dev/mmcblk0p9 | |
• Format to EXT4 the partition, make sure to have a backup because this is irreversible: | |
mkfs.ext4 /dev/mmcblk0p9 | |
• Remount the root filesystem as writeable: | |
mount -o remount,rw / | |
• Create a new mountpoint for the partition: | |
mkdir /mnt/newfs | |
• Mount the empty partition: | |
mount /dev/mmcblk0p9 /mnt/newfs | |
• Get a statically linked rsync binary: | |
cd /usr/bin | |
wget http://github.com/JBBgameich/rsync-static/releases/download/continuous/rsync-arm | |
mv rsync-arm rsync | |
chmod +x rsync | |
• Change directory to the new filesystem: | |
cd /mnt/newfs | |
• Make a backup of your current kernel: | |
dd if=/dev/mmcblk0p1 of=old.img | |
• Make a copy of it which we're going to modify to boot the new system: | |
cp -va old.img new.img | |
• Make the modification: | |
sed -i 's/mmcblk0p7/mmcblk0p9/' new.img | |
• Now leave everything as is on the PSC and get back to your host PC | |
Transfer the chroot over to the PSC: | |
• There are several ways to do this, you can use scp to transfer the files over networking via ssh to your PSC, you | |
can use rsync over networking or you can zip the chroot with something like tar (or anything else that preserves | |
permissions, attributes, etc.), copy it over a usb pen drive, connect it to your PSC and unzip the archive over | |
to your empty partition. This is up entirely to you, in this guide, as stated before, we're going to use rsync. | |
• On the terminal you've left open on your host PC in the previous steps start the transfer: | |
rsync -av . <PSC IP>:/mnt/newfs | |
where <PSC IP> is the IP of your PSC (ie: 192.168.1.70) | |
• When it's done, it's time to get back to the PSC | |
Final tests before the fireworks: | |
• Now you have to chroot into your new system to initialize the modules you've copied before and, generally speaking | |
to make sure everything has been done correctly so far: | |
chroot /mnt/newfs /bin/bash | |
• Initialize the modules cache and load the modules: | |
depmod -a | |
modprobe <name of your module> | |
where <name of your module> is the name of the module you need to load WITHOUT the .ko extension | |
(ex: pegasus.ko -> modprobe pegasus) | |
• Mess around a bit, maybe try doing something like an apt update to see if everything works. Remember that you're | |
inside a chroot, you've not booted into your new system, so this is just a sanity check to make sure you haven't | |
done something horribly wrong. | |
• When you're done, exit the chroot: | |
exit | |
• It's time to write the new kernel and reboot: | |
dd if=/mnt/newfs/new.img of=/dev/mmcblk0p1 | |
• Reboot your system and cross your fingers: | |
reboot | |
• If it is stuck on the reboot process (ie: PSC hasn't turned off), you can just remove power from your PSC and plug | |
it in again | |
• Finally, if everything is ok you should now have Debian booted and you can login with the credentials root and the | |
password you chose before | |
• Needless to say, you won't have any output via HDMI, so I hope you have your serial port connected or you've | |
configured your network properly | |
• If you messed up... there's still hope. You can either use fastboot to flash the old kernel or do it blindly | |
• Connect a keyboard to one of the USB ports | |
• Now you have to be REALLY careful because you'll be putting in commands blindly, so every key stroke counts, remember | |
that the keyboard layout is US | |
• Input your login credentials: | |
root | |
enter | |
password | |
enter | |
• You should now be in a command shell | |
• Write back the old kernel: | |
dd if=/old.img of=/dev/mmcblk0p1 | |
enter | |
• Wait a minute, then reboot: | |
reboot | |
• It might get stuck on the reboot process, so if after a minute nothing happens, unplug the PSC from power and plug | |
it again | |
• You should now have the stock OS booting | |
Graphical user interface, video acceleration and all that jazz: | |
...so you've chosen death. | |
Before you lays a desolate wasteland where desperation, hopelessness and anger awaits. | |
It might seem at some point that you're close to a solution, you start seeing the light at the end of the tunnel, | |
just to realize a few seconds later that it's a train running at full steam towards you. | |
The last thing you see before everything goes back to black is the plate mounted in front of the locomotive with | |
two words etched on it: | |
SEGMENTATION FAULT | |
You still here? Well then, there are several ways to have a nice desktop environment up and running but all of them are | |
broken in some ways or another. | |
The easiest and most stable way is using Xorg but be warned: you won't have any kind of graphical acceleration, so | |
everything will be a bit sluggish. | |
This guide will use the LXQT desktop enviroment because it is has more or less everything and is very n00b friendly. | |
• Login to your PSC. Needless to say, you'll need an internet connection. | |
• You're going to need some stuff from the stock OS, so let's mount the old system: | |
mkdir /mnt/oldroot | |
mount /dev/mmcblk0p7 /mnt/oldroot | |
• Now let's fetch the firmware file to make the graphic card work: | |
cp -va /mnt/oldroot/lib/firmware /lib | |
• Let's install LXQT: | |
tasksel install lxqt-desktop --new-install | |
• This is going to take a while, at some point it might seem that everything has frozen, but it is still working | |
• In my case, after 15 minutes I realized I've lost connection to the PSC because, for some unfathomable reason, | |
it decided to change IP. If that's the case, try to SSH in again with the new IP (ask your router). If you are | |
using the serial console you shouldn't have any issues. | |
• Now we need to create a custom configuration for Xorg: | |
nano /usr/share/X11/xorg.conf.d/10-pvr.conf | |
• Add the following: | |
Section "Device" | |
Identifier "pvr" | |
Driver "modesetting" | |
Option "AccelMethod" "EXA" | |
EndSection | |
• Now plug an HDMI cable in your PSC, connect it to a full HD monitor and run the following: | |
pkill x | |
rm /dev/dri/card1 | |
startx | |
• You should now be in LXQT, you can go into the settings and change the resolution to whatever you like, up to 1080p | |
• The reason for connecting your PSC to a fullHD monitor is that Xorg will try to read the EDID and set the maximum | |
resolution supported by your monitor. So if you have a 1920x1200 monitor, it will set that res and you'll end up | |
with a garbled screen. Same with a 4k monitor. | |
• Sound works through ALSA (and possibly PulseAudio, Pipewire, etc.) but you need a modification to make it work: | |
nano /usr/share/alsa/alsa.conf | |
• At the end of the file add: | |
pcm.asymed { | |
type asym | |
capture.pcm{ | |
type plug | |
slave.pcm "hw:0,1" | |
} | |
playback.pcm "hw:0,2" | |
} | |
pcm.!default { | |
type plug | |
slave.pcm asymed | |
} | |
• Restart the ALSA service: | |
/etc/init.d/alsa-utils restart | |
• Some more steps might be needed in order to have PulseAudio working under LXQT, but that's for another day. | |
• Last steps now, we need to disable SDDM from autostarting and messing things up: | |
systemctl disable sddm | |
• Finally, let's create a script to start our hacky LXQT session: | |
nano /usr/bin/startlxqt.sh | |
• Add: | |
#!/bin/bash | |
rm /dev/dri/card1 | |
startx | |
• Make it executable: | |
chmod +x /usr/bin/startlqxt.sh | |
• And done. Everytime you reboot, you can just write startlqxt.sh to start the graphical environment. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment