Skip to content

Instantly share code, notes, and snippets.

View kbingham's full-sized avatar

Kieran Bingham kbingham

View GitHub Profile
#!/bin/sh
# Requires 'media-ctl' to parse the media devices
# Requires 'dot' to generate the media-graph png files.
# Identify all V4L2 devices
for v in /sys/class/video4linux/{v4l,video}*;
do
vn=`basename $v`
name=`cat $v/name`
@kbingham
kbingham / rpi4-usb.sh
Last active February 25, 2021 14:44 — forked from ianfinch/rpi4-usb.sh
Raspberry Pi 4 USB Gadget
#!/bin/bash
# Set up a Raspberry Pi 4 as a USB-C Ethernet Gadget
# Based on:
# - https://www.hardill.me.uk/wordpress/2019/11/02/pi4-usb-c-gadget/
# - https://pastebin.com/VtAusEmf
if ! $(grep -q dtoverlay=dwc2 /boot/config.txt) ; then
echo "Add the line dtoverlay=dwc2 to /boot/config.txt"
exit
fi
@kbingham
kbingham / sd-card-writer
Created December 15, 2020 16:10
SD Card writer (can also write USB sticks)
#!/bin/bash
## Usage sd-card-writer image <target>
IMAGE=$1
TARGET=${2:-/dev/mmcblk0}
if [ ! -b $TARGET ] ; then
echo "$TARGET is not a block device"
exit
for m in /sys/bus/media/devices/media*;
do
mn=`basename $m`
model=`cat $m/model`
echo $mn: $model
done | sort -V;
@kbingham
kbingham / bootstrap-deps.sh
Created September 10, 2021 16:12
Support installation of libcamera dependencies on multiple platforms
#!/bin/bash
app=`basename $0`
# Todo: Autodetect system
system=ubuntu
toolchains=(gcc clang)
modules=(android cam qcam raspberrypi tracing gstreamer hotplug documentation tracing developer)
@kbingham
kbingham / git-banner-commit
Created September 27, 2021 09:28
Create 'banner' commits in a branch to separate topics
#!/bin/sh
## Often used with interactive rebases to split patch groups
## git rebase -i
## add lines such as:
## x git banner-commit "Submitted"
## dot-files are created so that the commits are not empty, and persist.
columns=52
line="$*"
[bindings]
G = call hooks.getmail(ui)
@kbingham
kbingham / check-v4l2-sensor-compatibility.awk
Created February 25, 2022 11:02
Quick tool to help reviewing Camera Sensor drivers in linux-media to support libcamera requirements
#!/usr/bin/awk -f
function initialiseControls(ids, keys, controls)
{
split(ids, keys)
for (i in keys) controls[keys[i]] = "--------"
}
BEGIN {
print "Processing " ARGV[1]
FROM debian:bullseye
ENV DEBIAN_FRONTEND noninteractive
ENV LANG='C.UTF-8' LC_ALL='C.UTF-8'
# Support multiarch builds to perform cross compilation
# https://wiki.debian.org/Multiarch/HOWTO
RUN dpkg --add-architecture arm64
# Expected system requirements
@kbingham
kbingham / lcdebug
Created September 26, 2022 15:27
lcdebug - helper to debug libcamera
#!/bin/bash
# SPDX-License-Identifier: GPL-2.0-or-later
# Support debugging libcamera commands and applications.
# We default to enabling the most debug
# (that's why we're being used right)
FILTER="*"
LEVEL="0"