With current generation consoles still being hard to come by, even a year after launch, game streaming services have become quite popular. For a few dollars per month we can stream a curated library of games to our laptops, desktops and mobile devices.
With the recent release of Raspberry Pi OS, based upon Debian 11 “Bullseye” we find that the Chromium web browser now supports hardware acceleration and this means that we can finally use streaming games services with the Raspberry Pi 4.
In this how-to, we shall set up a fresh Raspberry Pi OS Bullseye install, overclock our Raspberry Pi 4 to 2 GHz and finally we will automate the process, turning our Raspberry Pi into a 1080p games console.
For This Project You Will Need
- Raspberry Pi 4 4GB
- 16GB Micro SD card
- Keyboard, mouse and 1080p screen for your Raspberry Pi
- Ethernet Internet connection
- Cooling for your Raspberry Pi 4. We used Pimoroni’s Fan Shim but passive cooling would be best.
- Xbox Game Pass Platinum
- An Xbox Controller
Installing Raspberry Pi OS Bullseye on Your Raspberry Pi 4
We start the process by installing the latest version of Raspberry Pi OS onto a fresh micro SD card.
1. Download, install and run Raspberry Pi Imager.
2. Click the Choose OS button. A menu appears.
3. Select Raspberry Pi OS (32-bit) from the OS menu.
4. Click Choose Storage and select your card from the menu.
5. Click Write. This process will take several minutes as Raspberry Pi Imager downloads Raspberry Pi OS and burns it to your microSD card.
6. Remove the SD card and place it into your Raspberry Pi and then boot to the desktop.
7. Open a terminal and update the software on your Raspberry Pi.
$ sudo apt update $ sudo apt upgrade -y
Overclock your Raspberry Pi 4
To ensure that you get the best performance, overclock your Raspberry Pi 4 to 2 GHz. It is easy to do, and gives you a free performance boost. Ensure that you have adequate cooling for your Raspberry Pi 4.
1. Power off your Raspberry Pi and attach your cooling option if it’s not already there. Boot up.
2. Open a terminal and use this command to open the config.txt file.
$ sudo nano /boot/config.txt
3. Scroll to the bottom of the file and make a new line. This will be a comment, used to identify what the code under it will do.
#Overclock to 2 GHz
4. Use these settings to set the overclock. Press CTRL + X, then press Y and Enter to save and exit.
arm_freq=2000 gpu_freq=750 over_voltage=6 force_turbo=1
5. Reboot your Raspberry Pi for the changes to take effect.
Running Xbox Cloud Gaming (Beta) on Raspberry Pi 4
This is truly the easy part! The latest version of Chromium (v92) which ships with Raspberry Pi OS “Bullseye” comes with hardware acceleration baked in. This means YouTube video playback is much smoother than previous, and more importantly our games play better than ever.
1. Plug your Xbox controller into a spare USB port. At this time, Raspberry Pi OS cannot use the controller via Bluetooth.
2. Click on the browser icon to open a new browser window.
3. Go to https://xbox.com and sign in to your account. If prompted to save your login details, do so as later we will automate a large part of this process.
4. Click on Play to start the Cloud Gaming service.
5. Using the controller, select a game and start playing.
Automatically Starting Xbox Cloud Gaming on Boot
Playing games should be fun, so plugging in a keyboard, mouse etc just to login each time is a chore. What if we automated the process? In the previous section, we asked the browser to remember our login details, so now let's have the browser open as soon as the Raspberry Pi desktop starts.
1. Open a terminal window and create a file called xbox.sh. This file in your home directory (/home/pi) will store all of the steps necessary to run the gaming service.
$ nano xbox.sh
2. Add a line that tells the system what language we are using, in this case a Bash script. Add a second line to force the system to pause for five seconds before moving on.
#!/bin/bash sleep 5
3. Use xrandr to force the display to use a 1080p resolution. This is a tweak that will override a bug in Raspberry Pi OS Bullseye which forces the default resolution to match the display. For users with 4K displays, this is an essential step.
xrandr -s 1920x1080
4. Add the final line, which is the command to be executed. In this case it opens Chromium in fullscreen, and goes directly to the xbox.com play site (in our case the en-GB site for the UK, but change this to the URL for your region). The last part of the line is “&” and this tells Linux to run the command in the background.
Exec=chromium-browser --start-fullscreen https://xbox.com/en-GB/play &
5. Press CTRL + X, then press Y and Enter to save and exit.
6. Convert xbox.sh into an executable file.
chmod +x xbox.sh
7. In the terminal, create a file called xbox.desktop which will run when the desktop starts.
$ sudo nano /etc/xdg/autostart/xbox.desktop
8. Create two lines inside the file. The first is a description of the file. The second line is the command to be executed. In this case, it will call the Bash script that we have just written.
[Desktop Entry] Exec=/home/pi/xbox.sh
10. Press CTRL + X, then press Y and Enter to save and exit.
11. Reboot your Raspberry Pi for the changes to take effect.
Your Raspberry Pi 4 will now boot straight into the Xbox Cloud Gaming service, and you are ready to game!
To exit a game via the controller, press the Xbox logo and select Quit game.