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 πŸ™‚

     

    8 responses to “Godot on Raspberry Pi 4” RSS icon

    • Hi,

      Thanks for your instructions. I followed the above step on my RPi4 4GB using Raspbian 2019-07-10 . The Godot binary can be built without problem. However, the performance is not so good. I’ve tested with the official 2D platformer demo and the FPS is quite low. Do you have the same situation?

      Thanks!

    • I tested Godot with the simple rotating cube and another project. Both projects were 3d and did not require many polygons. For me, it seemed to be all right.

      The second project did have some lag. I felt I could still continue to use the Raspberry Pi 4 for development of the project. I did not spend a lot of time on actual game development on Raspberry Pi 4.

      I plan to do more this upcoming week. I’ll see if I can do another post about how the dev went.

    • Ok, I tested some more stuff…

      Use these flags when you build godot…I noticed it helped with performance…
      CCFLAGS="-mcpu=cortex-a7 -mfpu=neon-vfpv4 -mfloat-abi=hard -mlittle-endian -munaligned-access"

      WordPress may add smart quotes when it displays this…replace the smart quotes with normal quotes.

      I’ve update the tutorial to reflect this improvement.

    • Hi,

      I looked up for a tutorial the last week to get godot run on my Pi 4 and found all the links you posted before your tutorial. I got it compiled already, but i didn’t know how to start a game. So if anyone tries to start it, after compiling it, here is what i came up with, maybe you can correct me and/or maybe put it in your tutorial:

      Start a Game.pck-file:
      exec /path/to/your/godot/bin/godot.x11.opt.32.llvm –main-pack /path/to/your/godot/game.pck –print-fps

      On my Pi4 the real command is:

      exec /home/pi/godot/bin/godot.x11.opt.32.llvm –main-pack /home/pi/godot/bin/MaterialTester.pck –print-fps

      I get arround 6 fps in 3D for the Material-Tester demo.

      But i tried a little bit differend compile command than all others talk about. I found out, that i get a lot of neon-vfpv4 related compiler errors. The compile command that runs without errors I came up is:

      scons platform=x11 target=release tools=no use_llvm=yes CCFLAGS=”-mtune=cortex-a72 -mcpu=cortex-a72 -mcfpu=neon-fp-armv8 -mfloat-abi=hard” -j4

      But i will try the one you posted above as well soon, maybe than I get a little bit more fps.

      But for now I’m happy that godot finally run on my Pi4 1GB. Now its time to boost the fps…. πŸ˜€

      The .pck project files I use, were created with a Windows 10 64-bit Godot export to X11.
      Pi4 Raspbian 10 Buster kernel 4.19.75

      sorry for my english πŸ˜‰ its not my native language

    • yes, the big thing now is the fps…you are right…I noticed the fps could get very slow.

      I’m not sure what in the engine causes the issue. If you see some of the other openGL demos for Raspberry Pi 4, they seem to work all right.

    • Really appreciate the write-up but I hit problems trying to get it to compile under Manjaro on my 4GB RPi4

      scons: Building targets …
      [ 1%] Compiling ==> platform/x11/godot_x11.cpp
      [ 1%] Compiling ==> platform/x11/context_gl_x11.cpp
      [ 1%] Compiling ==> platform/x11/vulkan_context_x11.cpp
      [ 1%] Compiling ==> platform/x11/crash_handler_x11.cpp
      clang-9: error: the clang compiler does not support ‘-mcpu=cortex-a7’
      scons: *** [platform/x11/godot_x11.x11.tools.64.llvm.o] Error 1
      clang-9: error: the clang compiler does not support ‘-mcpu=cortex-a7’
      scons: *** [platform/x11/context_gl_x11.x11.tools.64.llvm.o] Error 1
      clang-9: error: the clang compiler does not support ‘-mcpu=cortex-a7’
      scons: *** [platform/x11/vulkan_context_x11.x11.tools.64.llvm.o] Error 1
      clang-9: error: the clang compiler does not support ‘-mcpu=cortex-a7’
      scons: *** [platform/x11/crash_handler_x11.x11.tools.64.llvm.o] Error 1
      scons: building terminated because of errors.

    • Try -mcpu=cortex-a72

      See if that fixes the issue..
      scons platform=x11 target=release tools=no use_llvm=yes CCFLAGS=”-mtune=cortex-a72 -mcpu=cortex-a72 -mcfpu=neon-fp-armv8 -mfloat-abi=hard” -j4

      This was mentioned in another comment…


    Leave a reply