raspberrypi / rpicam-apps

BSD 2-Clause "Simplified" License
387 stars 211 forks source link

libcamera-still with timelapse stop recording after time time #401

Closed vlachoudis closed 1 year ago

vlachoudis commented 1 year ago

Describe the bug I am using the libcamera-still with time lapse through home assistant., which on a motion event it sends the last captured image. On start it works ok for several hours and at a random moment it freezes the image, while the application still "runs" with no any error message.

Command: /usr/bin/libcamera-still --nopreview -o /home/bnv/.homeassistant/camera/rpi_camera.jpg -t 0 --width 800 --height 600 --timelapse 1000 -q 75 --rotation 0

on a RPI 3B+ with a camera V1.2 (ov5647)

I am recording the images on a ramdisk, to avoid writing on the SD card

Bug report Please use the camera-bug-report tool to create a bug report, and upload it here.

--------------------------------------------------------------------------------
libcamera-apps Bug Report
--------------------------------------------------------------------------------
Date: 01-11-2022 (16:57:53)
Command: /usr/bin/camera-bug-report -t 5 -o bug.txt -c libcamera-still -t 1000 -o test.jpg

--------------------------------------------------------------------------------
Hardware information
--------------------------------------------------------------------------------
** hostname **
pi

** cat /proc/cpuinfo **
processor   : 0
BogoMIPS    : 38.40
Features    : fp asimd evtstrm crc32 cpuid
CPU implementer : 0x41
CPU architecture: 8
CPU variant : 0x0
CPU part    : 0xd03
CPU revision    : 4

processor   : 1
BogoMIPS    : 38.40
Features    : fp asimd evtstrm crc32 cpuid
CPU implementer : 0x41
CPU architecture: 8
CPU variant : 0x0
CPU part    : 0xd03
CPU revision    : 4

processor   : 2
BogoMIPS    : 38.40
Features    : fp asimd evtstrm crc32 cpuid
CPU implementer : 0x41
CPU architecture: 8
CPU variant : 0x0
CPU part    : 0xd03
CPU revision    : 4

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

Hardware    : BCM2835
Revision    : a22082
Serial      : 0000000042b9c8db
Model       : Raspberry Pi 3 Model B Rev 1.2

--------------------------------------------------------------------------------
Configuration
--------------------------------------------------------------------------------
** cat /boot/cmdline.txt **
console=tty1 root=PARTUUID=33198336-02 rootfstype=ext4 fsck.repair=yes rootwait

** cat /boot/config.txt **
# For more options and information see
# http://rpf.io/configtxt
# Some settings may impact device functionality. See link above for details

# uncomment if you get no picture on HDMI for a default "safe" mode
#hdmi_safe=1

# uncomment the following to adjust overscan. Use positive numbers if console
# goes off screen, and negative if there is too much border
#overscan_left=16
#overscan_right=16
#overscan_top=16
#overscan_bottom=16

# uncomment to force a console size. By default it will be display's size minus
# overscan.
#framebuffer_width=1280
#framebuffer_height=720

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

# uncomment to force a specific HDMI mode (this will force VGA)
#hdmi_group=1
#hdmi_mode=1

# uncomment to force a HDMI mode rather than DVI. This can make audio work in
# DMT (computer monitor) modes
# BNV uncommented
hdmi_drive=2

# uncomment to increase signal to HDMI, if you have interference, blanking, or
# no display
#config_hdmi_boost=4

# uncomment for composite PAL
#sdtv_mode=2

#uncomment to overclock the arm. 700 MHz is the default.
#arm_freq=800

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

# Uncomment this to enable infrared communication.
#dtoverlay=gpio-ir,gpio_pin=17
#dtoverlay=gpio-ir-tx,gpio_pin=18

# Additional overlays and parameters are documented /boot/overlays/README

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

# Automatically load overlays for detected cameras
camera_auto_detect=1
# BNV raspi camera V1.2
dtoverlay=ov5647
# raspi camera V2
#dtoverlay=imx219

# Automatically load overlays for detected DSI displays
display_auto_detect=1

# Enable DRM VC4 V3D driver
dtoverlay=vc4-kms-v3d
max_framebuffers=2

# Run in 64-bit mode
arm_64bit=1

# Disable compensation for displays with overscan
disable_overscan=1

# disable camera led
disable_camera_led=1

[cm4]
# Enable host mode on the 2711 built-in XHCI USB controller.
# This line should be removed if the legacy DWC2 controller is required
# (e.g. for USB device mode) or if USB support is not required.
otg_mode=1

[all]

[pi4]
# Run as fast as firmware / board allows
arm_boost=1

[all]
gpu_mem=32
enable_uart=1

--------------------------------------------------------------------------------
Logs
--------------------------------------------------------------------------------
** dmesg **
[108615.529578] Bluetooth: hci0: Frame reassembly failed (-84)
[108615.529608] Bluetooth: hci0: Frame reassembly failed (-84)
[108615.531061] Bluetooth: hci0: Frame reassembly failed (-84)
[108615.531147] Bluetooth: hci0: Frame reassembly failed (-84)
[108615.531235] Bluetooth: hci0: Frame reassembly failed (-84)
[108615.531321] Bluetooth: hci0: Frame reassembly failed (-84)
[108615.531411] Bluetooth: hci0: Frame reassembly failed (-84)
[108615.531495] Bluetooth: hci0: Frame reassembly failed (-84)
[108615.531582] Bluetooth: hci0: Frame reassembly failed (-84)
[108615.531669] Bluetooth: hci0: Frame reassembly failed (-84)
[108615.531754] Bluetooth: hci0: Frame reassembly failed (-84)
[108615.531842] Bluetooth: hci0: Frame reassembly failed (-84)
[108615.531930] Bluetooth: hci0: Frame reassembly failed (-84)
[108615.531942] Bluetooth: hci0: Frame reassembly failed (-84)
[108615.532015] Bluetooth: hci0: Frame reassembly failed (-84)
[108615.532101] Bluetooth: hci0: Frame reassembly failed (-84)
[108615.532168] Bluetooth: hci0: Frame reassembly failed (-84)

** sudo vcdbg log msg **
sudo: vcdbg: command not found

** sudo vcdbg log assert **
sudo: vcdbg: command not found

** sudo vcdbg log ex **
sudo: vcdbg: command not found

--------------------------------------------------------------------------------
Memory
--------------------------------------------------------------------------------
** cat /proc/meminfo **
MemTotal:         976424 kB
MemFree:          110828 kB
MemAvailable:     365696 kB
Buffers:           41668 kB
Cached:           246380 kB
SwapCached:            0 kB
Active:           182496 kB
Inactive:         566052 kB
Active(anon):        824 kB
Inactive(anon):   469988 kB
Active(file):     181672 kB
Inactive(file):    96064 kB
Unevictable:          16 kB
Mlocked:              16 kB
SwapTotal:        102396 kB
SwapFree:          99068 kB
Dirty:               200 kB
Writeback:             0 kB
AnonPages:        460572 kB
Mapped:           130808 kB
Shmem:             10308 kB
KReclaimable:      42668 kB
Slab:              68528 kB
SReclaimable:      42668 kB
SUnreclaim:        25860 kB
KernelStack:        3388 kB
PageTables:         4276 kB
NFS_Unstable:          0 kB
Bounce:                0 kB
WritebackTmp:          0 kB
CommitLimit:      590608 kB
Committed_AS:    1037352 kB
VmallocTotal:   259653632 kB
VmallocUsed:       11452 kB
VmallocChunk:          0 kB
Percpu:              688 kB
CmaTotal:         262144 kB
CmaFree:           83380 kB

** sudo cat /sys/kernel/debug/dma_buf/bufinfo **

Dma-buf Objects:
size        flags       mode        count       exp_name    ino     
00749568    00000002    00080007    00000001    videobuf2_dma_contig    00356390    
    Attached Devices:
Total 0 devices attached

Total 1 objects, 749568 bytes

** sudo cat /sys/kernel/debug/vcsm-cma/state **

VC-ServiceHandle     000000002d124257

Resources

Resource                00000000be556708
           NAME         sm-host-resource
           SIZE         749568
           DMABUF       000000008b892bc2
           ATTACH       0000000000000000
           SGT          0000000000000000
           DMA_ADDR     0x00000000dfe00000
           VC_HANDLE     c0000006
           VC_MAPPING    2

Total resource count:   1

--------------------------------------------------------------------------------
Media Devices
--------------------------------------------------------------------------------
** media-ctl -d 0 -p **
Media controller API version 5.15.74

Media device information
------------------------
driver          bcm2835-isp
model           bcm2835-isp
serial          
bus info        platform:bcm2835-isp
hw revision     0x0
driver version  5.15.74

Device topology
- entity 1: bcm2835_isp0 (4 pads, 4 links)
            type Node subtype Unknown flags 0
    pad0: Sink
        <- "bcm2835-isp0-output0":0 [ENABLED,IMMUTABLE]
    pad1: Source
        -> "bcm2835-isp0-capture1":0 [ENABLED,IMMUTABLE]
    pad2: Source
        -> "bcm2835-isp0-capture2":0 [ENABLED,IMMUTABLE]
    pad3: Source
        -> "bcm2835-isp0-capture3":0 [ENABLED,IMMUTABLE]

- entity 6: bcm2835-isp0-output0 (1 pad, 1 link)
            type Node subtype V4L flags 0
            device node name /dev/video13
    pad0: Source
        -> "bcm2835_isp0":0 [ENABLED,IMMUTABLE]

- entity 12: bcm2835-isp0-capture1 (1 pad, 1 link)
             type Node subtype V4L flags 0
             device node name /dev/video14
    pad0: Sink
        <- "bcm2835_isp0":1 [ENABLED,IMMUTABLE]

- entity 18: bcm2835-isp0-capture2 (1 pad, 1 link)
             type Node subtype V4L flags 0
             device node name /dev/video15
    pad0: Sink
        <- "bcm2835_isp0":2 [ENABLED,IMMUTABLE]

- entity 24: bcm2835-isp0-capture3 (1 pad, 1 link)
             type Node subtype V4L flags 0
             device node name /dev/video16
    pad0: Sink
        <- "bcm2835_isp0":3 [ENABLED,IMMUTABLE]

** media-ctl -d 1 -p **
Media controller API version 5.15.74

Media device information
------------------------
driver          bcm2835-isp
model           bcm2835-isp
serial          
bus info        platform:bcm2835-isp
hw revision     0x0
driver version  5.15.74

Device topology
- entity 1: bcm2835_isp0 (4 pads, 4 links)
            type Node subtype Unknown flags 0
    pad0: Sink
        <- "bcm2835-isp0-output0":0 [ENABLED,IMMUTABLE]
    pad1: Source
        -> "bcm2835-isp0-capture1":0 [ENABLED,IMMUTABLE]
    pad2: Source
        -> "bcm2835-isp0-capture2":0 [ENABLED,IMMUTABLE]
    pad3: Source
        -> "bcm2835-isp0-capture3":0 [ENABLED,IMMUTABLE]

- entity 6: bcm2835-isp0-output0 (1 pad, 1 link)
            type Node subtype V4L flags 0
            device node name /dev/video20
    pad0: Source
        -> "bcm2835_isp0":0 [ENABLED,IMMUTABLE]

- entity 12: bcm2835-isp0-capture1 (1 pad, 1 link)
             type Node subtype V4L flags 0
             device node name /dev/video21
    pad0: Sink
        <- "bcm2835_isp0":1 [ENABLED,IMMUTABLE]

- entity 18: bcm2835-isp0-capture2 (1 pad, 1 link)
             type Node subtype V4L flags 0
             device node name /dev/video22
    pad0: Sink
        <- "bcm2835_isp0":2 [ENABLED,IMMUTABLE]

- entity 24: bcm2835-isp0-capture3 (1 pad, 1 link)
             type Node subtype V4L flags 0
             device node name /dev/video23
    pad0: Sink
        <- "bcm2835_isp0":3 [ENABLED,IMMUTABLE]

** media-ctl -d 2 -p **
Media controller API version 5.15.74

Media device information
------------------------
driver          bcm2835-codec
model           bcm2835-codec
serial          0000
bus info        platform:bcm2835-codec
hw revision     0x1
driver version  5.15.74

Device topology
- entity 1: bcm2835-codec-decode-source (1 pad, 1 link)
            type Node subtype V4L flags 0
            device node name /dev/video10
    pad0: Source
        -> "bcm2835-codec-decode-proc":0 [ENABLED,IMMUTABLE]

- entity 3: bcm2835-codec-decode-proc (2 pads, 2 links)
            type Node subtype Unknown flags 0
    pad0: Sink
        <- "bcm2835-codec-decode-source":0 [ENABLED,IMMUTABLE]
    pad1: Source
        -> "bcm2835-codec-decode-sink":0 [ENABLED,IMMUTABLE]

- entity 6: bcm2835-codec-decode-sink (1 pad, 1 link)
            type Node subtype V4L flags 0
            device node name /dev/video10
    pad0: Sink
        <- "bcm2835-codec-decode-proc":1 [ENABLED,IMMUTABLE]

- entity 15: bcm2835-codec-encode-source (1 pad, 1 link)
             type Node subtype V4L flags 0
             device node name /dev/video11
    pad0: Source
        -> "bcm2835-codec-encode-proc":0 [ENABLED,IMMUTABLE]

- entity 17: bcm2835-codec-encode-proc (2 pads, 2 links)
             type Node subtype Unknown flags 0
    pad0: Sink
        <- "bcm2835-codec-encode-source":0 [ENABLED,IMMUTABLE]
    pad1: Source
        -> "bcm2835-codec-encode-sink":0 [ENABLED,IMMUTABLE]

- entity 20: bcm2835-codec-encode-sink (1 pad, 1 link)
             type Node subtype V4L flags 0
             device node name /dev/video11
    pad0: Sink
        <- "bcm2835-codec-encode-proc":1 [ENABLED,IMMUTABLE]

- entity 29: bcm2835-codec-isp-source (1 pad, 1 link)
             type Node subtype V4L flags 0
             device node name /dev/video12
    pad0: Source
        -> "bcm2835-codec-isp-proc":0 [ENABLED,IMMUTABLE]

- entity 31: bcm2835-codec-isp-proc (2 pads, 2 links)
             type Node subtype Unknown flags 0
    pad0: Sink
        <- "bcm2835-codec-isp-source":0 [ENABLED,IMMUTABLE]
    pad1: Source
        -> "bcm2835-codec-isp-sink":0 [ENABLED,IMMUTABLE]

- entity 34: bcm2835-codec-isp-sink (1 pad, 1 link)
             type Node subtype V4L flags 0
             device node name /dev/video12
    pad0: Sink
        <- "bcm2835-codec-isp-proc":1 [ENABLED,IMMUTABLE]

- entity 43: bcm2835-codec-image_fx-source (1 pad, 1 link)
             type Node subtype V4L flags 0
             device node name /dev/video18
    pad0: Source
        -> "bcm2835-codec-image_fx-proc":0 [ENABLED,IMMUTABLE]

- entity 45: bcm2835-codec-image_fx-proc (2 pads, 2 links)
             type Node subtype Unknown flags 0
    pad0: Sink
        <- "bcm2835-codec-image_fx-source":0 [ENABLED,IMMUTABLE]
    pad1: Source
        -> "bcm2835-codec-image_fx-sink":0 [ENABLED,IMMUTABLE]

- entity 48: bcm2835-codec-image_fx-sink (1 pad, 1 link)
             type Node subtype V4L flags 0
             device node name /dev/video18
    pad0: Sink
        <- "bcm2835-codec-image_fx-proc":1 [ENABLED,IMMUTABLE]

- entity 57: bcm2835-codec-encode_image-sour (1 pad, 1 link)
             type Node subtype V4L flags 0
             device node name /dev/video31
    pad0: Source
        -> "bcm2835-codec-encode_image-proc":0 [ENABLED,IMMUTABLE]

- entity 59: bcm2835-codec-encode_image-proc (2 pads, 2 links)
             type Node subtype Unknown flags 0
    pad0: Sink
        <- "bcm2835-codec-encode_image-sour":0 [ENABLED,IMMUTABLE]
    pad1: Source
        -> "bcm2835-codec-encode_image-sink":0 [ENABLED,IMMUTABLE]

- entity 62: bcm2835-codec-encode_image-sink (1 pad, 1 link)
             type Node subtype V4L flags 0
             device node name /dev/video31
    pad0: Sink
        <- "bcm2835-codec-encode_image-proc":1 [ENABLED,IMMUTABLE]

** media-ctl -d 3 -p **
Media controller API version 5.15.74

Media device information
------------------------
driver          unicam
model           unicam
serial          
bus info        platform:3f801000.csi
hw revision     0x0
driver version  5.15.74

Device topology
- entity 1: ov5647 10-0036 (1 pad, 1 link)
            type V4L2 subdev subtype Sensor flags 0
            device node name /dev/v4l-subdev0
    pad0: Source
        [fmt:SGBRG10_1X10/2592x1944 field:none colorspace:raw
         crop.bounds:(16,6)/2592x1944
         crop:(16,6)/2592x1944]
        -> "unicam-image":0 [ENABLED,IMMUTABLE]

- entity 3: unicam-image (1 pad, 1 link)
            type Node subtype V4L flags 1
            device node name /dev/video0
    pad0: Sink
        <- "ov5647 10-0036":0 [ENABLED,IMMUTABLE]

** media-ctl -d 4 -p **
Failed to enumerate /dev/media4 (-2)

--------------------------------------------------------------------------------
Cameras
--------------------------------------------------------------------------------
** libcamera-still --list-cameras **
Available cameras
-----------------
0 : ov5647 [2592x1944] (/base/soc/i2c0mux/i2c@1/ov5647@36)
    Modes: 'SGBRG10_CSI2P' : 640x480 [58.92 fps - (16, 0)/2560x1920 crop]
                             1296x972 [43.25 fps - (0, 0)/2592x1944 crop]
                             1920x1080 [30.62 fps - (348, 434)/1928x1080 crop]
                             2592x1944 [15.63 fps - (0, 0)/2592x1944 crop]

--------------------------------------------------------------------------------
Versions
--------------------------------------------------------------------------------
** uname -a **
Linux pi 5.15.74-v8+ #1594 SMP PREEMPT Fri Oct 21 16:38:33 BST 2022 aarch64 GNU/Linux

** cat /etc/os-release **
PRETTY_NAME="Debian GNU/Linux 11 (bullseye)"
NAME="Debian GNU/Linux"
VERSION_ID="11"
VERSION="11 (bullseye)"
VERSION_CODENAME=bullseye
ID=debian
HOME_URL="https://www.debian.org/"
SUPPORT_URL="https://www.debian.org/support"
BUG_REPORT_URL="https://bugs.debian.org/"

** vcgencmd version **
Oct 18 2022 17:46:34 
Copyright (c) 2012 Broadcom
version 23aa699d0e70ed543c1ddcd17bed6446bfb6866e (clean) (release) (start)

** libcamera-still --version **
libcamera-apps build: b89cc36c3872 19-10-2022 (13:16:48)
libcamera build: v0.0.1+21-7c855784

--------------------------------------------------------------------------------
libcamera-still -t 1000 -o test.jpg
--------------------------------------------------------------------------------
libEGL warning: DRI3: failed to query the version
libEGL warning: DRI2: failed to authenticate
Error: ***** TIMEOUT *****

Additional context Add any other context about the problem here.

naushir commented 1 year ago

Thank you for your report. Would you be able to provide a few more details please:

On start it works ok for several hours and at a random moment it freezes the image, while the application still "runs" with no any error message.

When you say freezes the image, do you mean the application still takes captures, but the images are not updated? Or do captures completely stop? After approximately how many hours does this happen?

Are you able to run with the -v 2 command line argument and post us the output log when the application freezes?

vlachoudis commented 1 year ago

The application seems to run (it shows on top, ps). I don't know if it takes images or not. However the file is not updated at all. Most of the time It takes around ~1h to happen. It happens everytime I run, however it is totally random.

I am going to add the option you recommended and send you the output once I see that the image is not updated any more.

vlachoudis commented 1 year ago

@naushir running with the -v 2 and redirection to a file the camera didn't crash. I have the feeling that the problem is not coming from the libcamera-still but rather from the calling process from home assistant that was not consuming the output of libcamera. So maybe the buffer to filled up and the process stalled.

Maybe I should close the issue for the moment to investigate a bit further

naushir commented 1 year ago

Thanks for getting back. Sure, feel free to close this issue if you suspect something else is not consuming the data correctly. Please do reopen this or a new issue if you find that libcamera-apps is not doing the right thing!

vlachoudis commented 1 year ago

Indeed after redirecting the output to null it runs happily for more about at day now