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

Legacy camera stack under Bullseye

Tue Nov 09, 2021 5:16 pm

As per the blog post for the release of Raspberry Pi OS Bullseye, the default camera stack is now libcamera. There are the libcamera versions of the raspivid and raspistill that are largely a drop in replacement.

There are a couple of use cases that aren't handled by libcamera at present, in particular handling two simultaneous cameras, and stereoscopic capture (both of which are only relevant on Compute Modules). Those will be implemented in the fullness of time, but aren't implemented as yet.
Python bindings for libcamera are in the pipeline.

If there is a DESPERATE need to revert to the old camera stack, then it is possible.
- Edit /boot/config.txt, remove the line "camera_auto_detect=1", and add "start_x=1" and "gpu_mem=128". Rebooting at this stage will reload the old V4L2 driver. Stop at this point if that is sufficient for your needs.

If you need raspistill/vid, then build the userland libraries for yourself.

Code: Select all

cd ~
sudo apt install cmake
mkdir bin
git clone https://github.com/raspberrypi/userland
cd userland
./buildme
cp build/bin/* ~/bin/
If a "bin" directory exists in your home directory, then the default .profile adds it to your path, hence it will find these copies of the binaries.
If you need the binary accessible by all users, then copying them into /usr/local/bin would be the normal solution.

Note that with the graphics stack having been changed to be Full KMS by default, then the firmware can no longer a a preview display to the screen. Please use the -n option (for no preview), or edit /boot/config.txt again and change "dtoverlay=vc4-kms-v3d" to "dtoverlay=vc4-fkms-v3d".
Second note, this is still 32bit only. MMAL support on 64bit is still partially broken.
Software Engineer at Raspberry Pi Ltd. Views expressed are still personal views.
I'm not interested in doing contracts for bespoke functionality - please don't ask.

User avatar
MRV
Posts: 185
Joined: Thu Jul 19, 2018 3:09 am

Re: Legacy camera stack under Bullseye

Tue Nov 09, 2021 5:49 pm

Made a bin folder for pi user
Then ran cp build/bin/* ~/bin/
I can now call Raspivid as pi user.

How do we make the Raspivid app available to all users from any location? sudo (root) etc?

Sincerely
DESPERATE Person

UPDATE
Never mind, I got it.
Just run cp build/bin/* ../../bin/
Raspivid can now be called by Pi, sudo users etc.
Last edited by MRV on Tue Nov 09, 2021 5:59 pm, edited 1 time in total.

User avatar
nsayer
Posts: 84
Joined: Thu Jun 26, 2014 12:43 am

Re: Legacy camera stack under Bullseye

Tue Nov 09, 2021 5:56 pm

Those steps to restore the legacy camera stack do not work.

File "/usr/lib/python3/dist-packages/picamera/exc.py", line 184, in mmal_check
raise PiCameraMMALError(status, prefix)
picamera.exc.PiCameraMMALError: Failed to create MMAL component b'vc.camera_info': Function not implemented

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

Re: Legacy camera stack under Bullseye

Tue Nov 09, 2021 6:05 pm

MRV wrote:
Tue Nov 09, 2021 5:49 pm
Made a bin folder for pi user
Then ran cp build/bin/* ~/bin/
I can now call Raspivid as pi user.

How do we make the Raspivid app available to all users from any location? sudo (root) etc?

Sincerely
DESPERATE Person

UPDATE
Never mind, I got it.
Just run cp build/bin/* ../../bin/
Raspivid can now be called by Pi, sudo users etc.
Put them in a directory that is on the default path? /usr/local/bin would be the typical one to use.
Software Engineer at Raspberry Pi Ltd. Views expressed are still personal views.
I'm not interested in doing contracts for bespoke functionality - please don't ask.

User avatar
MRV
Posts: 185
Joined: Thu Jul 19, 2018 3:09 am

Re: Legacy camera stack under Bullseye

Tue Nov 09, 2021 6:10 pm

6by9 wrote:
Tue Nov 09, 2021 6:05 pm
MRV wrote:
Tue Nov 09, 2021 5:49 pm
Made a bin folder for pi user
Then ran cp build/bin/* ~/bin/
I can now call Raspivid as pi user.

How do we make the Raspivid app available to all users from any location? sudo (root) etc?

Sincerely
DESPERATE Person

UPDATE
Never mind, I got it.
Just run cp build/bin/* ../../bin/
Raspivid can now be called by Pi, sudo users etc.
Put them in a directory that is on the default path? /usr/local/bin would be the typical one to use.
Ok, seems to be (tentatively) working again.
Haven’t tried recording from cameras yet but calling Raspivid seems to work for all users…

User avatar
nsayer
Posts: 84
Joined: Thu Jun 26, 2014 12:43 am

Re: Legacy camera stack under Bullseye

Tue Nov 09, 2021 6:12 pm

And now, basically, neither stack works.

% libcamera-hello
[0:01:32.611673997] [815] INFO Camera camera_manager.cpp:293 libcamera v0.0.0+3156-f4070274
[0:01:32.714763463] [815] INFO Camera camera.cpp:937 configuring streams: (0) 1640x1232-YUV420
[0:01:32.714941641] [817] INFO RPI raspberrypi.cpp:122 Mode: 3280x2464 fmt RG10 Score: 2218 (best 2218)
[0:01:32.715019082] [817] INFO RPI raspberrypi.cpp:122 Mode: 1920x1080 fmt RG10 Score: 2041.48 (best 2041.48)
[0:01:32.715061766] [817] INFO RPI raspberrypi.cpp:122 Mode: 1640x1232 fmt RG10 Score: 1500 (best 1500)
[0:01:32.715100505] [817] INFO RPI raspberrypi.cpp:122 Mode: 640x480 fmt RG10 Score: 5004.81 (best 1500)
[0:01:32.715142226] [817] INFO RPI raspberrypi.cpp:122 Mode: 3280x2464 fmt pRAA Score: 1718 (best 1500)
[0:01:32.715180724] [817] INFO RPI raspberrypi.cpp:122 Mode: 1920x1080 fmt pRAA Score: 1541.48 (best 1500)
[0:01:32.715217778] [817] INFO RPI raspberrypi.cpp:122 Mode: 1640x1232 fmt pRAA Score: 1000 (best 1000)
[0:01:32.715254332] [817] INFO RPI raspberrypi.cpp:122 Mode: 640x480 fmt pRAA Score: 4504.81 (best 1000)
[0:01:32.715293886] [817] INFO RPI raspberrypi.cpp:122 Mode: 3280x2464 fmt RGGB Score: 3218 (best 1000)
[0:01:32.715330829] [817] INFO RPI raspberrypi.cpp:122 Mode: 1920x1080 fmt RGGB Score: 3041.48 (best 1000)
[0:01:32.715366865] [817] INFO RPI raspberrypi.cpp:122 Mode: 1640x1232 fmt RGGB Score: 2500 (best 1000)
[0:01:32.715403290] [817] INFO RPI raspberrypi.cpp:122 Mode: 640x480 fmt RGGB Score: 6004.81 (best 1000)
[0:01:32.715543136] [817] INFO RPI raspberrypi.cpp:620 Sensor: /base/soc/i2c0mux/i2c@1/imx219@10 - Selected mode: 1640x1232-pRAA
[0:01:34.718915141] [817] ERROR IPCPipe ipc_pipe_unixsocket.cpp:132 Call timeout!
[0:01:34.718992897] [817] ERROR IPCPipe ipc_pipe_unixsocket.cpp:64 Failed to call sync
[0:01:34.719025155] [817] ERROR IPAProxy raspberrypi_ipa_proxy.cpp:359 Failed to call configure
[0:01:34.719056821] [817] ERROR RPI raspberrypi.cpp:1306 IPA configuration failed!
[0:01:34.719092893] [817] ERROR RPI raspberrypi.cpp:757 Failed to configure the IPA: -32
ERROR: *** failed to configure streams ***

I have now tried every possible permutation in config.txt of commenting the following in or out:

camera_auto_detect=1
start_x=1
gpu_mem=128

arm_64bit=1

[pi4]
dtoverlay=vc4-fkms-v3d
max_framebuffers=2

My pi 4 with a camera module 2 NOIR is essentially bricked.

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

Re: Legacy camera stack under Bullseye

Tue Nov 09, 2021 6:20 pm

PLEASE KEEP THIS THREAD CLEAR OF GENERAL CHAT.
I will try to help out and update the first post with improvements, but will delete general chat posts (eg "me too").
Software Engineer at Raspberry Pi Ltd. Views expressed are still personal views.
I'm not interested in doing contracts for bespoke functionality - please don't ask.

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

Re: Legacy camera stack under Bullseye

Tue Nov 09, 2021 6:20 pm

nsayer wrote:
Tue Nov 09, 2021 6:12 pm
My pi 4 with a camera module 2 NOIR is essentially bricked.
No, you take the SD card out and write a new image to it. Actually bricking a Pi is pretty difficult.
Software Engineer at Raspberry Pi Ltd. Views expressed are still personal views.
I'm not interested in doing contracts for bespoke functionality - please don't ask.

User avatar
MRV
Posts: 185
Joined: Thu Jul 19, 2018 3:09 am

Re: Legacy camera stack under Bullseye

Tue Nov 09, 2021 8:19 pm

Ok. I can confirm that dual-camera support works if 6by9’s instructions are followed to re-implement Userland over a fresh install of Bullseye.
This is good.

However
The I2C-microphone on my CM4 carrier board no longer works.

Put i2s-soundcard.dtbo in boot/overlays

boot/config.txt:
dtparam=i2c_arm=on
dtoverlay=i2s-soundcard
dtparam=i2s=on

I now get the following error (that I did not have in Buster)

Code: Select all

root@raspberrypi:/# arecord --dump-hw-params -D hw:1,0
arecord: main:830: audio open error: No such file or directory

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

Re: Legacy camera stack under Bullseye

Tue Nov 09, 2021 8:29 pm

MRV wrote:
Tue Nov 09, 2021 8:19 pm
Ok. I can confirm that dual-camera support works if 6by9’s instructions are followed to re-implement Userland over a fresh install of Bullseye.
This is good.

However
The I2C-microphone on my CM4 carrier board no longer works.

Put i2s-soundcard.dtbo in boot/overlays

boot/config.txt:
dtparam=i2c_arm=on
dtoverlay=i2s-soundcard
dtparam=i2s=on

I now get the following error (that I did not have in Buster)

Code: Select all

root@raspberrypi:/# arecord --dump-hw-params -D hw:1,0
arecord: main:830: audio open error: No such file or directory
Not related to camera as far as I can tell. Please start another thread.
Principal Software Engineer at Raspberry Pi Ltd.
Working in the Applications Team.

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

Re: Legacy camera stack under Bullseye

Tue Nov 09, 2021 8:31 pm

nsayer wrote:
Tue Nov 09, 2021 5:56 pm
Those steps to restore the legacy camera stack do not work.

File "/usr/lib/python3/dist-packages/picamera/exc.py", line 184, in mmal_check
raise PiCameraMMALError(status, prefix)
picamera.exc.PiCameraMMALError: Failed to create MMAL component b'vc.camera_info': Function not implemented
That is not the original camera stack, that is the third party picamera Python binding.

Why do you need the legacy camera system? If you are on the Pi4, you should be able to use libcamera apps.
Principal Software Engineer at Raspberry Pi Ltd.
Working in the Applications Team.

joecarl
Posts: 11
Joined: Tue Nov 09, 2021 7:20 pm

Re: Legacy camera stack under Bullseye

Tue Nov 09, 2021 8:42 pm

jamesh wrote:
Tue Nov 09, 2021 8:31 pm
nsayer wrote:
Tue Nov 09, 2021 5:56 pm
Those steps to restore the legacy camera stack do not work.

File "/usr/lib/python3/dist-packages/picamera/exc.py", line 184, in mmal_check
raise PiCameraMMALError(status, prefix)
picamera.exc.PiCameraMMALError: Failed to create MMAL component b'vc.camera_info': Function not implemented
That is not the original camera stack, that is the third party picamera Python binding.

Why do you need the legacy camera system? If you are on the Pi4, you should be able to use libcamera apps.
I don't understand... can you please provide link or explnation about how to replace my python picamera code with non legacy stuff?

Thanks so much.

wumfi
Posts: 15
Joined: Fri Dec 02, 2011 3:09 pm

Re: Legacy camera stack under Bullseye

Tue Nov 09, 2021 10:06 pm

I think the main problem is that we have been informed that the camera system has been migrated to libcamera, but received no guidance on actually how to use it from a noob/user perspective.

It used to be easy, and you could spin up a camera stream from the command line. Now all we’ve been given is a notice that it’s changed, and links to documentation that basic users will not be able to follow.

When the Pi first came out, it was very much geared to kids and tinkerers. The documentation was spot on and easy to read. This latest camera change seems to go against the very ethos that the foundation was formed upon.
Last edited by wumfi on Wed Nov 10, 2021 7:53 pm, edited 2 times in total.

User avatar
nsayer
Posts: 84
Joined: Thu Jun 26, 2014 12:43 am

Re: Legacy camera stack under Bullseye

Wed Nov 10, 2021 1:40 am

jamesh wrote:
Tue Nov 09, 2021 8:31 pm
nsayer wrote:
Tue Nov 09, 2021 5:56 pm
Those steps to restore the legacy camera stack do not work.

File "/usr/lib/python3/dist-packages/picamera/exc.py", line 184, in mmal_check
raise PiCameraMMALError(status, prefix)
picamera.exc.PiCameraMMALError: Failed to create MMAL component b'vc.camera_info': Function not implemented
That is not the original camera stack, that is the third party picamera Python binding.

Why do you need the legacy camera system? If you are on the Pi4, you should be able to use libcamera apps.
So, this has been a journey of extreme pain over the last couple of months.

I have a picamera script that for a long time worked just fine. A couple months ago, I switched from buster to bullseye. It continued to work. Then libraspberrypi0 and libraspberrypi-bin, libraspberrypi-bootloader and libraspberrypi-dev were updated beyond 20210831. Picamera has not worked since. I have, for a while, downgraded those packages to the last version that worked, and that was fine. But picamera, it would seem, does not work with anything beyond that.

I am using picamera because I want to stream MJPEG over HTTP within a simple static frame. So far as I have found, there is no other solution to this problem.

As a test, I was able to use libcamera-vid briefly to stream h264 over TCP, but that is not what I want. And in experimenting today, even that now seems to be broken, and no permutation of config.txt options listed anywhere seem to work.

In the midst of all of this, my honest and earnest requests for assistance have been met with pushback and attitude - here and elsewhere - that I feel have been entirely unjustified.

EDIT: And, once again, downgrading the boatloader and libraspberrypi0 and related packages back to 20210831 works and picamera is able to see the hardware, so this is definitely a software problem. I guess I am going to just have to mark-hold those packages indefinitely and just tell anyone who asks that Raspberry Pi camera support beyond there doesn't work. Because I have no evidence that it does.

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

Re: Legacy camera stack under Bullseye

Wed Nov 10, 2021 7:17 am

The Picamera issue looks to be that the compiler update in Buster has changed the default for --no-as-needed flag, and as mmal_vc_client relies on a constructor only to register the relevant component support, the compiler thinks it isn't needed and removes it. https://github.com/raspberrypi/userland/issues/178
I'll look at giving up on the architectural stance that mmal_vc_client isn't a dependency on mmal_core but of the app, and look to merge the two.
Software Engineer at Raspberry Pi Ltd. Views expressed are still personal views.
I'm not interested in doing contracts for bespoke functionality - please don't ask.

User avatar
nsayer
Posts: 84
Joined: Thu Jun 26, 2014 12:43 am

Re: Legacy camera stack under Bullseye

Wed Nov 10, 2021 7:56 am

Thank you.

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

Re: Legacy camera stack under Bullseye

Wed Nov 10, 2021 9:09 am

wumfi wrote:
Tue Nov 09, 2021 10:06 pm
I think the main problem is that have been informed that the camera system has been migrated to libcamera, but received no guidance on actually how to use it from a noob/user perspective.

It used to be easy, and you could spin up a camera stream from the command line. Now all we’ve been given is a notice that it’s changed, and links to documentation that basic users will not be able to follow.

When the Pi first came out, is was very much geared to kids and tinkerers. The documentation was spot on and easy to read. This latest camera change seems to go against the very ethos that the foundation was formed upon.
This documentation would be worth a read.

https://www.raspberrypi.com/documentati ... amera.html
Principal Software Engineer at Raspberry Pi Ltd.
Working in the Applications Team.

btidey
Posts: 1677
Joined: Sun Feb 17, 2013 6:51 pm

Re: Legacy camera stack under Bullseye

Wed Nov 10, 2021 1:01 pm

I am interested in trying to use the legacy stack method, at least in the short term, to support the raspimjpeg process used in RPi Cam Web Interface software. One reason is to maintain good performance even on Pi Zeros which are commonly used with this software.

Currently for buster I install the raspimjpeg executable into the /opt/vc/bin folder where the raspivid and raspistill processes used to live (with links from /usr/bin)

For bullseye if I set up legacy stack support as suggested then I'd like to avoid making the whole userland on each install.

So my questions are what dependencies would there be. E.g. is it sufficient to say install what was in buster under /opt/vc/lib, or do I need anything else.

User avatar
RichShumaker
Posts: 406
Joined: Tue Jul 31, 2012 4:16 pm
Location: Sunny Southern CA near downtown LA

Re: Legacy camera stack under Bullseye

Wed Nov 10, 2021 5:25 pm

Your original post does not discuss that you can't have both. Either you use Libcamera OR RasPiStii(vid).
Or am I wrong you can have both?

Either way if you could add which one it is to the original post to avoid confusion that would be awesome.

And Now I understand from reading your post. With the switch to KMS Desktop Direct Preview has been removed. So if you need a Direct Preview as I do I need to stay with an older release. Or find a Libcamera to KMS Desktop(or other software) Method to do something similar.
Rich Shumaker
http://www.instructables.com/id/Pi-Zero-W-NoIR-8MP-Camera-Build-Overview-Introduct/

User avatar
MRV
Posts: 185
Joined: Thu Jul 19, 2018 3:09 am

Re: Legacy camera stack under Bullseye

Thu Nov 11, 2021 10:52 am

I can tentatively confirm that the legacy stack, for Raspivid and 3D stereoscopic recording, is fully operational on a clean install of Bullseye.

Step 1:
sudo -s
raspi-config > Interface Options: (enable)
Camera
I2C

Step 2:
root directory > nano boot/config.txt
add:
start_x=1
gpu_mem=256

comment out:
#camera_auto_detect=1

Step 3:
root directory >
git clone https://github.com/raspberrypi/userland
cd userland
./buildme
sudo cp build/bin/* ../usr/local/bin/

Step 4: (optional)
For 3D stereo, add your dt-blob.bin file to the boot directory.

btidey
Posts: 1677
Joined: Sun Feb 17, 2013 6:51 pm

Re: Legacy camera stack under Bullseye

Thu Nov 11, 2021 9:26 pm

I can verify this method of enabling legacy stack allow the RPi Cam software using the raspimjpeg process to run under Bullseye. I haven't checked all functionality but it looks OK.

Some experimentation indicated the raspimjpeg process would run without any extra userland so what I did was to make the legacy stack changes to config.txt, make the dir /opt/vc/bin, and then run the normal RPi Cam installer. This actually still uses the raspimjpeg binary compiled under Buster but that seems OK.

Thanks to all in this thread to give me a good workaround for the moment.

User avatar
MRV
Posts: 185
Joined: Thu Jul 19, 2018 3:09 am

Re: Legacy camera stack under Bullseye

Sat Nov 13, 2021 12:46 pm

UPDATE NOV 13

I am testing 2 CM4 carrier boards. One with a fresh install of Buster 10 and the other with a fresh install of Bullseye 11. Both boards have 2 attached cameras for stereo recording. They are each powered by a single LiPo battery and have a USB-C port.

When the Bullseye board is powered on with the USB-C cable attached (to wall power), the device does not complete it’s boot sequence and fails to operate. When the USB-C cable is removed, and the device is powered exclusively by the LiPo battery, it turns on fine. With one camera (not 2) attached, the board will power on with the USB-C power attached. So, the issue under Buster is related to powering on the device via USB-C with 2 cameras attached.


The Buster board works fine in all cases.

My goal has been to get the Bullseye board fully operational so users of the (open-source) project would not encounter issues if they attempted to upgrade a Buster board to Bullseye on their own.

User avatar
smoothlapse
Posts: 6
Joined: Sat Oct 09, 2021 9:55 pm

Re: Legacy camera stack under Bullseye

Sun Nov 14, 2021 8:21 pm

Following OP's instructions enables a live stream to work using MjpgStreamer. Thank you for this.

Although, even after following the instructions from OP and MRV a few posts back, we still get the following exception when trying to use the MMALSharp library (running C# code compiled under .net Core):

Code: Select all

[FTL] System.TypeInitializationException: The type initializer for ' . ' threw an exception.
 ---> MMALSharp.MMALNotImplementedException: Function not implemented. Unable to create component
   at MMALSharp.MMALNativeExceptionHelper.MMALCheck(MMAL_STATUS_T status, String message)
   at MMALSharp.MMALComponentBase.CreateComponent(String name)
   at MMALSharp.MMALComponentBase..ctor(String name)
   at MMALSharp.Components.MMALDownstreamComponent..ctor(String name)
   at MMALSharp.Components.MMALRendererBase..ctor(String name)
   at MMALSharp.Components.MMALNullSinkComponent..ctor()
See this issue: https://github.com/techyian/MMALSharp/issues/203
It seems to be an MMAL issue rather than an MMALSharp issue.
Is there anything we can do above and beyond the steps in OP's post to get this to work?

longo92
Posts: 128
Joined: Mon Sep 03, 2018 3:45 pm
Location: Pisa-Italy

Re: Legacy camera stack under Bullseye

Mon Nov 15, 2021 2:32 pm

Hi, is there also a way to restore the dispmanx stack ? I have successfully enabled the old camera stack, but for the preview using opengl dispmanx is requested.

Thanks,
Alessandro

cdgru
Posts: 1
Joined: Mon Oct 11, 2021 3:59 pm

Re: Legacy camera stack under Bullseye

Wed Nov 17, 2021 9:37 am

Herewith I can confirm that the proposed changes in /boot/config.txt solved even my problem with
webRTC using chromium and RASPICAM under bulls eye!

The problem can be reproduced, entering e.g. https://webrtc.github.io/samples/src/co ... media/gum/ in chromium address line.
Chromium only showing black HTML5 RASPICAM stream.
Under buster I had no problem.

I also want to mention, that there does exist an chromium related issue concerning webRTC and RASPICAM with chromium versions > 88, independent of bulls eye or buster.
In this case chromium https://webrtc.github.io/samples/src/co ... media/gum/ does throw a get user media error: "requested device not found".
The issue already is known (see viewtopic.php?p=1918621) and I am ok with the chromium 88 fall back.


Anyways, thank You very much for all Your competent and very usefull contributions which did help me so much!

Best Regards,
Claus

Return to “Camera board”