Freenove / Freenove_Big_Hexapod_Robot_Kit_for_Raspberry_Pi

Apply to FNK0052
Other
114 stars 86 forks source link

camera.py fails on RasPi 4 with Raspberry Pi OS Bookworm #29

Closed emendir closed 8 months ago

emendir commented 8 months ago

When testing the camera,on a raspberry pi 4 with the latest Raspberry Pi OS (Bookworm), I got the following error:

Traceback (most recent call last):
  File "/usr/lib/python3.11/threading.py", line 1038, in _bootstrap_inner
    self.run()
  File "/usr/lib/python3.11/threading.py", line 975, in run
    self._target(*self._args, **self._kwargs)
  File "/usr/lib/python3/dist-packages/picamera2/previews/null_preview.py", line 29, in thread_func
    callback(picam2)
  File "/usr/lib/python3/dist-packages/picamera2/previews/drm_preview.py", line 75, in handle_request
    picam2.process_requests(self)
  File "/usr/lib/python3/dist-packages/picamera2/picamera2.py", line 1265, in process_requests
    display.render_request(display_request)
  File "/usr/lib/python3/dist-packages/picamera2/previews/drm_preview.py", line 66, in render_request
    self.render_drm(self.picam2, completed_request)
  File "/usr/lib/python3/dist-packages/picamera2/previews/drm_preview.py", line 145, in render_drm
    raise RuntimeError("Failed to reserve DRM plane")
RuntimeError: Failed to reserve DRM plane
^CTraceback (most recent call last):
  File "/home/hex/Freenove_Big_Hexapod_Robot_Kit_for_Raspberry_Pi/Code/Server/camera.py", line 3, in <module>
    picam2.start_and_capture_file("image.jpg")
  File "/usr/lib/python3/dist-packages/picamera2/picamera2.py", line 1827, in start_and_capture_file
    self.start_and_capture_files(name=name, initial_delay=delay, preview_mode=preview_mode,
  File "/usr/lib/python3/dist-packages/picamera2/picamera2.py", line 1785, in start_and_capture_files
    self.switch_mode_and_capture_file(capture_mode, name.format(i))
  File "/usr/lib/python3/dist-packages/picamera2/picamera2.py", line 1387, in switch_mode_and_capture_file
    return self.dispatch_functions(functions, wait, signal_function, immediate=True)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/picamera2/picamera2.py", line 1304, in dispatch_functions
    return job.get_result() if wait else job
           ^^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/picamera2/job.py", line 79, in get_result
    return self._future.result()
           ^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/concurrent/futures/_base.py", line 451, in result
    self._condition.wait(timeout)
  File "/usr/lib/python3.11/threading.py", line 320, in wait
    waiter.acquire()

OS version: Linux raspberrypi 6.1.0-rpi6-rpi-v8 #1 SMP PREEMPT Debian 1:6.1.58-1+rpt2 (2023-10-27) aarch64 GNU/Linux

Anybody know what the cause and solution might be?

Shaynee-MO commented 8 months ago

Hi! Please run the following commands one by one and send us screenshots of the result. getconf LONG_BIT cat /proc/cpuinfo cat /etc/rpi-issue

And please run this command to see if it takes a photo successfully. libcamera-jpeg -o test.jpg -t 2000 --width 800 --height 600 If it does not work, please send us a screenshot of the error message.

emendir commented 8 months ago

Here are the outputs of the requested commands:

getconf LONG_BIT:

64

cat /proc/cpuinfo

processor   : 0
BogoMIPS    : 108.00
Features    : fp asimd evtstrm crc32 cpuid
CPU implementer : 0x41
CPU architecture: 8
CPU variant : 0x0
CPU part    : 0xd08
CPU revision    : 3

processor   : 1
BogoMIPS    : 108.00
Features    : fp asimd evtstrm crc32 cpuid
CPU implementer : 0x41
CPU architecture: 8
CPU variant : 0x0
CPU part    : 0xd08
CPU revision    : 3

processor   : 2
BogoMIPS    : 108.00
Features    : fp asimd evtstrm crc32 cpuid
CPU implementer : 0x41
CPU architecture: 8
CPU variant : 0x0
CPU part    : 0xd08
CPU revision    : 3

processor   : 3
BogoMIPS    : 108.00
Features    : fp asimd evtstrm crc32 cpuid
CPU implementer : 0x41
CPU architecture: 8
CPU variant : 0x0
CPU part    : 0xd08
CPU revision    : 3

Hardware    : BCM2835
Revision    : c03115
Serial      : 100000001f32c1fd
Model       : Raspberry Pi 4 Model B Rev 1.5

cat /etc/rpi-issue

Raspberry Pi reference 2023-10-10
Generated using pi-gen, https://github.com/RPi-Distro/pi-gen, 962bf483c8f326405794827cce8c0313fd5880a8, stage4

Also, the command libcamera-jpeg -o test.jpg -t 2000 --width 800 --height 600 successfully creates an image file.

Shaynee-MO commented 8 months ago

Please run the following commands one by one to update picamera2 library and then run python camera.py to try again. sudo apt install -y python3-picamera2 sudo apt install -y python3-libcamera python3-kms++

emendir commented 8 months ago

The packages were already installed, presumably by the setup script. Running those two commands resulted with: python3-picamera2 is already the newest version (0.3.14-1)., python3-libcamera is already the newest version (0.1.0+rpt20231020-1). and `python3-kms++ is already the newest version (0~git20230930~162059+b91affd-1).

camera.py still produces exactly the same error.

emendir commented 8 months ago

I think I've found out the issue: it seems like this failure only occurs on the 64-bit version of Raspberry Pi OS Bookworm.

I tried setting up everything again on the 32-bit version of Raspberry Pi OS Bookworm (on the same Raspberry Pi 4 hardware) and camera.py succeeded.