Open Thebeefed opened 3 years ago
did you enable the camera yet? you can use raspi-config
for that. The info is in the documentation though
I have this same problem, but instead of I/O error, I get Function not implemented. This was with a fully working script. apt-get upgrade broke it. I've opened another issue for this.
I upgrade to bullseye and got in the same situation. Unfortunately it doesn't promising to get fixed soon.
https://raspberrypi.stackexchange.com/questions/132145/software-upgrade-broke-camera
My error is slightly different:
pi@raspberrypi3:~ $ ipython3 Python 3.9.2 (default, Mar 12 2021, 04:06:34) Type 'copyright', 'credits' or 'license' for more information IPython 7.20.0 -- An enhanced Interactive Python. Type '?' for help.
In [1]: from picamera import PiCamera
PiCameraMMALError Traceback (most recent call last)
With regard Bullseye (released on 7th November, so TOTALLY unrelated to this issue), the blog post about the release is fairly plain. https://www.raspberrypi.com/news/raspberry-pi-os-debian-bullseye/
New camera driver
The driver used by Raspberry Pi to access camera modules has now been replaced with libcamera, a standard Linux API. As with the video driver change, this means less closed-source proprietary code, and makes it easier for third parties to develop new camera hardware and software.
For anyone who has written camera-based applications in the past, this is a very significant change, and is too large to be covered here. There will be a blog post dedicated to the new camera driver published soon, so watch this space!
@6by9 I was going to mention that I got it working after install libcamera-tools and libcamera-apps.
So the picamera package has wrong dependencies.
libcamera-tools and libcamera-apps have no relation to picamera - they will not reinstall the MMAL dependencies which picamera relies on.
The legacy camera stack (including picamera) is not officially supported on Bullseye.
So @6by9 what would be fix for that? I may missed that point. It works via libcamera-tools, but remains complaining w/ "'vc.camera_info': Function not implemented".
I can see it is defined at header files:
$ grep -r camera_info /usr/include/interface/mmal/ /usr/include/interface/mmal/util/mmal_default_components.h:# define MMAL_COMPONENT_DEFAULT_CAMERA_INFO "camera_info" /usr/include/interface/mmal/util/mmal_default_components.h:# define MMAL_COMPONENT_DEFAULT_CAMERA_INFO "vc.camera_info"
So this means that picamera either needs to be rewritten against libcamera or it becomes abandonware.
If I understand the announcement correctly, it does imply that if the work were to get done it would mean that picamera would be applicable for platforms beyond the Raspberry Pi because libcamera is apparently a standard facility across multiple Linux variants.
You can still enable the legacy stack, but the default is now libcamera. https://forums.raspberrypi.com/viewtopic.php?t=323390
Python bindings for libcamera are already in the works.
@6by9 Thank you for posting the link to the topic in the Raspberry Pi forums. It enabled me to reuse the old stack.
I think that this is a big issue which doesn't get enough visibility. Googling for answers does barely yield any useful results, and the news post [0] from the foundation about this changes should give the user hints to how to re-enable the old behavior.
There are things the new stack can't do (at this time) which might break old code, in my case it was picamera
, on which I relied to stream the video with a current timestamp and preform image snapshots in parallel at a given time interval.
In any case, I will copy your code into this issue, should the forum become inaccessible:
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.
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.
[0] https://www.raspberrypi.com/news/an-open-source-camera-stack-for-raspberry-pi-using-libcamera/
That's not enough. If you attempt this with the current libraspberrypi0/bootloader packages, what you get is "Failed to create MMAL component b'vc.camera_info': Function Not Implemented." You have to backtrack those packages to the 20210831-1 versions for now.
You have to backtrack those packages to the 20210831-1 versions for now.
What does that mean? How do I do that?
Go to http://archive.raspberrypi.org/debian/pool/main/r/raspberrypi-firmware/
Download
libraspberrypi0_1.20210831-1_armhf.deb libraspberrypi-bin_1.20210831-1_armhf.deb libraspberrypi-dev_1.20210831-1_armhf.deb libraspberrypi-doc_1.20210831-1_armhf.deb raspberrypi-bootloader_1.20210831-1_armhf.deb
as root, do "dpkg -i " for all those files. You may need to remove vcdbg or make other package adjustments so that those fit.
Afterwards, do "apt-mark hold" for all of them so that future apt upgrades don't overwrite them until that bug gets fixed.
@nsayer How safe is this downgrading? Does it have side-effects? Also, can it be completely reverted by "unholding" them and then issuing an apt-get update & apt-get upgrade
?
Well, it worked fine for me.
And, yes, un-holding and upgrading is sufficient to undo this.
This is what worked for me:
wget http://archive.raspberrypi.org/debian/pool/main/r/raspberrypi-firmware/raspberrypi-bootloader_1.20210831-1_armhf.deb
wget http://archive.raspberrypi.org/debian/pool/main/r/raspberrypi-firmware/libraspberrypi0_1.20210831-1_armhf.deb
wget http://archive.raspberrypi.org/debian/pool/main/r/raspberrypi-firmware/libraspberrypi-bin_1.20210831-1_armhf.deb
wget http://archive.raspberrypi.org/debian/pool/main/r/raspberrypi-firmware/libraspberrypi-dev_1.20210831-1_armhf.deb
wget http://archive.raspberrypi.org/debian/pool/main/r/raspberrypi-firmware/libraspberrypi-doc_1.20210831-1_armhf.deb
sudo apt purge vcdbg
sudo dpkg -i raspberrypi-bootloader_1.20210831-1_armhf.deb
sudo dpkg -i libraspberrypi0_1.20210831-1_armhf.deb
sudo dpkg -i libraspberrypi-bin_1.20210831-1_armhf.deb
sudo dpkg -i libraspberrypi-dev_1.20210831-1_armhf.deb
sudo dpkg -i libraspberrypi-doc_1.20210831-1_armhf.deb
sudo apt-mark hold raspberrypi-bootloader
sudo apt-mark hold libraspberrypi0
sudo apt-mark hold libraspberrypi-bin
sudo apt-mark hold libraspberrypi-dev
sudo apt-mark hold libraspberrypi-doc
vcdbg
needs to be removed because it is included in libraspberrypi-bin
, else libraspberrypi-bin
would not install.
But I still have a question: doing an apt search raspberrypi
yields:
raspberrypi-bootloader/stable 1:1.20211029-1 armhf [upgradable from: 1:1.20210831-1] -- Raspberry Pi bootloader
libraspberrypi0/stable 1:2+git20210928~141951+6e8f786-2 armhf [upgradable from: 1:1.20210831-1] -- EGL/GLES/OpenVG/etc. libraries for the Raspberry Pi's VideoCore IV
libraspberrypi-bin/stable 1:2+git20210928~141951+6e8f786-2 armhf [upgradable from: 1:1.20210831-1] -- Miscellaneous Raspberry Pi utilities
libraspberrypi-dev/stable 1:2+git20210928~141951+6e8f786-2 armhf [upgradable from: 1:1.20210831-1] -- EGL/GLES/OpenVG/etc. libraries for the Raspberry Pi's VideoCore IV (headers)
libraspberrypi-doc/stable 1:2+git20210928~141951+6e8f786-2 armhf [upgradable from: 1:1.20210831-1] -- EGL/GLES/OpenVG/etc. libraries for the Raspberry Pi's VideoCore IV (headers)
firmware-brcm80211/stable,now 1:20210315-3+rpt3 all [installed] -- Binary firmware for Broadcom/Cypress 802.11 wireless cards
libraspberrypi-bin-dbgsym/stable 1:2+git20210928~141951+6e8f786-2 armhf -- debug symbols for libraspberrypi-bin
libraspberrypi0-dbgsym/stable 1:2+git20210928~141951+6e8f786-2 armhf -- debug symbols for libraspberrypi0
raspberrypi-kernel/stable,now 1:1.20211029-1 armhf [installed] -- Raspberry Pi bootloader
raspberrypi-kernel-headers/stable 1:1.20211029-1 armhf -- Header files for the Raspberry Pi Linux kernel
raspberrypi-net-mods/stable,now 1.3.2 all [installed] -- Network configuration for the Raspberry Pi UI
raspberrypi-sys-mods/stable,now 20211005+bullseye armhf [installed] -- System tweaks for the Raspberry Pi
raspberrypi-ui-mods/stable 1.20211110 armhf -- Config to customise the LXDE UI for the Raspberry Pi
So I'm wondering how safe it is to leave the latter not-upgradeable entries at the newest version, specially libraspberrypi-bin-dbgsym
and libraspberrypi0-dbgsym
In any case, thank you for your help, because now it works.
Another question: libraspberrypi-bin
contains /usr/bin/raspistill
and /usr/bin/raspivid
, at least according to https://packages.ubuntu.com/focal-updates/arm64/libraspberrypi-bin/filelist
So, could it be that it is not necessary to compile and install userland as described above ( where git clone https://github.com/raspberrypi/userland
is mentioned )?
@6by9
For anyone who has written camera-based applications in the past, this is a very significant change, and is too large to be covered here. There will be a blog post dedicated to the new camera driver published soon, so watch this space!
I really don't believe that this is the right way for the RPi Foundation to communicate such a big change, and I understand why many are frustrated with it.
There are thousands of scripts and examples out there that reference picamera
, and they have been written over many years. There are even Android apps built around the way picamera streams video feeds. I have built many pieces of automation that leverage picamera
to stream and record video between devices, and they've all been broken by the bullseye upgrade.
You can't get away with a random blog post that says "hey guys, FYI we've decided to completely kill the old picamera API, we'll let you know as soon as we have time how you are supposed to migrate your scripts". You can't even expect people to go through blog posts before a dist-upgrade to validate whether anything is going to break upon reboot. This is the best way to get developers pissed, and it has another unfortunate precedent (the way the omxplayer layer has been left to break and rot on its own without viable alternatives). What I would have expected:
picamera
relevant pages (Github, documentation and pypi) should have reported, in big capital letters and with reasonable notice before bullseye was released as a new stable, WARNING: This library is deprecated and is going to break in bullseye, [link to migration steps here]. If people are opening issues on this topic, it probably means that a breaking change wasn't properly communicated.picamera
on bullseye that clearly warns the user about the deprecation.picamera
module provides an API that makes it easier to e.g. start a video stream or record with a preview even for a beginner, without having to mangle with ffmpeg/gstreamer/v4l2/gtk internals. The picamera
module could have simply relied on e.g. a gstreamer wrapper instead of the proprietary interface, while providing the same external interface to maintain back-compatibility with previously written software. I'm pretty sure that lots of beginners out there would have loved a back-compatible way of writing a script to stream a camera feed in three lines of code.We're all happy to see the RPi software finally transition towards a more open-source approach, leaving behind legacy and hard-to-debug software like picamera or omxplayer. But we also expect the alternatives to be properly documented and supported. Many people out there rely on RPi software for stuff like media or camera playback: you can't just break their software without providing and documenting the alternatives.
Raspberry Pi is becoming low-rent Apple.
Python bindings for libcamera are already in the works.
Can we follow progress for this somewhere? Is there a code repo? Thanks!
*UPDATE AS OF 02/08/22** As mentioned by @danielfaust Just a note on @lexodistro 's solution.
According to https://downloads.raspberrypi.org/raspios_armhf/release_notes.txt the 2022-01-28 release re-added support for the old camera stack ("Legacy camera applications and libraries reinstalled") and raspi-config got a new option to enable the legacy stack raspi-config - add option to switch to legacy camera mode.
This means that it is enough to issue a sudo apt update; sudo apt dist-upgrade and after the reboot issue sudo raspi-config to enable the legacy camera stack in the 3 Interface Options-section.
If you were holding the old packages you'd need to unhold them before doing the dist-upgrade:
sudo apt-mark unhold libraspberrypi0 sudo apt-mark unhold libraspberrypi-bin sudo apt-mark unhold libraspberrypi-dev sudo apt-mark unhold libraspberrypi-doc
sudo apt update; sudo apt upgrade and then after the reboot issue the sudo apt dist-upgrade
Original Post with spelling corrections (thanks @worldofchris)
Bro
In order to get the piCamera modules not to throw errors I had to manually update my repositories for bullseye this is important to do or else you will get errors like so
mmal: mmal_component_create_core: could not find component 'vc.camera_info'
Traceback (most recent call last):
File "
To fix this run these commands to update the repositories and remove the vlc errors
sudo apt-get remove --purge vlc-nox
sudo apt-get autoclean
sudo dpkg --configure -a
sudo apt-get -f install
sudo apt-get autoremove
sudo apt-get update
sudo apt-get dist-upgrade
Then make sure to reenable the legacy camera interface
sudo raspi-config
Then enable it
After this do a reboot
sudo reboot
Then send me lots of thanks its quick and dirty but you can run PiCamera on bullseye and then update to Libcamera when they release picamer2 with the python3 bindings!!! be well and hope this helped someone. And I know I know you don't need to use the -get anymore just a habit that's hard to shake.
@lexodistro I think it fixed the problem for me thank you :) However I am not able to use the VNC desktop anymore. Do you have an idea how I can fix this? It says: "Cannot currently show the desktop"
@lexodistro thanks
A million thanks, @lexodistro ! This saved my day :-) I completely agree with BlackLight, btw.
@lexodistro you have saved the day. I was working against the clock to get something ready for an after school club when I hit this issue.
One minor issue. I think you have a typo in your post:
sudo rasps-config
sudo: rasps-config: command not found
Should it be:
sudo raspi-config
?
Thank you SO much though.
Just a note on @lexodistro 's solution.
According to https://downloads.raspberrypi.org/raspios_armhf/release_notes.txt the 2022-01-28 release re-added support for the old camera stack ("Legacy camera applications and libraries reinstalled") and raspi-config
got a new option to enable the legacy stack raspi-config - add option to switch to legacy camera mode
.
This means that it is enough to issue a sudo apt update; sudo apt dist-upgrade
and after the reboot issue sudo raspi-config
to enable the legacy camera stack in the 3 Interface Options
-section.
If you were holding the old packages you'd need to unhold them before doing the dist-upgrade
:
sudo apt-mark unhold libraspberrypi0
sudo apt-mark unhold libraspberrypi-bin
sudo apt-mark unhold libraspberrypi-dev
sudo apt-mark unhold libraspberrypi-doc
sudo apt update; sudo apt upgrade
and then after the reboot issue the sudo apt dist-upgrade
@worldofchris Goodeye, I should have just copied my terminal history instead of trying to manually retype it here. Yes it should be sudo raspi-config
@danielfaust I just read the update details and this does seem to be the case, I will update my post with your comment, thanks.
I'm using Raspberry Pi 3 Model B+.
vcgencmd get_camera
gives mesupported=1 detected=1
raspistill -o test.jpg
gives me the test.jpg file but also gives this messageThen, I try to run this python code below, but it gives me this error message
Error: