How to Compile HiFi for the Pi

Compiling High Fidelity on the Raspberry Pi Model B v2 is surprisingly not too difficult. The biggest thing that will take up your time is compiling QT5 (5.3.2 specifically, since as of writing, this is the minimal version you need). Compiling 5.4.1 gets ‘close’ to working but doesn’t compile QtWebkit properly, which is required for building High Fidelity in the first place! After some tinkering around in my free time, I finally was able to get a build working, but only after experimenting with what did work and did not. Let my mistakes be your knowledge.

First of all, a few things to note about the ‘Pi’ edition of Hifi.

  • Only the domain-server and assignment-clients have been tested. Compile the interface as your own experimentation.
  • Odd things happen in the Pi build and this list may not name all the oddities. Welcome the world of experimental builds!
  • User creation with cubes, spheres, and other non-mesh items seem to be hit and miss. Sometimes they work, other times, they do not. I can conclude that the issues lie with the Pi build assignment-clients.
  • Objects made by scripts seem to work. Same with marketplace called items. Go figure.
  • Just like the standard linux build, there is no ability to get a free place-name like you can with the Stack Manager.
  • My prior build caused the nodes to become self disabled. I’m not sure why that happened or if there was a fix from the time I began the compiling attempts to the current success. If someone out there fixed this bug due to it being an actual bug in the software, thank you!
  • As of the time of writing, the latest Stack manager build is build 70. That is my only reference with the versioning at this time. If you need something more specific, the Interface build was 2993 when I had to update.

What you will need:

  • Raspberry Pi 2 Model B (Versions 1.x will not work!)
  • At least 8GB MicroSD card (16GB+ recommended)
  • Power supply for the Pi (a tablet charger should work fine)
  • Monitor with HDMI support (TVs are okay)
  • A USB Keyboard
  • Ethernet (If you decide to use WiFi, you are on your own)

Files you will need:

With all that out-of-the-way, let’s begin the actual build:

Step 1: Setup the Pi 2

For this tutorial, you will need a Raspberry Pi 2 Model B. The quad cores, 1GB of ram, and armv7 architecture is just what we need to get HiFi working, since the Intel Threading Building Blocks (TBB) minimally work with that processor type. I’m not going to walk you through how to burn an image onto the Pi’s SD card or how to power it all up, as there are thousands of YouTube videos and other written tutorials that can explain the process 100x better than I can. You will also need a screen with HDMI support and a USB keyboard initially, since the image you will be downloading does NOT have SSH enabled by default.

The image we will be using has Ubuntu 14.04 (Trusty), which means that the tutorial on HiFi’s documentation area can be followed almost completely (more on that later). So go ahead and download the image here and burn it to your microSD card. Once that is done, hook up all the Pi’s components expect power. Insert the microSD into the Pi and supply power. The boot up time is very short as this build of Ubuntu is a minimal setup, which will help us out immensely.

Once you are at the login prompt (and everything else is working fine), go ahead and log in (default credentials are ‘ubuntu’ as the username and ‘ubuntu’ as the password). The first thing we are going to do is install two critical things: screen and openssh. This is so that we can unplug the monitor and keyboard so the Pi can run “headless” (without a monitor and keyboard) for a more optimal operation.

First, we need to set up the root’s password so we can just log in with ‘su’. To do this, type in:

{follow the instructions to set the root’s password}

After that, install openssh and screen by typing in the following:

With openssh, we can connect using an ssh client from our desktop and operate the Pi remotely, and screen is so we can safely compile things in the future in the event something severs the connection. At this point, you can shutdown the Pi and, if you want to take the extra time to do so, backup your current image to your desktop. This is so you have a pre-built image that has ssh set up and in the event of failure (this has happened to me twice. Learn from my mistakes!). You now have the option to open up an ssh session with your favorite program (PuTTY for Windows, though I am slowly beginning to like MobaXterm), or you can continue using the Pi plugged in with the keyboard and monitor (if you are into that kind of thing).

From this point on, we will need to set up the file storage since this is not setup by default. Because we do not have raspi-config (for veteran Pi users), we will have to do this manually with fdisk. This part of the tutorial is straight from the Ubuntu wiki for the Raspberry Pi.

Once you have the system rebooted, type in the last command:

At this point, your Pi’s file system is now completely ready! For further information regarding what we did, you can read it from Ubuntu’s documentation.

Step 2: Compile QT5.3.2

Time for the gauntlet round! This part will mostly involve waiting for downloading and compiling. The compiling process took me about 3-4 hours, but you do not need to observe the process as regularly.

First, we will save ourselves from failure by making a swap file. This is just for the compiling process, as a swap file on a flash card is not advisable for any system! While the Pi has plenty of power to compile, when we are using all the cores, the 1GB of ram isn’t enough. For this reason, we will make a 2GB swap file, which should be more than enough to ensure the compiling process has enough memory to work with.

After that, we will now have 2GB of swap space to do the building with. Once we are finished, we can turn it off to conserve the lifespan of the SD card.

Now we need to grab the QT source code, which we can grab from their website.

Now we need to begin the giant apt-get.

Now we run into a small problem. We will need to set up the X11 development dependencies, but they will try to override files from libraspberrypi-dev. To avoid this, we can do the following:

First part installs the needed dependencies. Next removes the development files (for now). The next two first lets the packages override the files then reinstall the development files with the same overriding properties. No more apt-get conflicts! Now we can run configure.

Sit back and let the first part go. As part of the configuration, it starts building qmake, which may take a small while. If anything bad happens, you can read the log file, configure_output. if all is well, then we can begin the real compiling!

This part will EASILY take 4 hours to finish. At this point, the Pi can be left alone and you can do other things. Read a book. Watch TV. Go on YouTube (Trust me, the “5 minutes” on YouTube will cover all 4 hours easily). If you ever lose your connection, you can reconnect by calling screen -rx. Afterwards (or if any errors happen), you can check the output_make log file. With 2GB of swap and 1GB of standard memory, there shouldn’t be any problems.

Once everything is done, go ahead and install!

Congratulations! You have now built QT5.3.2 natively on the Pi2!

Step 3: Compile HiFi (Domain-Server & Assignment-Client)

The Here comes the big time, and by big time, I mean we follow a ‘slightly’ modified Ubuntu build guide!

First, we use a slightly modified Step 3.

Next, we proceed with Step 4, ensuring we are running as root and have screen active.

Steps 5 and 6 I think are handled by cmake when building HiFi in the more recent versions, but for the sake of tradition, let’s compile it anyway!

Step 7 needs two more lines to be added.

Step 8 is nothing different.

Keep an eye out for any errors that pop up. The ones that came up the first time were in regards to Qt5_DIR and (of all things) Qt5LinguistTools_DIR, but if you have been following this tutorial, you should already have that covered.

Step 9: Compiling the Domain-server.

If all went well, begin Step 10: Compiling the Assignment-Client.

If everything went okay, then congrats! You now have High Fidelity on the Raspberry Pi!

Step 4: Running Hifi on the Pi!

We’ve made it this far, so let’s finish up by taking some footnotes from Coal’s CentOS7 build script and move HiFi to somewhere safe!

From here, we can just go into the folder and run it. Here are two scripts I have JUST for getting the server going (again, based on the CentOS7 build script).

Remember to make them executable and give a whirl! If all is well, then you should be able to access the domain-server control panel on a browser. Congratulations! Just remember to turn off the swap file we made earlier (we’re quite done with it).

Final Thoughts

Overall, performance on the Raspberry Pi 2, under default settings, handles everything very well. Audio mixing is handled very accurately and I have not heard any oddities when talking with friends on the domain. Aside from the weird object ownership bug, a Pi flavored High Fidelity server could mean people could jump into High Fidelity without having to use their own computer as the server, which is great for having a low-cost option. Throw in the fact that active cooling is completely optional and thanks to the assignment-client’s ability to provide remote support, one could easily make a mini High Fidelity cluster domain server the size of a shoebox. If WiFi could be sorted out and a battery pack is added, this could make for a portable server that can be showcased around with complete ease.

Considering the original intention of the Raspberry Pi, it would be interesting to see if the scripting engine of Hifi could somehow interact with the GPIO pins on the Pi itself. Imagine a light switch in world that could turn an LED on and off with avatar interaction, or a button that manipulates an object in the virtual world. With the Pi’s ability to interface with electronics, this could be a major step forward in what HiFi brings to the table and what the Raspberry Pi could do to expand upon HiFi’s ideas. Instead of using Scratch for kids to learn programming, high school students or even college students could experiment with the Raspberry Pi via High Fidelity, being able to communicate and observe the in-world and real world reactions. Perhaps, for fun, home automation could be handled by an avatar in-world with user set permissions. Lights could be turned on in a virtual home, reflecting the status of a real world counterpart.

It’ll be interesting to see where things goes on from here.

Leave a Reply

Your email address will not be published. Required fields are marked *

8 + eight =