*DISCLAIMER:* Please read through the post in its entirety before commenting. This is a deep, complex, and long topic. To a Linux expert reading this, I do not claim to be correct in everything that is written here. So if you have an objection, please comment below. To the beginners and intermediate, I hope it gives you greater interest to getting your hands dirty and start researching yourself. I started this post with an Introduction and Background & Theory to give others a better understanding of how the kernel & initramfs operate together. Furthermore, I am not a coder. I am simply a noob who decided to get his hands dirty. Please read the FAQ.
Thanks to the help of @Dr4kk3N and @noob404. From this forum thread: Correct Bluetooth Driver for PS4 Pro CUH-7215B & 7216B, I was able to successfully develop a working kernel and initramfs file combination to activate the Bluetooth drivers for 7215B & 7216B for the Baikal Southbridge chip. I also have a working Bluetooth, Belize kernel for my own Pro 7215B, just waiting on someone else to test it... perhaps I should post that as well.
But the point of this topic is that, in the PS4-Linux community, the main topics of discussion are usually the Kernel and pre-configured Linux distribution. But rarely is the initramfs file ever discussed, so this post serves to give spotlight as to why the initramfs file is so fundamentally important to the Linux OS.
Background & Theory
First, let's define what the initramfs is... the initramfs is an abbreviation for Initial Ram File System. When you boot into Linux, the kernel communicates with the initramfs to initialize the drivers & firmware in the root filesystem of your Linux distribution. This is why the initramfs is important because if the initramfs doesn't contain the necessary drivers to run your PC or PS4... it won't be booted at startup. This explains why PS4-Linux has many functionality issues because the initramfs is missing many necessary drivers & firmware to get a Linux distribution running properly.
Second, let's illustrate what I call the PS4-Linux paradigm:
PS4 Linux Payload ---> Kernel (BzImage) ---> Loader file (kernel configuration) ---> Initramfs ---> Linux OS
- Linux payload sends a signal to the PS4 to activate its BIOS firmware to look for the Linux kernel.
- Kernel activates, and runs its loader file (configuration setup with
menuconfig) to load drivers & firmware
- Initramfs receives commands from loader file and boots the drivers & firmware of the root filesystem
- Linux distribution runs properly with its correct drivers activated from the initramfs
Third, the current PS4-Linux paradigm I defined above is archaic/outdated compared to the modern PC-Linux paradigm. Let me define what I call the modern PC Linux paradigm:
BIOS firmware ---> LinuxDistro.iso ---> Linux OS
Yes... you read that right. You might be scratching your head as to why the kernel or initramfs file is not in the modern PC Linux paradigm. Because the kernel & initramfs are included in the LinuxDistro.iso file... they do not require a separate FAT32 partition and are installed in the same ext4 partition with the Linux Distro. If you look under the directory of your root-filesystem of your distro: "~/lib/firmware" you will see that your Linux distro has all the firmware you PS4 needs... but it is not mounted at boot. Why?
My hypothesis is that, since the current PS4-Linux paradigm has two separate partitions i.e. the FAT32 and ext4 partition... or the kernel/initramfs partition and the Linux Distro partition. The kernel is not able to mount the root file-system of the Linux distro because the root file-system is on the separate ext4 partition with the Linux Distro! This explains why when I added the Bluetooth driver needed for Pro models: 7215B & 7216B to the initramfs, it was able to load the necessary driver because it was on the same FAT32 partition as the kernel.
**As a side-note, some of the areas that are firmware-issue related for the PS4 are, but not limited to: Wi-Fi, Bluetooth, USB-connectivity, Gamepad support, TUN/TAP tunneling, Network related issues.
Now that you have a general understanding of how the kernel & initramfs work together... let's start the tutorial.
You will need to use Noob's VirtualBox tutorial for installing Linux the easy way. This tutorial is going to include ALL the official Linux-firmware from the official Linux-firmware source. The reason why I recommend installing all the official Linux-firmware is that it eliminates the need for you to identify specific drivers for the your PS4 since you're installing all available firmware. ** You will have to change the FAT32 partition from 50MB to 600MB when using gparted so it is large enough to contain your new initramfs.cpio.gz file and custom kernel.**
- Go to a directory you like to use. In this case, I will use the "Documents" directory under my Home folder.
- Create 2 folders. Name them: "initra" and "new initra"
- Copy & paste your initramfs.cpio.gz file you use to boot Linux into your "initra" folder
- Right-click on your "initra" folder, and click "Open-in Terminal"
- In your terminal window, run this command-line:
zcat initramfs.cpio.gz | cpio -idmv. This unpacks the initramfs archive.
- Now in your GUI, go to this directory:
- Cut & paste the folder "amdgpu" for safe keeping somewhere. We don't want this folder to get overwritten.
- In your web browser, click here and download the latest linux firmware tar.gz file. In your terminal window, run:
sudo tar -xvf "/path/to/your/linuxfirmware.tar.gz" -C "/home/noob404/Documents/initra/lib/". This will extract all the firmware to your initra firmware directory.
- Go to where the folder extracted and rename it "firmware". Delete the amdgpu folder inside it and replace it with the older one that you saved.
- In terminal, run:
sudo chown -R noob404.noob404 "/path/to/firmwarefolder/"
- Back in your terminal window, run this command:
find . | cpio -o -c -R root:root | gzip -9 > "/home/noob404/Documents/new initra/initramfs.cpio.gz" Just make sure it has the correct directory of your "new initra" folder
- Your new initramfs file will be created in the "new initra" folder.
- You will now have to build a custom kernel. If you download one of the default kernels, it will not have the necessary support for the drivers you included in your new initramfs file. So you will have to "toggle-on" the support for those drivers through the command-line:
make menuconfig when you build your custom kernel. I will not explain how to build a custom kernel as @noob404 has already covered this topic in great detail. Please read his article here.
- Copy & Paste your new kernel & initramfs to your 600MB FAT32 partition (or wherever they're located), and reboot your PS4.
- Your new drivers should be working and loaded.
Alternative Tutorial | Finding the specific drivers your PS4 needs
Please see sources for more information on this.
If you don't want to install all available Linux firmware, personally I think it's the best method, then you can find specific drivers.
- Doing this is difficult, but it's possible. You will need to use the commands:
- In your terminal,
install lshw in case you don't have this application. Then run:
- The terminal will now list all of your peripherals and will list driver information under each peripheral.
- You can also use the
lspci command. However,
lshw (means list hardware) will list ALL of your hardware peripherals for your PS4.
- Once you have located the drivers you want for your PS4, simply follow the same instructions in the original tutorial the difference is that you can keep your 50MB partition.
Research & Development for the Future of PS4/5 Linux
1. Official PS4/5 support under the Linux Kernel.
Let me explain why this might be more possible than what others might think. First, we all know that in order to run Linux on a PS4... you need a jailbroken PS4. There is some debate that under the DCMA copyright law of the United States that tempering with a console's OEM (Original Engineering Manufacturer) firmware is illegal. This will require further research, but there might be a caveat that it is only illegal if the intent is to redistribute or resell the OEM firmware of the console. Furthermore, people will incorrectly assume that jailbroken PS4 = piracy of PS4 Games. According to the subject of descriptive statistics, correlation does not equal causation. There are many homebrew applications that are free, and Linux itself is open-source. Meaning that it is perfectly legal to redistribute Linux. What I'm saying is that if the PS4 is able to get official support under the Linux kernel, then essentially all of the problems of PS4 Linux will be a thing of the past. This will also include the Mesa drivers for the PS4/5 to be officially supported as well.
2. Update the partition size from 50MB to 600MB in the command scripts for the initramfs.cpio.gz
This will require the init and functions scripts of the initramfs file to change the FAT32 partition from 50MB to 600MB. Doing this will require someone with knowledge in the C-programming language. It might be one or two simple commands-lines. Making these corrections will allow PS4 Linux users to install PS4-Linux from the Rescue Shell instead of having to rely on the VirtualBox method.
3. Update the code for the PS4-Linux payloads to mount a Linux.iso file
This might be unnecessary since I have heard of people running ".iso" files instead of the standard ".tar.gz" system. But the goal of this is to be able to include both the kernel & initramfs in the .iso file so it doesn't require a separate partition to run. This will require someone who has great knowledge in the C-programming language. If we are able to replace the old PS4-Linux paradigm for the modern PC Linux paradigm, then in theory... all linux distributions that run on PC will be able to run on the PS4. Furthermore, creating custom initramfs.cpio.gz & kernel files will be a thing of the past, since it will be included directly in the ".iso" file. All someone would have to do to install PS4-Linux is to flash a “.iso” file to an external drive of their choice, or include it in the /boot/ directory of their internal PS4 HDD.
Why Bother Looking into the Research & Development Topics when I can just run Linux on a PC?
If you have the money for a modern PC, then certainly nobody is going to stop you. Unfortunately, as inflation surges... it is becoming increasingly uncommon for people to be able to afford a PC. Most PS4s sell between $250 to $500 (U.S. Dollars), which is a fraction of the cost for a mid-tier gaming PC - usually around the $2,500 mark. PS4 Linux is already running fairly well, but implementing the above changes means a comparable experience of PS4 Linux to PC Linux.
5.15.xx Broken Bluetooth Commit
Building an initramfs. Device Tree
BuildRoot Initramfs Tool
Identifying Device Drivers.
Official Linux-Firmware Page
Will you create a GitHub page?
Nothing in this post is relevant to GitHub except the PS4-Linux kernel sources.
I will in the future. Just not now as I have limited coding experience.
Can you help me build a custom kernel?
Noob's article on how to build a custom kernel contains everything that is necessary to build a custom kernel.
So the answer is no. Use Google, that's what I had to do.
What can we expect from the Research & Development section suggested in this article?
The answer is that will be up to the sum of the determination and motivation of the people who read it.
We can also expect that if those ideas come to fruition, then we can expect a much more enjoyable experience with PS4-Linux. As for me, I do plan to look into those topics in the near future because I find it enjoyable and want to make a living as a software engineer.
Can I just make my own custom drivers for PS4?
If you have the capability to write your own custom driver for Bluetooth or Wi-Fi then I don't understand why you're wasting your time on this forum. You should be applying to $200k/yr Senior Software Engineer positions at Apple or Google. I hope you realize that there are entire software engineering teams dedicated to such a cause because of how difficult that is. But hey, if you prove me wrong then so be it.
Your commands for the tutorial are in Fedora, can you help me figure out what different commands I should use?
You probably only need to use "Su" instead of "Sudo." But no, I won't help you with this. Use Google.