Experimental Game Dev Interviews — The First Game Dev Podcast Ever
RSS icon Home icon
  • Godot on Raspberry Pi 4

    Posted on September 1st, 2019 IndieGamePod 8 comments

    This tutorial will be about how to get Godot to work on a Raspberry Pi 4.

    I recently got a Raspberry Pi 4, 2 GB version.

    I read about other folks that tried to get Godot to work on previous versions of Raspberry Pi and did not expect things to go well. It seems like getting Godot to run on Raspberry Pi was not a priority. It seemed like if I could get Godot to run on Raspberry Pi, it would be very slow.

    I decided to see what happens anyways. I was able to run Godot on Raspberry Pi 4…and it seemed to run all right. I’ll know more as I try to do more dev on it.

    Here’s what I did to make it happen…
    I downloaded the latest Godot source…3.2 dev… and compiled it on the Raspberry Pi 4. It took about an hour.

    To compile the source properly…I had to do a few things…
    1) Keep this post for reference…
    https://www.reddit.com/r/godot/comments/af1cji/compiling_godot_31_for_raspberry_pi/

    Keep this one for reference too…if you want to overclock…
    https://bits.krzysztofjankowski.com/raspberry-pi-4-as-perfect-indie-console/

    2) I had to make sure I had all the necessary libraries needed for Godot to properly compile.

    I used this page for reference…
    https://docs.godotengine.org/en/3.1/development/compiling/compiling_for_x11.html

    Since I think Noobs is based off Ubuntu/Debian…I used the one liner provided to install the relevant libraries…
    sudo apt-get install build-essential scons pkg-config libx11-dev libxcursor-dev libxinerama-dev \
    libgl1-mesa-dev libglu-dev libasound2-dev libpulse-dev libfreetype6-dev libudev-dev libxi-dev \
    libxrandr-dev yasm

    Install clang compiler…
    sudo apt-get install clang

    It was not enough and I had to install a few more libraries. I found out the exact libraries I needed when I tried to build the source with the following command…
    scons -j 4 platform=x11 module_webm_enabled=no tools=yes use_llvm=yes CCFLAGS="-mcpu=cortex-a7 -mfpu=neon-vfpv4 -mfloat-abi=hard -mlittle-endian -munaligned-access"

    If it builds, cool…if not, SCons might mention the library/thing missing as you try to build. use apt-get to install the missing libraries.

    Once you do that, you will be able to specify x11 as the platform.

    One other note is that you will need to disable the webm module since it seems to cause errors when you build with it.

    To do that, you add this flag to the build command…
    module_webm_enabled=no

    Since Raspberry Pi 4…is a quad core…I used the -j 4 command…to help make the build go faster. I think it then uses all 4 cores for the build process.

    Based on feedback from others and more time with development, I realize that some compiler flags need to be added…to make sure the performance of Godot is somewhat decent…
    CCFLAGS="-mcpu=cortex-a7 -mfpu=neon-vfpv4 -mfloat-abi=hard -mlittle-endian -munaligned-access"

    I did try to build with 64 bits, but I do not think it went well…so I just went with the default…I think that is 32 bits.

    The final build command looked like this…
    scons -j 4 platform=x11 module_webm_enabled=no tools=yes use_llvm=yes CCFLAGS="-mcpu=cortex-a7 -mfpu=neon-vfpv4 -mfloat-abi=hard -mlittle-endian -munaligned-access"

    also, if you run out of virtual memory, just run the scons command again….it should pick up where it left off…so run this line again…
    scons -j 4 platform=x11 module_webm_enabled=no tools=yes use_llvm=yes CCFLAGS="-mcpu=cortex-a7 -mfpu=neon-vfpv4 -mfloat-abi=hard -mlittle-endian -munaligned-access"

    3) Once it built, I went to the bin subdirectory and ran it. It seemed to run fine and I was able to develop on it. I made a simple cube and rotated it every frame. I ran it…and it went really well. There was no lag that I noticed.

    I then wanted to see if I could make it so I could deploy the project to raspberry pi 4. To do this, I tried various things. The closest way I could get this to work was to build a version from source that was a release target but still had tools.

    Then I exported the project as a zip file. I had to move the release version of godot to the directory with the zip file.

    I then ran the godot release version and it loaded the project and ran the rotating cube directly.

    It was nice. But still, I think there must be a better/faster way to do this.

    The ideal situation would be that the executable would be built and then could be run…so I do not need to have the godot release build and the files in the same folder.

    One other note…once you build Godot, the object files may take up a few gigabytes of space. If you need space on your sd card, you may want to remove the object files…go to the terminal, then go to your godot-master directory and type in the following…
    scons –clean

    There are 2 dashes before the clean.

    It will delete the object files and give you more space on your sd card. Of course, it also means that scons will have to generate the .o files again if you want to compile the source code again.

    Post comments or questions below 🙂