A few months ago, I was able to release the WiFi and Bluetooth drivers for Mediatek MT7668 for PS4, thanks to the sponsorship provided by novice4321. Since then, there has been a lot of demand to make the source code public. But, I needed some more time to work on cleaning up the code for better public consumption. But, in the past two weeks, I have been working on-and-off on finally cleaning up the code and open-sourcing my edit of the drivers. And, here we are.
In this article, I will explain, how my edition of the source code can be utilised by anyone. Doesn’t matter if you are trying to build the MT7668 drivers for PS4 or for any other Android box, this article will help you get started.
UPDATE 1 (28 August, 2023) – Latest kernels with inbuilt MT7668 WiFi & Bluetooth.
UPDATE 2 (18th January, 2024) – Fix for DNS issues on MT7668 kernels.
UPDATE 3 (20th June, 2024) – PS4 Baikal & Belize Kernels with MT7668 (incl. DNS fix) and VPN support opensourced.
Without further ado, let’s begin with the requirements.
Requirements
- PC/VM running Linux (currently, Ubuntu/Fedora)
- PS4 or Android Box with MT7668 (Check if you have MT7668 here)
- Source Code on GitHub
- Kernel source (For PS4, check here)
Those are the basic requirements. As for now, the source code has been tested on kernel 5.4.213 for PS4. But, in the current state, it should work for other 5.4.x kernels too. As for the newer kernels, the source code might require reworking. I will try my best to help. Leave a comment below.
Now, let’s get into the compilation and installation process itself. This tutorial itself will be divided into multiple parts, but mainly into two. In the first part, we will see how the driver module itself is compiled. And, in the second part, we will see how we can use the module on another device with the MT7668 chipset, for example, PS4, Android boxes, etc.
Compile MT7668 WiFi & Bluetooth drivers for Linux
Let’s go through the compilation process step-by-step.
Step 1. Preparing Linux for driver module compilation
For now, we will see how the driver can be compiled and used on an Ubuntu/Fedora-based distro. To compile the kernel, we need some applications. These are the steps required to install them.
- On Ubuntu or Ubuntu-based distros:-
- Open a terminal and run
sudo apt install build-essential
- Open a terminal and run
- On Fedora or Fedora-based distros:-
- Open a terminal and run
sudo dnf install @development-tools gcc g++ ncurses
- Open a terminal and run
Once that’s done, let’s jump into the kernel-headers building process.
Step 2. Compile and install kernel-headers
- Download the kernel target source and extract it to a suitable folder or clone it into a suitable folder.
- Check if a config file exists. If yes, open the config file,
CONFIG_LOCALVERSION
is set to nothing, i.e., it says,CONFIG_LOCALVERSION=""
. Once confirmed, save the config file and exit. - Open a terminal in the kernel source folder.
- On Ubuntu or Ubuntu-based distros:-
- Run
make -j5 deb-pkg
. - Once complete, check the terminal for the location of the .deb files, named linux-headers… and linux-image… Copy those .deb files to a suitable location.
- Run
- On Fedora or Fedora-based distros:-
- Run
make -j5 rpm-pkg
. - Once complete, check the terminal for the location of the .rpm files, named kernel… and kernel-devel… and kernel-headers… Copy those .rpm files to a suitable location.
- Run
- On Ubuntu or Ubuntu-based distros:-
- Copy the bzImage within the arch/x86/boot folder to somewhere safe.
- Install the kernel header files.
- On Ubuntu or Ubuntu-based distros:-
- Open a terminal in the folder containing .deb files that we created in the previous step.
- Run
sudo dpkg -i *.deb
and wait for them to install.
- On Fedora or Fedora-based distros:-
- Open a terminal in the folder containing .rpm files that we created in the previous step.
- Run
sudo rpm -i --nodeps --force *.rpm
and wait for them to install.
- On Ubuntu or Ubuntu-based distros:-
Just to be sure that the kernel-related files have been properly installed, check /usr/lib/modules and /usr/src folders. You should find folder pertaining to your kernel version.
Step 3. Compile MT7668 WiFi and Bluetooth drivers
- Clone the driver source code to a suitable folder by running
git clone https://github.com/noob404yt/mt7668-wifi-bt
. - Go into the folder and open the text file, Makefile.x86 within the folder MT7668-WiFi. Replace kernel_version at top with your kernel version’s folder, for eg.-
5.4.213+
. To confirm, on your PC/VM, go into the folder /lib/modules to find the exact folder name. Make the same replacement in Makefile within the folder MT7668-Bluetooth. - To build the WiFi driver, open a terminal in the folder, MT7668-WiFi and run
make EXTRA_CFLAGS="-w" CROSS_COMPILE= -f Makefile.x86
. You will find the compiled module named wlan_mt76x8.ko within MT7668-WiFi/drv_wlan/MT6632/wlan. Copy it somewhere safe.
- To build the Bluetooth driver, open a terminal in the folder, MT7668-Bluetooth and run
make
. You will find the compiled module named bt_mt7668.ko within MT7668-Bluetooth. Copy it somewhere safe.
That’s it! That’s how you can compile WiFi and Bluetooth driver modules for MT7668. Now, let’s see how we can use the compiled modules on our target system.
Install MT7668 WiFi & Bluetooth drivers on Linux (PS4, Android Boxes, etc.)
Step 1. Preparing target system for driver module installation
- Boot the target system (PS4, Android Box, etc.) with the compiled kernel (bzImage), that we had copied in Step 2.4.
- Install the kernel header files built in Step 2.3 on the target system.
- On Ubuntu or Ubuntu-based distros:-
- Open a terminal in the folder containing .deb files that we created in the previous step.
- Run
sudo dpkg -i *.deb
and wait for them to install.
- On Fedora or Fedora-based distros:-
- Open a terminal in the folder containing .rpm files that we created in the previous step.
- Run
sudo rpm -i --nodeps --force *.rpm
and wait for them to install.
- On Ubuntu or Ubuntu-based distros:-
- Go back to the driver source code on GitHub and copy every file in MT7668-WiFi/7668_firmware to /usr/lib/firmware on the target system.
That prepares the system to accept the WiFi and Bluetooth driver modules that we built in Step 3.
Step 2. Install MT7668 WiFi and Bluetooth driver modules
- To temporarily load the modules without restart:-
- Open a terminal within the folder containing the modules (.ko).
- Run these commands one-by-one:-
sudo insmod bt_mt7668.ko
sudo insmod wlan_mt76x8.ko
- You should have both Bluetooth and WiFi running now.
- To automatically load modules on every boot:-
- Copy the modules (.ko) to /usr/lib/modules/kernel_version folder.
- Open a terminal anywhere and run these commands one-by-one:-
echo "bt_mt7668" | sudo tee -a /etc/modules
echo "wlan_mt76x8" | sudo tee -a /etc/modules
sudo depmod -a
- Reboot and there shall be WiFi and Bluetooth.
That’s it, guys!
Troubleshooting
This section will be updated with your comments and solutions.
Conclusion
Before concluding, I’d like to thank everyone that made this project possible, mainly novice4321 (sponsor) and other donors and testers including Reo Au In. Special thanks to Khadas’ repo, on which the source code is based.
As for the future of this project, please do understand that this is only one method of doing this. With a little more work, especially for the PS4, we could incorporate the module into the kernel as a driver, instead of being loaded as a module. I am led to believe that many capable members and devs within the PS4 community itself are working on this, as we speak and have had successes much before my work went open-source. I hope that this article will help them and everyone else. Anyways, I’ll keep updating you guys with the latest information on the PS4 Linux scene. Stay tuned!
h ./scripts/package/mkspec >./kernel.spec
TAR kernel-5.4.213+.tar.gz
rpmbuild –target x86_64 -ta kernel-5.4.213+.tar.gz \
–define=’_smp_mflags %{nil}’
make[1]: rpmbuild: No such file or directory
make[1]: *** [scripts/Makefile.package:59: rpm-pkg] Error 127
make: *** [Makefile:1472: rpm-pkg] Error 2
got this error when running make -j5 rpm-pkg
Try running
sudo dnf install rpmdevtools
and try again.Hello, I want to impement your driver into CoreELEC.
But when I execute “make -j5 deb-pkg”, I only get this error in return:
make: *** No rule to make target ‘deb-pkg’. Stop.
Am I doing something wrong? Would be great if you could help me with that issue! Thanks!
You are probably using a kernel source that doesn’t support deb-pkg.
I see. Is it even possible to implement your drivers on Linux 4.9.260 aarch64? I’m using EmuELEC (https://github.com/EmuELEC/EmuELEC) on an android tv-box (A95x_f2) and unfortunately the box has the MT-7668-chip. WiFi is working, but bluetooth isn’t.
Would be great if you could answer me that question! Sorry for being a little noobish, I’m trying my best learning about Linux, but it’s not that simple….Thank you.
You will have to downgrade some functions in the drivers for 4.9. On PS4, it was built for 4.19.
Sorry, EmuELEC 4.6. uses Linux 4.9.269
Thank you for your answer. I brought the issue to the EmuELEC-developers and he was able to implement the PS4-patch and now it’s working, thanks to your effort. Keep up the good work! All the best!
Good to know. Good luck.
Very Nice, greate job !!! Thanks you for sharing your sources
The latest inbuilt kernel drivers have been shared here.