lagurus
Posts: 49
Joined: Wed Aug 07, 2013 8:02 am

raspistill on RPI4 - failed to add service

Thu Apr 16, 2020 9:19 am

Hi all,
when is started following:

Code: Select all

raspistill --gl --glscene sobel
it return only

Code: Select all

* failed to add service - already in use?
Configuration: RPI 4 4GB running Raspbian Buster.

For older model (PI,PI2B,PI3B) it works.

Any chance to get it work again?
Thanks.

6by9
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 9356
Joined: Wed Dec 04, 2013 11:27 am
Location: ZZ9 Plural Z Alpha, aka just outside Cambridge.

Re: raspistill on RPI4 - failed to add service

Thu Apr 16, 2020 2:56 pm

lagurus wrote:
Thu Apr 16, 2020 9:19 am
Any chance to get it work again?
Not without significant reworking.
The Pi4 has the next generation of the 3D core, and the firmware doesn't know how to drive it. You need to use the desktop Mesa GL stack instead of the firmware GLES driver.
Software Engineer at Raspberry Pi Trading. Views expressed are still personal views.
I'm not interested in doing contracts for bespoke functionality - please don't ask.

lagurus
Posts: 49
Joined: Wed Aug 07, 2013 8:02 am

Re: raspistill on RPI4 - failed to add service

Fri Apr 17, 2020 4:47 pm

Not without significant reworking.
The Pi4 has the next generation of the 3D core, and the firmware doesn't know how to drive it. You need to use the desktop Mesa GL stack instead of the firmware GLES driver.
Any chance to make it oneself?
Is enough to modify raspicam tree - e.g. files like RapiTex.c and RaspiTexUtil.h?
Or is needed to change also something deeper - e.g. in firmware?

jamesh
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 26888
Joined: Sat Jul 30, 2011 7:41 pm

Re: raspistill on RPI4 - failed to add service

Fri Apr 17, 2020 4:52 pm

lagurus wrote:
Fri Apr 17, 2020 4:47 pm
Not without significant reworking.
The Pi4 has the next generation of the 3D core, and the firmware doesn't know how to drive it. You need to use the desktop Mesa GL stack instead of the firmware GLES driver.
Any chance to make it oneself?
Is enough to modify raspicam tree - e.g. files like RapiTex.c and RaspiTexUtil.h?
Or is needed to change also something deeper - e.g. in firmware?
You would need to rework the raspicam code to use the Mesa GL stack instead of the current mechanism which uses the firmware 3D. I am no expert on this, I suspect it's feasible, but I have no idea how to do it. Probably not a huge amount of work for someone who is familiar with the Mesa, but not trivial.
Principal Software Engineer at Raspberry Pi (Trading) Ltd.
Contrary to popular belief, humorous signatures are allowed.
I've been saying "Mucho" to my Spanish friend a lot more lately. It means a lot to him.

lagurus
Posts: 49
Joined: Wed Aug 07, 2013 8:02 am

Re: raspistill on RPI4 - failed to add service

Fri Jul 17, 2020 10:03 am

Resurrecting old post.

Finally I had time and tried to modify my code.
It seems that error message:

Code: Select all

* failed to add service - already in use?
is gone.

I am using Mesa GL. For creation is used DRM/GBM stuff (beacuse I am headless).
Also was needed to link program with GLESv2,EGL instead of brcmGLESv2,brcmEGL

Some functions are not defined in MESA EGL and need to be added dynamically using eglGetProcAddress e.g.:

eglCreateImageKHR
eglDestroyImageKHR
glEGLImageTargetTexture2DOES


But now receive EGL error 0x300c in function raspitexutil_do_update_texture during calling of
eglCreateImageKHR
. Error 0x300c = EGL_BAD_PARAMETER.

I have noticed that function eglCreateImageKHR was originally defined in egl_khr_image_client.c which I think is used when
is program linked against brcmEGL. But MESA EGL hasn't it defined it in such way and don't know anything about:

EGL_IMAGE_BRCM_MULTIMEDIA,EGL_IMAGE_BRCM_MULTIMEDIA_Y,EGL_IMAGE_BRCM_MULTIMEDIA_U,EGL_IMAGE_BRCM_MULTIMEDIA_V

Some tips how to solve this issue?
How to add support to PI4? I have used it on PI1/2/3 for fast image processing using shaders.

Thank you.

bhjel
Posts: 55
Joined: Tue Jan 01, 2019 2:00 am

Re: raspistill on RPI4 - failed to add service

Wed Sep 09, 2020 9:02 pm

Same issue - I have swapped out dispmanX with X11 for the userland demos and I am linking the latest MESA openglES 3.1. Not sure how to address the following methods just yet:
eglCreateImageKHR
eglDestroyImageKHR
glEGLImageTargetTexture2DOES

There is progress with eglGetProcAddress(), but I'm not sure how to handle this EGL_IMAGE_BRCM_MULTIMEDIA dependency.

therealdavidp
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 76
Joined: Tue Jan 07, 2020 9:15 am

Re: raspistill on RPI4 - failed to add service

Thu Sep 10, 2020 8:04 am

I think I had something similar. I got round it by downloading, building and installing this: https://github.com/anholt/libepoxy

Disclaimer: I know nothing whatsoever about GL, EGL, OpenGL, OpenGLES, MESA.

bhjel
Posts: 55
Joined: Tue Jan 01, 2019 2:00 am

Re: raspistill on RPI4 - failed to add service

Fri Sep 11, 2020 12:14 pm

Thank you - that gave me some clues.
I'm very close now - through the mmal api I am getting proper RGBA frames (judging by the contents of the buffer). glEGLImageTargetTexture2DOES(GL_TEXTURE_EXTERNAL_OES,...) continues to return error 1282, and I have a feeling that I am missing some context on what exactly isn't allowed with V3D / VC6. Which targets should I be using for createImageKHR, glEGLImageTargetTexture2DOES, etc? What preview port encoding should be used for this no-copy use-case?

charliebravo
Posts: 3
Joined: Wed Sep 23, 2020 10:16 am

Re: raspistill on RPI4 - failed to add service

Wed Sep 23, 2020 10:30 am

Hello!

I found this thread after running into a dreaded "* failed to add service" message. It seems to me that no matter what I do (and I tried setting up brcmEGL with drm/gbm and separately with dispmanx), current version of brcmEGL fails on RPi 4.

I tried hard to make mesa EGL/GL work with MMAL buffers, but no dice. My impression is that eglCreateImageKHR in MESA libs simply doesn't "know" EGL_IMAGE_BRCM_MULTIMEDIA, for I am also getting 0x500c (or EGL_BAD_PARAMETER).

@bhjel - what you wrote suggests that you were able to get past eglCreateImageKHR error. How you did that? In my code I am basically following what raspistill does, and I keep getting 0x500c on eglCreateImageKHR.

Anybody knows how it is supposed to be solved? Is it possible for Broadcom features to be added to Mesa or do we have to wait for brcmEGL/GL supporting Pi4?

charliebravo
Posts: 3
Joined: Wed Sep 23, 2020 10:16 am

Re: raspistill on RPI4 - failed to add service

Sat Sep 26, 2020 6:02 pm

OK, I got it to work on RPi 4. I did it the following way:
- Used MESA EGL/GLES (so -lEGL, -lGLESv2, without "brcm")
- Took code from https://github.com/6by9/drm_mmal/blob/export/drm_mmal.c as an example for decoding video via MMAL into dma_bufs
- Used EGL_MESA_image_dma_buf_import to create EGLImage with eglCreateImageKHR

About the only problem is that performance drops to 40+FPS, and about 20% of CPU is being used. I guess that at some point EGL/GL decides to blit/convert the image to format compatible with GPU textures, and that it is done on the CPU :-(

Return to “Camera board”