patriciogonzalezvivo / glslViewer

Console-based GLSL Sandbox for 2D/3D shaders
BSD 3-Clause "New" or "Revised" License
4.54k stars 352 forks source link

*failed to add service - already in use?* error on Pi4 #204

Open nicolevella opened 3 years ago

nicolevella commented 3 years ago

Cant get it to run on my Pi4.

Tried both desktop and headless installs of raspiban. and running it from desktop terminal and from booting into command line and running there.

any ideas?

something to do with drivers?

patriciogonzalezvivo commented 3 years ago

I think by headless you mean with out X11 and directly from the command line. Do you mind showing me what command do you use to compile? and the first lines of the compiling process?

nicolevella commented 3 years ago

I just used

apt-get install glslviewer

I will try compiling from source after lecutre today

patriciogonzalezvivo commented 3 years ago

Yes, please try compiling from source. Because I haven't send a new deb package to the nice folks of Raspberry Pi in a couple of years : )

patriciogonzalezvivo commented 3 years ago

@nicolevella any update on this? did you manage to compile it?

nicolevella commented 3 years ago

I’m going to try this afternoon.

After reading more into it the other day, I think I’ll get it complied.

I’ll update soon.

Sent from ProtonMail Mobile

On Sun, Mar 14, 2021 at 6:37 AM, Patricio Gonzalez Vivo @.***> wrote:

@.***(https://github.com/nicolevella) any update on this? did you manage to compile it?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or unsubscribe.

nicolevella commented 3 years ago

Updated all packages and made sure that the right lines were present and uncommented in /boot/config.txt and that the fake-KMS was enabled.

Here's the error I get. I tried compiling on both Lite and Desktop versions on the Pi4

g++ -Wall -O3 -std=c++11 -fpermissive -DPLATFORM_RPI -Wno-psabi -DUSE_VCHIQ_ARM -DOMX_SKIP64BIT -DHAVE_LIBBCM_HOST -DUSE_EXTERNAL_LIBBCM_HOST -DHAVE_LIBOPENMAX=2 -DOMX -DUSE_EXTERNAL_OMX -DDRIVER_FAKE_KMS -Isrc/ -Iinclude/ -I/usr/include/libdrm -I/usr/include/GLES2 -I/opt/vc/include/ -I/opt/vc/include/interface/vcos/pthreads -I/opt/vc/include/interface/vmcs_host/linux -g -c src/uniforms.cpp -o src/uniforms.o -Wno-deprecated-declarations In file included from src/gl/fbo.h:3, from src/uniforms.h:8, from src/uniforms.cpp:1: src/gl/gl.h:9:10: fatal error: xf86drm.h: No such file or directory

include

      ^~~~~~~~~~~

compilation terminated. make: *** [Makefile:102: src/uniforms.o] Error 1

joaodafonseca commented 3 years ago

same problem here! any new developments?

patriciogonzalezvivo commented 3 years ago

Do you mind describing:

VinaiRachakonda commented 3 years ago

I was having the same problem at first then this thread helped me nail down the problem: https://www.raspberrypi.org/forums/viewtopic.php?t=243707&start=25

Did you install libgbm-dev? I got the make and make install to pass on rpi4 but have been unable to run glslViewer itself.

joaodafonseca commented 3 years ago

Do you mind describing:

  • OS
  • Hardware
  • copy the entire output get after doing make ?

OS : Raspberry PI OS Lite - no desktop environment Hardware : PI 4 2gb

`RPI platform with fake_kms drivers src/defines.o g++ -Wall -O3 -std=c++11 -fpermissive -DPLATFORM_RPI -Wno-psabi -DUSE_VCHIQ_ARM -DOMX_SKIP64BIT -DHAVE_LIBBCM_HOST -DUSE_EXTERNAL_LIBBCM_HOST -DHAVE_LIBOPENMAX=2 -DOMX -DUSE_EXTERNAL_OMX -DDRIVER_FAKE_KMS -Isrc/ -Iinclude/ -I/usr/include/libdrm -I/usr/include/GLES2 -I/opt/vc/include/ -I/opt/vc/include/interface/vcos/pthreads -I/opt/vc/include/interface/vmcs_host/linux -g -c src/defines.cpp -o src/defines.o -Wno-deprecated-declarations src/uniforms.o g++ -Wall -O3 -std=c++11 -fpermissive -DPLATFORM_RPI -Wno-psabi -DUSE_VCHIQ_ARM -DOMX_SKIP64BIT -DHAVE_LIBBCM_HOST -DUSE_EXTERNAL_LIBBCM_HOST -DHAVE_LIBOPENMAX=2 -DOMX -DUSE_EXTERNAL_OMX -DDRIVER_FAKE_KMS -Isrc/ -Iinclude/ -I/usr/include/libdrm -I/usr/include/GLES2 -I/opt/vc/include/ -I/opt/vc/include/interface/vcos/pthreads -I/opt/vc/include/interface/vmcs_host/linux -g -c src/uniforms.cpp -o src/uniforms.o -Wno-deprecated-declarations In file included from src/gl/fbo.h:3, from src/uniforms.h:8, from src/uniforms.cpp:1: src/gl/gl.h:9:10: fatal error: xf86drm.h: No such file or directory

include

      ^~~~~~~~~~~

compilation terminated. make: *** [Makefile:102: src/uniforms.o] Error 1`

i got this when compiling from source. If I compile from apt im able to compile but i got the following message when try to run glslViewer: *failed to add service - already in use?*

joaodafonseca commented 3 years ago

if i do apt-file search xf86drm.h i got:

libdrm-dev: /usr/include/xf86drm.h

Could be that the path is wrong?

patriciogonzalezvivo commented 3 years ago

But is there when you do:

ls -la /usr/include/xf86drm.h
joaodafonseca commented 3 years ago

But is there when you do:


ls -la /usr/include/xf86drm.h

Nope

ls: cannot access 'xf86drm.h': No such file or directory

patriciogonzalezvivo commented 3 years ago

You need to install it. Follow the compilation instruction for Raspberry Pi 4

sudo apt-get install libegl1-mesa-dev libgbm-dev libgles2-mesa-dev
joaodafonseca commented 3 years ago

sudo apt-get install libegl1-mesa-dev libgbm-dev libgles2-mesa-dev

Hmm im following your instructions, already did that but same error

patriciogonzalezvivo commented 3 years ago

oh... I see, then try

sudo apt install libdrm-dev
joaodafonseca commented 3 years ago

ok cool that solved it. But still cant make

RPI platform with fake_kms drivers
g++ -Wall -O3 -std=c++11 -fpermissive -DPLATFORM_RPI -Wno-psabi  -DUSE_VCHIQ_ARM -DOMX_SKIP64BIT -DHAVE_LIBBCM_HOST -DUSE_EXTERNAL_LIBBCM_HOST -DHAVE_LIBOPENMAX=2 -DOMX -DUSE_EXTERNAL_OMX  -DDRIVER_FAKE_KMS include/skylight/ArHosekSkyModel.cc src/defines.o src/uniforms.o src/window.o src/main.o src/sandbox.o src/io/gltf.o src/io/obj.o src/io/stl.o src/io/osc.o src/io/ply.o src/io/fs.o src/gl/textureStreamOMX.o src/gl/textureCube.o src/gl/fbo.o src/gl/texture.o src/gl/gl.o src/gl/textureStreamAV.o src/gl/shader.o src/gl/textureStreamSequence.o src/gl/pingpong.o src/gl/textureStreamMMAL.o src/gl/vbo.o src/gl/textureBump.o src/gl/vertexLayout.o src/scene/scene.o src/scene/light.o src/scene/model.o src/scene/camera.o src/scene/node.o src/scene/material.o src/tools/text.o src/tools/geom.o src/types/mesh.o src/types/list.o include/oscpack/osc/OscOutboundPacketStream.o include/oscpack/osc/OscPrintReceivedElements.o include/oscpack/osc/OscTypes.o include/oscpack/osc/OscReceivedElements.o include/oscpack/ip/posix/NetworkingUtils.o include/oscpack/ip/posix/UdpSocket.o -ldrm -lgbm -lGLESv2 -lEGL -L/opt/vc/lib/ -lmmal -lmmal_core -lmmal_util -lmmal_vc_client -lvcos -lopenmaxil -lvchiq_arm -lbcm_host -lpthread -rdynamic -o bin/glslViewer
/usr/bin/ld: src/sandbox.o: in function `std::_Function_handler<std::unique_ptr<std::__future_base::_Result_base, std::__future_base::_Result_base::_Deleter> (), std::__future_base::_Task_setter<std::unique_ptr<std::__future_base::_Result<void>, std::__future_base::_Result_base::_Deleter>, std::__future_base::_Task_state<std::_Bind<Sandbox::onScreenshot(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >)::Job ()>, std::allocator<int>, void ()>::_M_run_delayed(std::weak_ptr<std::__future_base::_State_baseV2>)::{lambda()#1}, void> >::_M_invoke(std::_Any_data const&)':
/usr/include/c++/8/bits/atomic_base.h:312: undefined reference to `__atomic_fetch_add_8'
/usr/bin/ld: src/sandbox.o: in function `std::_Function_handler<std::unique_ptr<std::__future_base::_Result_base, std::__future_base::_Result_base::_Deleter> (), std::__future_base::_Task_setter<std::unique_ptr<std::__future_base::_Result<void>, std::__future_base::_Result_base::_Deleter>, std::__future_base::_Task_state<std::_Bind<Sandbox::onScreenshot(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >)::Job ()>, std::allocator<int>, void ()>::_M_run()::{lambda()#1}, void> >::_M_invoke(std::_Any_data const&)':
/usr/include/c++/8/bits/atomic_base.h:312: undefined reference to `__atomic_fetch_add_8'
/usr/bin/ld: src/sandbox.o: in function `std::_Function_handler<bool (std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&), Sandbox::setup(std::vector<WatchFile, std::allocator<WatchFile> >&, std::vector<Command, std::allocator<Command> >&)::{lambda(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)#18}>::_M_invoke(std::_Any_data const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)':
/usr/include/c++/8/bits/atomic_base.h:396: undefined reference to `__atomic_load_8'
/usr/bin/ld: /usr/include/c++/8/bits/atomic_base.h:374: undefined reference to `__atomic_store_8'
/usr/bin/ld: src/sandbox.o: in function `Sandbox::onScreenshot(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >)':
/usr/include/c++/8/bits/atomic_base.h:320: undefined reference to `__atomic_fetch_sub_8'
/usr/bin/ld: /usr/include/c++/8/bits/atomic_base.h:396: undefined reference to `__atomic_load_8'
/usr/bin/ld: /usr/include/c++/8/bits/atomic_base.h:312: undefined reference to `__atomic_fetch_add_8'
collect2: error: ld returned 1 exit status
make: *** [Makefile:105: bin/glslViewer] Error 1
patriciogonzalezvivo commented 3 years ago

oh snap, never saw that before. @ben-hansske do you think this is related to the new a sync stuff?

@joaodafonseca do you mind doint:

make clean
git checkout 0a33ef4344974c16e2a36aed97a9e2eae3bf4ada
make 

sorry for the inconvenience!

joaodafonseca commented 3 years ago

oh snap, never saw that before. @ben-hansske do you think this is related to the new a sync stuff?

@joaodafonseca do you mind doint:

make clean
git checkout 0a33ef4344974c16e2a36aed97a9e2eae3bf4ada
make 

sorry for the inconvenience!

No problem thanks a lot for the support. i was able to compile and install now bit still got * failed to add service - already in use?

Maybe because i compiled from apt before?

joaodafonseca commented 3 years ago

ok i removed the apt install make clean install again from that branch and only have the following output. RPI platform with fake_kms drivers

when i do glslViewer -v

i got: -bash: /usr/bin/glslViewer: No such file or directory

joaodafonseca commented 3 years ago

ok slowly getting closer. I rebooted and was able to make and install.. I wrote a simple shader and did glslViewer test.frag but nothing happens and no message on the terminal. Do you have an idea? Do I need the desktop OS version for this?

edit: verbose mode show the following: `OpenGL ES Vendor: VMware, Inc. Renderer: llvmpipe (LLVM 9.0.1, 128 bits) Version: OpenGL ES 3.1 Mesa 19.3.2 GLSL version: OpenGL ES GLSL ES 3.10 GL_MAX_TEXTURE_SIZE = 8192 // Reload 2D shaders

shader load time: 0.0208175s Starting Render Loop`

and im using the following display, which is working and showing the terminal https://www.ptrobotics.com/lcd-grafico/6982-35-inch-480x320-tft-display-w-touchscreen-for-raspberry-pi.html

patriciogonzalezvivo commented 3 years ago

do you mind sharing the code?

joaodafonseca commented 3 years ago

very basic, just a test shader:

`#ifdef GL_ES precision mediump float;

endif

void main() { gl_FragColor = vec4(1.0,0.0,1.0,1.0); }`

VinaiRachakonda commented 3 years ago

@joaodafonseca how were you able to get past this "* failed to add service - already in use?". I've been stuck on this error for the past week and unsure how to get around it.

joaodafonseca commented 3 years ago

@VinaiRachakonda check the my discussion with @patriciogonzalezvivo i was able to compile it and install it successfully but still not running shaders

joaodafonseca commented 3 years ago

@VinaiRachakonda also make sure you don't install from apt but from the source if you did that already delete it and reboot

VinaiRachakonda commented 3 years ago

@joaodafonseca No luck. I didn't do a sudo apt-install. I tried compiling from the hash @patriciogonzalezvivo gave but I am still stuck with "*failed to add service -already in use?' when running ./bin/glslViewer

VinaiRachakonda commented 3 years ago

I think the problem could be with overlays. My /config/boot.txt has dtoverlay=vc4-fkms-v3d but when I do dtoverlay -l I get "No overlays loaded" @joaodafonseca do you mind running dtoverlay -l for me in your terminal?

joaodafonseca commented 3 years ago

@VinaiRachakonda i can try tonight! @patriciogonzalezvivo do you have any idea why the shader is not running?

patriciogonzalezvivo commented 3 years ago

@VinaiRachakonda if you are trying to run glslViewer on a raspberry pi 4 directly from the console (not inside a window manager) Please follow this instructions https://github.com/patriciogonzalezvivo/glslViewer/wiki/Compiling#cc-compiling-fake_kms-using-the-newer-videocore-vi-drivers-on-raspberry-pi-version-4-and-up. Notice that you need run the following commands before compiling on glslViewer folder.

make clean
git checkout 0a33ef4344974c16e2a36aed97a9e2eae3bf4ada
make 

@joaodafonseca do the program run and terminate. Or runs, show the command prompt (something that looks like this):

// >
joaodafonseca commented 3 years ago

@patriciogonzalezvivo yeah it shows exactly that

// >

nicolevella commented 3 years ago

@patriciogonzalezvivo yeah it shows exactly that

// >

I believe that means its rendering/working. It's just the window of the viewer isn't appearing. Becasue that's what you see when the shader is running, thats the Console IN Command prompt (CIN). Which is what runs and allows you to feed datat to the shader. I'm guessing its an overlay/window issue.

but patricio knows way more than I do, obviously! haha

patriciogonzalezvivo commented 3 years ago

Never play with dtoverlay -l... so here I'm a bit lost on what's happening.

@nicolevella did you manage to recompile? There is a known bug on master right now so you will need to:

make clean
git checkout 0a33ef4344974c16e2a36aed97a9e2eae3bf4ada
make 

@ben-hansske any idea what's the best way to fix that bug?

nicolevella commented 3 years ago

havent had time. school is killing me right now. but I will be testing the pi4 again soon.

ben-hansske commented 3 years ago

oh snap, never saw that before. @ben-hansske do you think this is related to the new a sync stuff? ...

Since I am using atomics for synchronization, this might be the case. I googled 'undefined reference to __atomic_fetch_sub_8' and found this: https://github.com/opencv/opencv/issues/15192 It seems like adding -latomic to the linker options could be the solution, but I have no RPi to test it.

I can remind that I got a similar linker error once when trying to do an incremental build. I didn't mind it because make clean && make just worked for me.

patriciogonzalezvivo commented 3 years ago

Thanks @ben-hansske! This is super useful! I will check it out! Thank you!

joaodafonseca commented 3 years ago

@patriciogonzalezvivo any tip for me? looks like its just the window that isn't showing up!

patriciogonzalezvivo commented 3 years ago

@joaodafonseca do you mind adding a regular screen instead to the tft? Just to discard variables

joaodafonseca commented 3 years ago

Dont have a mini hdmi at the moment. could try to buy on tomorrow!

VinaiRachakonda commented 3 years ago

@patriciogonzalezvivo I'll go back to the basics and try recompiling tonight with the hash you listed above! For reference I am using one HDMI output to a monitor.

VinaiRachakonda commented 3 years ago

@patriciogonzalezvivo Same result. I got "failed to add service - already in use" after compiling at that hash.

Does this library still work for Pi3? I might just go ahead and buy one of those

patriciogonzalezvivo commented 3 years ago

Hi! I just added -latomic to the make routine for Raspberry Pi as @ben-hansske suggested and now master compiles with no issues. Also I tried it on my RPi 4 and all seams to work as expected. Here is how my /boot/config.txt looks like

disable_overscan=1

# uncomment if hdmi display is not detected and composite is being output
hdmi_force_hotplug=1

# Uncomment some or all of these to enable the optional hardware interfaces
dtparam=i2c_arm=on

# Enable audio (loads snd_bcm2835)
dtparam=audio=on

dtoverlay=dwc2
dr_mode=host

dtoverlay=vc4-fkms-v3d
max_framebuffers=2
hdmi_force_hotplug=1

start_x=1
gpu_mem=128
[all]
dtoverlay=vc4-fkms-v3d
VinaiRachakonda commented 3 years ago

@patriciogonzalezvivo Do you mind letting me know what version of raspian you are using and what kernel version you are running?

VinaiRachakonda commented 3 years ago

@patriciogonzalezvivo Reflashed my sd card and now it compiles and runs test.frag! Thank you so much!

VinaiRachakonda commented 3 years ago

Very strange! I was running my rpi continuously for about a week and then I ctrl-c glslViewer. Now when I try to restart it I get

Unable to get DRM resources
Unable to get DRM resource
glslViewer: src/window.cpp:280: void initGL(glm::ivec4&, WindowStyle): Assertion `EGL_FALSE != result` failed.
Aborted
VinaiRachakonda commented 3 years ago

Fixed by compiling on card0 instead of card1.

patriciogonzalezvivo commented 3 years ago

wow! good catch! can't belive we were going on circles because of that. Thanks you so much

GaneshBaronAloir commented 3 years ago

@joaodafonseca Have you found a fix? I have the same problem has you do, I can make and install correctly but when I try to run it I get:

// >

I tried:

git clone https://github.com/patriciogonzalezvivo/glslViewer.git  
sudo apt-get install libegl1-mesa-dev libgbm-dev libgles2-mesa-dev libdrm-dev  
make  
make install

My /boot/config.txt looks like this

disable_overscan=1 #uncomment if hdmi display is not detected and composite is being output
hdmi_force_hotplug=1

# Uncomment some or all of these to enable the optional hardware interfaces
dtparam=i2c_arm=on

#Enable audio (loads snd_bcm2835)
dtparam=audio=on

[pi4]
#Enable DRM VC4 V3D driver on top of the dispmanx display stack
dtoverlay=vc4-fkms-v3d
max_framebuffers=2

[all]
dtoverlay=vc4-fkms-v3d

if I add those lines to conform to what @patriciogonzalezvivo /boot/config.txt looks like:

dtoverlay=dwc2
dr_mode=host

start_x=1
gpu_mem=128

I get

Unable to get DRM resources
Unable to get DRM resources
Failed to create EGL surface! Error: A NativeWindowType argument does not refer to a valid native window.
Segmentation fault

It seems to be fairly similar to the issue that @VinaiRachakonda had, but I am fairly new to compiling with cmake and I am unsure how to compile on card0 instead of card1. Can somebody clarify this for me?

joaodafonseca commented 3 years ago

@joaodafonseca Have you found a fix? I have the same problem has you do, I can make and install correctly but when I try to run it I get:

// >

I tried:

git clone https://github.com/patriciogonzalezvivo/glslViewer.git  
sudo apt-get install libegl1-mesa-dev libgbm-dev libgles2-mesa-dev libdrm-dev  
make  
make install

My /boot/config.txt looks like this

disable_overscan=1 #uncomment if hdmi display is not detected and composite is being output
hdmi_force_hotplug=1

# Uncomment some or all of these to enable the optional hardware interfaces
dtparam=i2c_arm=on

#Enable audio (loads snd_bcm2835)
dtparam=audio=on

[pi4]
#Enable DRM VC4 V3D driver on top of the dispmanx display stack
dtoverlay=vc4-fkms-v3d
max_framebuffers=2

[all]
dtoverlay=vc4-fkms-v3d

if I add those lines to conform to what @patriciogonzalezvivo /boot/config.txt looks like:

dtoverlay=dwc2
dr_mode=host

start_x=1
gpu_mem=128

I get

Unable to get DRM resources
Unable to get DRM resources
Failed to create EGL surface! Error: A NativeWindowType argument does not refer to a valid native window.
Segmentation fault

It seems to be fairly similar to the issue that @VinaiRachakonda had, but I am fairly new to compiling with cmake and I am unsure how to compile on card0 instead of card1. Can somebody clarify this for me?

Nope never passed this issue, looks like glslViewr is running but no window is showing. Keep me posted if you find a solution please.

vade commented 2 years ago

Hi friends.

Im getting similar errors to the DRM / card1 doesn't exist - I have no idea how to resolve.

glslViewer passthrough.frag --video 1920x1080x30
Can't open display /dev/dri/card1 seams it doesn't exist
Unable to get DRM resources
Can't open display /dev/dri/card1 seams it doesn't exist
Unable to get DRM resources
glslViewer: /home/pi/Documents/Repositories/glslViewer/deps/ada/src/window.cpp:436: int ada::initGL(glm::ivec4&, ada::WindowProperties): Assertion `EGL_FALSE != result' failed.
Aborted

Im using Rapsian Legacy:

sb_release -a
No LSB modules are available.
Distributor ID: Raspbian
Description:    Raspbian GNU/Linux 10 (buster)
Release:    10
Codename:   buster

Ive instructions for installing dependencies for no X11 / FFMPEG and ran cmake with no X11 flags.

How do I resolve the card1 / card0 issue?