Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't compile PPSSPP on the Raspberry Pi 4 #12137

Closed
namanix opened this issue Jun 26, 2019 · 26 comments · Fixed by #12159
Closed

Can't compile PPSSPP on the Raspberry Pi 4 #12137

namanix opened this issue Jun 26, 2019 · 26 comments · Fixed by #12159

Comments

@namanix
Copy link

namanix commented Jun 26, 2019

What happens?

When I compile with:
cmake . -DCMAKE_TOOLCHAIN_FILE=cmake/Toolchains/raspberry.armv7.cmake
it fails with this error when making:

[ 51%] Building CXX object CMakeFiles/Core.dir/GPU/Common/TextureDecoderNEON.cpp.o
/tmp/ccJDi8IY.s: Assembler messages:
/tmp/ccJDi8IY.s:37: Error: selected processor does not support `movw r0,0xc00b' in ARM mode
/tmp/ccJDi8IY.s:38: Error: selected processor does not support `movt r0,0x9bd9' in ARM mode
/tmp/ccJDi8IY.s:39: Error: selected processor does not support `movw r1,0x4b73' in ARM mode
/tmp/ccJDi8IY.s:40: Error: selected processor does not support `movt r1,0xb651' in ARM mode
/tmp/ccJDi8IY.s:42: Error: selected processor does not support `movw r0,0x4d9b' in ARM mode
/tmp/ccJDi8IY.s:43: Error: selected processor does not support `movt r0,0x4309' in ARM mode
/tmp/ccJDi8IY.s:44: Error: selected processor does not support `movw r1,0x0083' in ARM mode
/tmp/ccJDi8IY.s:45: Error: selected processor does not support `movt r1,0x0001' in ARM mode
/tmp/ccJDi8IY.s:47: Error: selected processor does not support `movw r0,0x2455' in ARM mode
make[2]: *** [CMakeFiles/Core.dir/build.make:3196: CMakeFiles/Core.dir/GPU/Common/TextureDecoderNEON.cpp.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:496: CMakeFiles/Core.dir/all] Error 2
make: *** [Makefile:130: all] Error 2

I've also made a new raspberry.armv8.cmake file in which I changed the mcpu to cortex-a72.
Gives me the same error.

Is this a bug? Or am I doing something wrong?

@mrcmunir
Copy link
Contributor

you are running raspbian? seems this error is because they i think compile by default for Armv6 mode for compatibility reason for first raspberry pi?
Unfortunately in armv6 mode doesn't movt or movw because these instrucions are for armv7 .

@unknownbrackets
Copy link
Collaborator

It has an armv8 processor so it seems like it'd be better to compile for armv8.

https://www.raspberrypi.org/products/raspberry-pi-4-model-b/specifications/

So that means, remove set(ARMV7 ON) from the toolchain file. I think it will autodetect ARM64.

-[Unknown]

@namanix
Copy link
Author

namanix commented Jun 27, 2019

@mrcmunir but why does it think I'm compiling for ArmV6? I'v told it to use the ArmV7 toolchain

@namanix
Copy link
Author

namanix commented Jun 27, 2019

@unknownbrackets I'll try that. But do keep in mind that raspbian is STILL 32 bit... so only ArmV7 support

@unknownbrackets
Copy link
Collaborator

In that case, try -march=armv7-a -mfpu=neon. I'm not sure we support armv6 anymore, so definitely don't want to compile as armv6.

-[Unknown]

@hrydgard
Copy link
Owner

We do not support ARMv6. In fact we should probably try to make it error out early with an error message if someone tries to compile for that architecture.

@kaiomatico
Copy link
Contributor

Hi, I just tried compiling using the recommendation of -march=armv7-a -mfpu=neon . So I edited the line in the cmake/Toolchains/raspberry.armv7.cmake file as follows:
set(ARCH_FLAGS "-march=armv7-a -mfpu=neon -mfloat-abi=hard")

Running cmake followed by a make -j4 and sudo make install worked fine, however the successfully built PPSSPPSDL executable was not able to launch from the global path (I guess it was not copied to /usr/bin or something similar).
Anyway I then just executed ./PPSSPPSDL from the git cloned ppsspp folder, but get the following error message (note the raspbian desktop is loaded ) :

pi@raspberrypi:~/ppsspp $ ./PPSSPPSDL
E: VulkanLoader.cpp:339: Failed to create vulkan instance.
DEBUG: Vulkan is not available, not using Vulkan.

  • failed to add service - already in use?

I don't know how up-to-date you PPSSPP developers are with what is going on in the raspberry pi land, but as a piece of information which might be related: The graphics driver has changed for the raspberry pi 4 from the closed source "vc4" to the open source OpenGL "fkms" driver

Maybe it has something to do with that.

@namanix
Copy link
Author

namanix commented Jul 3, 2019

@kaiomatico Remove the following lines to make it build and execute correctly.
https://github.com/hrydgard/ppsspp/blob/master/cmake/Toolchains/raspberry.armv7.cmake
Line 12, 23, 24
I don't really remember why line 12 needed to be gone. But I do remember removing it fixed something.
Line 23 and 24 are libraries which are not supported by the Rpi4 anymore.
All libraries with "brcm" are removed (I believe all) and now the pi uses are more generic approach. So no more pi specific builds from Rpi4 and forth

@kaiomatico
Copy link
Contributor

Thank you for your suggestions @namanix , I removed line 12,23 and 24, rebuilt and got a little further (even though PPSSPPSDL still seems not to be copied to the local /bin path). Have a look at the screenshot what happens after I have rebuilt ppsspp with your suggested changes and then try to run it:
2019-07-03-132019_1920x1080_scrot
A new window title bar opens up for the fraction of a second until the segfault occurs.

@unknownbrackets
Copy link
Collaborator

On the Pi 3, to get hardware accelerated rendering (which you definitely want), you had to use FBDEV and run without GUI. "failed to add service - already in use?" was shown if you tried to run it in GUI, iirc. Maybe this isn't necessary on the Pi 4, but then you would need to remove USING_FBDEV too.

FBDEV basically means that it draws full screen only.

-DPPSSPP_PLATFORM_RPI=1 makes it call bcm_host functions, related to set(OPENGL_LIBRARIES brcmGLESv2 bcm_host). If those aren't used anymore, it makes sense to remove.

make does not install in /usr/local/bin by default no.

-[Unknown]

@namanix
Copy link
Author

namanix commented Jul 4, 2019

@unknownbrackets Your comment about hardware accelerated rending got me worried if mine actually is. Do you have the core running on the Rpi 3 right now? And can you tell me the fps of a game that you have so that I can check if the Rpi4 does it better? (Just to check if hardware rendering is on)

@kaiomatico
Copy link
Contributor

@unknownbrackets Thank you for your help, I tried running PPSSPPSDL without starting the X Server, which resulted in the following error message:
IMG_20190704_091144401

After that I built PPSSPP without the FBDEV in the .cmake file and tried to run it in the GUI which resulted in this error message again:
2019-07-04-093003_1920x1080_scrot

So somehow I am too stupid to compile it on my own 😆 ... I will probably just wait until a Retropie build becomes available or something similar. By the way I saw that the .cmake file states that it should use GLES2, with the raspberry pi 4 we have GLES3 support. Maybe it is worth optimizing this file further or adding a .cmake file specificially for the raspberry pi 4 because so many things have changed. Thank you all for your efforts

@unknownbrackets
Copy link
Collaborator

I don't have it handy, but performance was not great in Crisis Core for example. It sounds like the Pi 4 is generally doing well, so if you're seeing Crisis Core run in game (like when fighting) at better than 50% speed, I think we can safely assume you have hardware accelerated rendering.

Check the Pi 3 instructions. It may help performance if you change the CPU scaling to upclock sooner, like with the Pi 3.

Hm. I think that non-FBDEV code is actually assuming you're using X11. Maybe it's Wayland or something. Unfortunately, I don't know a lot about X alternatives. But you can try this completely untested code change:

https://github.com/hrydgard/ppsspp/compare/master...unknownbrackets:sdl-wm?expand=1

USING_GLES2 just means using OpenGL ES 2.x+ instead of using desktop OpenGL. It also means GLES 3, which we'll automatically detect support for.

-[Unknown]

@kaiomatico
Copy link
Contributor

@unknownbrackets I compiled your current sdl-wm branch and it works great. I've used the attached .cmake file. I just wonder why the PPSSPP version is so old (v0.9.9.1) even though the last commits seem to be just a couple of days old. Anyway thank you! Maybe this patch could be merged.

https://user-images.githubusercontent.com/8037196/60742260-e5ab3d80-9f6c-11e9-9dad-1ca02e74b7cb.png

https://github.com/hrydgard/ppsspp/files/3363822/raspberry.armv7.cmake.txt

@unknownbrackets
Copy link
Collaborator

Thanks for reporting. I wonder if there's some reasonable way to detect the Pi 4 in that file - I don't want to just break Pi 3.

There's three parts to the version number: v1.2.3, -1234, and -gabc12345.

The second part represents how many changes you are away from the first part. The problem here is that your copy from git doesn't know about any newer release than v0.9.9.1, so it thinks this is just a git build 11,613 changes later than that.

You should be able to use something like:

git fetch origin --tags

To get the latest git tags, which will make the version number correct (you'd have to rebuild.)

-[Unknown]

@kaiomatico
Copy link
Contributor

kaiomatico commented Jul 6, 2019

You could just do an fopen/fread or cat /proc/cpuinfo and grep for revision "a03111", "b03111" or "c03111". This is what identifies a raspberry pi 4. See this table: https://www.raspberrypi.org/documentation/hardware/raspberrypi/revision-codes/README.md

My Pi 4 2GB shows the following:
Hardware : BCM2835
Revision : b03111

@unknownbrackets
Copy link
Collaborator

How does this work?

master...unknownbrackets:rpi4

Also, I realized you might've just cloned from my fork, which probably has outdated tags.

-[Unknown]

@kaiomatico
Copy link
Contributor

kaiomatico commented Jul 6, 2019

Oops I just saw that I compiled the master branch 22 hours ago, somehow it just worked, now we don't know why -.- this time I will make sure to checkout the rpi4 branch before compiling.
Is there a different way other than cloning your repo and switching to the correct branch? It fails building, see the attached error log. As a side note: I ran the retropie-setup in the meantime, I hope it did not add any additional environment variables or something similar. I can re-install a stock raspbian tomorrow to test again.
errorlog.txt

@unknownbrackets
Copy link
Collaborator

Ah, try this line instead - I was just trying to make sure it was using neon and vfpu4:

set(ARCH_FLAGS "-march=armv7-a -mcpu=cortex-a72 -mtune=cortex-a72 -mfpu=neon-vfpv4 -mfloat-abi=hard")

Instead of:

set(ARCH_FLAGS "-march=armv7-a+neon-vfpv4 -mcpu=cortex-a72 -mtune=cortex-a72 -mfpu=neon-vfpv4 -mfloat-abi=hard")

-[Unknown]

@kaiomatico
Copy link
Contributor

kaiomatico commented Jul 6, 2019

Running cmake with the edited SET(ARCH_FLAGS ... line works great now, but running make after that leads to the following error (see log)
errorlog_make.txt

@unknownbrackets
Copy link
Collaborator

Ah, hadn't had a chance to try it - updated the branch, it should compile now (still not sure if it'll work.)

It sounds like eff793c was working, though. If it's broken since then, we may want to bisect:
eff793c...master

(I guess it still needs at least the cmake settings.)

In that range, I would suspect #12097...

-[Unknown]

@kaiomatico
Copy link
Contributor

Ok so after realizing yeterday that I successfully ran your master branch rather than the sdl-wm branch I've tried to compile the sdl-wm branch today. It caused the same error I described yesterday (see
error_sdl-wm_branch.txt
I don't see any difference in your rpi4 branch since I've tried it yesterday. The pi 4 autodetection of the cmake file looks fine, but most likely the #12155 broke the compilation at 16%.
If not then there must be something else different making your master branch work rather than the official PPSSPP master branch. If I should test something else out just let me know 😄

@unknownbrackets
Copy link
Collaborator

It would be great to bisect to confirm:
https://github.com/hrydgard/ppsspp/wiki/How-to-bisect-to-find-what-broke-a-game

It's not clear to me if the master on my fork (which is simply an older git build at eff793c) was working without cmake changes or not. But bisecting would tell you when it stopped working for sure.

So to be clear, the rpi4 branch (I pushed new code there) still fails with the same error message? That's really weird, because e_eglDisplay was just a typo (I hadn't tried compiling it anywhere since I didn't have a device immediately available then) and should be completely gone now.

-[Unknown]

@kaiomatico
Copy link
Contributor

Sorry for the confusion. I just checked out your rpi4 branch and after editing the line in the .cmake file to this set(ARCH_FLAGS "-march=armv7-a -mcpu=cortex-a72 -mtune=cortex-a72 -mfpu=neon-vfpv4 -mfloat-abi=hard") (so removing the +) everything builds and launches correctly! :) great news! It even shows the correct version number now.
2019-07-07-182035_1920x1080_scrot

@unknownbrackets
Copy link
Collaborator

Great, thanks for confirming. Sorry for the confusion, it was really helpful to have you test the different versions.

-[Unknown]

@hrydgard
Copy link
Owner

hrydgard commented Jul 7, 2019

Sounds like we can close this now?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants