[{"id":38220,"web_url":"https://patchwork.libcamera.org/comment/38220/","msgid":"<177141797387.3376561.14581605076071052795@ping.linuxembedded.co.uk>","date":"2026-02-18T12:32:53","subject":"Re: [PATCH v2] utils: Introduce libcamera-bug-report","submitter":{"id":4,"url":"https://patchwork.libcamera.org/api/people/4/","name":"Kieran Bingham","email":"kieran.bingham@ideasonboard.com"},"content":"Quoting Kieran Bingham (2026-02-18 12:19:33)\n> Introduce a script which can be installed into the system to aide\n> reporting potential camera and media related issues.\n> \n> The script shall capture system information and store it in a temporary\n> file - but it remains the users responsibilty to choose to share this\n> data, and no automatic bug submissions are anticipated.\n> \n> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n> ---\n> There are many occasions where people would like to report issues with\n> their camera, and there are always a common set of commands that we\n> would like to run to identify potential issues.\n> \n> Provide a helper that will ease reporting of camera related issues\n> especially for bringup of new cameras or when cameras do not show.\n> \n\nDoes anyone know if b4 can force outputing a cover letter even for a\nsingle patch?\n\n\n> ---\n> v2:\n>  - Fix installation with correct filename\n>  - Do not override file permissions\n>  - Add a request to remove sensitive information\n>  - Use posix shell and clear through shellcheck\n>  - Ask for permission to use sudo\n> ---\n>  utils/libcamera-bug-report | 119 +++++++++++++++++++++++++++++++++++++++++++++\n>  utils/meson.build          |   6 +++\n>  2 files changed, 125 insertions(+)\n> \n> diff --git a/utils/libcamera-bug-report b/utils/libcamera-bug-report\n> new file mode 100755\n> index 000000000000..6c7d1d86557a\n> --- /dev/null\n> +++ b/utils/libcamera-bug-report\n> @@ -0,0 +1,119 @@\n> +#!/bin/sh\n> +# SPDX-License-Identifier: LGPL-2.1-or-later\n> +\n> +REPORT=\"libcamera-report-$(hostname)-$(date +%Y%m%d-%H%M%S).txt\"\n> +\n> +section() {\n> +    echo\n> +    echo \"==================================================\"\n> +    echo \"$1\"\n> +    echo \"==================================================\"\n> +}\n> +\n> +run() {\n> +    echo\n> +    echo \"\\$ $*\"\n> +    \"$@\" || echo \"[WARN] Command failed: $*\"\n> +}\n> +\n> +# Run a command with sudo if the script was allowed to use it.\n> +run_with_sudo() {\n> +    if [ -n \"$SUDO\" ]; then\n> +        echo\n> +        echo \"\\$ $SUDO $*\"\n> +        $SUDO \"$@\" || echo \"[WARN] Command failed: $SUDO $*\"\n> +    else\n> +        run \"$@\"\n> +    fi\n> +}\n> +\n> +mark_kmsg() {\n> +    if [ -w /dev/kmsg ]; then\n> +        echo \"libcamera-debug-report[$$]: $1\" > /dev/kmsg\n> +    else\n> +        if [ -n \"$SUDO\" ]; then\n> +            printf \"libcamera-debug-report[%s]: %s\\n\" \"$$\" \"$1\" | $SUDO tee /dev/kmsg >/dev/null || \\\n> +                echo \"[WARN] failed to write /dev/kmsg with sudo: $1\"\n> +        else\n> +            echo \"[INFO] /dev/kmsg not writable, skipping kernel marker: $1\"\n> +        fi\n> +    fi\n> +}\n> +\n> +main() {\n> +\n> +section \"Report metadata\"\n> +echo \"Date: $(date -Is)\"\n> +echo \"Host: $(hostname)\"\n> +echo \"User: $(id)\"\n> +\n> +section \"Kernel & OS\"\n> +run uname -a\n> +run cat /etc/os-release\n> +command -v lsb_release >/dev/null && run lsb_release -a\n> +\n> +section \"Media / V4L2 tools\"\n> +command -v media-ctl >/dev/null && run media-ctl --version\n> +command -v v4l2-ctl >/dev/null && run v4l2-ctl --version\n> +command -v v4l2-ctl >/dev/null && run v4l2-ctl --list-devices\n> +\n> +section \"Device nodes\"\n> +run ls -l /dev/video* /dev/v4l-* /dev/media* 2>/dev/null\n> +run grep . /sys/class/video4linux/*/name\n> +\n> +section \"Deferred devices\"\n> +run cat /sys/kernel/debug/devices_deferred\n\nThis one should also use run_with_sudo...\n\n> +\n> +section \"V4L2 async pending subdevices\"\n> +run_with_sudo cat /sys/kernel/debug/v4l2-async/pending_async_subdevices\n> +\n> +section \"Media graph topology\"\n> +for m in /dev/media*; do\n> +    echo\n> +    echo \"Parsing $m\"\n> +    command -v media-ctl >/dev/null && run media-ctl -p \"$m\"\n\nOf course testing after I sent, this is missing a '-d' to select the\ndevice which I didn't notice before while testing. Fixed for v3.\n\n\n> +done\n> +\n> +section \"libcamera & userspace\"\n> +run which cam\n> +command -v cam >/dev/null && run ldd \"$(which cam)\"\n> +\n> +section \"libcamera probe (cam -l)\"\n> +mark_kmsg \"BEGIN cam -l\"\n> +LIBCAMERA_LOG_LEVELS=\"*:0\" run cam -l\n> +mark_kmsg \"END cam -l\"\n> +\n> +section \"Kernel log (post cam -l)\"\n> +run_with_sudo dmesg\n> +\n> +section \"Permissions & capabilities\"\n> +run id\n> +run groups\n> +command -v getcap >/dev/null && run getcap \"$(which cam)\"\n> +\n> +section \"End of report\"\n> +\n> +cat <<EOF\n> +\n> +Report saved to $REPORT.\n> +\n> +Please inspect the report and remove any sensitive information before sharing.\n> +EOF\n> +\n> +}\n> +\n> +# If not running as root, prompt the user once to allow sudo\n> +SUDO=\"\"\n> +if [ \"$(id -u)\" -ne 0 ]; then\n> +    if [ -t 0 ]; then\n> +        printf \"Some checks require root; allow sudo for privileged commands? [y/N] \"\n> +        read -r ans\n> +        case \"$ans\" in\n> +            [Yy]|[Yy][Ee][Ss]) SUDO=\"sudo\" ;;\n> +            *) SUDO=\"\" ;;\n> +        esac\n> +    fi\n> +fi\n> +\n> +# Run main and tee output to both stdout and the report file.\n> +main 2>&1 | tee \"$REPORT\"\n> diff --git a/utils/meson.build b/utils/meson.build\n> index 3deed8ad4d7e..9c598793035c 100644\n> --- a/utils/meson.build\n> +++ b/utils/meson.build\n> @@ -7,3 +7,9 @@ gen_shader_headers = files('gen-shader-headers.sh')\n>  \n>  ## Module signing\n>  gen_ipa_priv_key = files('gen-ipa-priv-key.sh')\n> +\n> +## Bug reporting utility\n> +install_data(\n> +    'libcamera-bug-report',\n> +    install_dir: get_option('bindir'),\n> +)\n> \n> ---\n> base-commit: d97d2a58adaf284860fdf5d1f6785d779ab6e24a\n> change-id: 20260207-kbingham-bug-reporter-60285cd034af\n> \n> Best regards,\n> -- \n> --\n> Kieran\n>","headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 9615EC31E9\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed, 18 Feb 2026 12:32:59 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id CDEC86221D;\n\tWed, 18 Feb 2026 13:32:58 +0100 (CET)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 5DDCD620FA\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 18 Feb 2026 13:32:57 +0100 (CET)","from monstersaurus.ideasonboard.com\n\t(cpc89244-aztw30-2-0-cust6594.18-1.cable.virginm.net [86.31.185.195])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id F1D78981\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 18 Feb 2026 13:32:04 +0100 (CET)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"O2DnjhrM\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1771417925;\n\tbh=gWf7XiTh/a18/pXViJTET7Hait9kM99WRECQ9wos9eM=;\n\th=In-Reply-To:References:Subject:From:Cc:To:Date:From;\n\tb=O2DnjhrMp9Lyk422tGPd6XU5WoWjjxaQ4GohDHJhKBAJA6Ebzpm+YZT2P92JrjwE6\n\tPzvNc+mBJqmV3reb0q4Lm8HThnqO7oy/i58D5i8OmmMTAQ6YIOzil9TkiXZ0ytkW/8\n\tpxL2h23L58d/OLp6llIE9K9IHnY218TwYTfNtu8k=","Content-Type":"text/plain; charset=\"utf-8\"","MIME-Version":"1.0","Content-Transfer-Encoding":"quoted-printable","In-Reply-To":"<20260218-kbingham-bug-reporter-v2-1-02d7cf37968e@ideasonboard.com>","References":"<20260218-kbingham-bug-reporter-v2-1-02d7cf37968e@ideasonboard.com>","Subject":"Re: [PATCH v2] utils: Introduce libcamera-bug-report","From":"Kieran Bingham <kieran.bingham@ideasonboard.com>","Cc":"","To":"libcamera-devel@lists.libcamera.org","Date":"Wed, 18 Feb 2026 12:32:53 +0000","Message-ID":"<177141797387.3376561.14581605076071052795@ping.linuxembedded.co.uk>","User-Agent":"alot/0.9.1","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]