Skip to content

Instantly share code, notes, and snippets.

View calebccff's full-sized avatar
🏳️‍🌈

Caleb Connolly calebccff

🏳️‍🌈
View GitHub Profile
@calebccff
calebccff / README.md
Last active February 27, 2025 15:10
Find the list of modules explicitly required by your ARM device.

hwmodules.sh

This script uses the devicetree compatible properties in the modalias info and compares them to all the compatible properties used on the running device. Essentially, it filters lsmod to only show modules which are directly used for hardware functionality on your device. This is NOT an exhaustive list of modules, but should be added to your distros existing list. It doesn't cover basic things like nvme, etc.

Example output

On the Lenovo Yoga Slim 7x laptop, the following is printed:

@calebccff
calebccff / parse-pkg.sh
Created January 19, 2025 03:27
APKBUILD to JSON parser
#!/bin/busybox sh
# parse-pkg.sh: APKBUILD -> JSON parser
# This parses APKBUILD files to determine info
# ahead of time about the package that WOULD be
# built if abuild were invoked.
#
# Since APKBUILD files are literally shell scripts
# they can be fully dynamic, producing different
# output depending on the input.
@calebccff
calebccff / README.md
Last active January 16, 2025 14:45
Pretty print values in binary

regbits

Small utility for pretty-printing numbers in binary, useful to manually decoding register without counting digits by hand.

Demo

; regbits 768
@calebccff
calebccff / git-send-pr
Created February 22, 2024 16:10
Send a git pull request with one command
#!/bin/bash
start="$1"
url="$2"
end="$3"
shift 3
pull=$(mktemp /tmp/git-pull-XXXXXXX.pull)
echo "From: $(git config user.name) <$(git config user.email)>" >> $pull
@calebccff
calebccff / git-pmr.sh
Created February 14, 2024 23:20
Push an open a GitLab MR with a custom title and description (install in $PATH as git-pmr)
#!/bin/sh
# A crapp tool to push and open a gitlab MR
# with just one command!
# --force-with-lease ensures that we don't override any commits which only exist
# on the remote. But it will let you overwrite commits you've ammended.
cmd="git push --force-with-lease -o merge_request.create -o merge_request.description="
case $# in
1)
@calebccff
calebccff / fastgnome.sh
Last active January 15, 2024 10:28
Make your shell run faster
#!/bin/sh
PROC="gnome-shell"
CLAMP=900
PID=$(pidof "$PROC")
function enable() {
echo "Setting uclamp min to 800 (max: 1024)"
uclampset --pid "$PID" -m "$CLAMP"
@calebccff
calebccff / boards.md
Last active November 1, 2023 00:11
USB control board
  • USB hub that can do power control on one port (via pico), one USB-A female port for going to the phone
  • second USB goes to pico
  • 12v in via a barrel jack which powers an LDO with ~3.8-9v 4A output
  • output adjustable via software or just a pot
  • output voltage/current measured by MCU
  • Pico attached to board
  • pico GPIO pins exposed via some header for phone UART and button control
  • Should have a jumper to adjust between 1.8/3.3v UART
  • (just 1.8/3.3v is fine and i know from experience that a single voltage divider on the TX is enough for this)
  • Spare i2c and a few extra GPIOs for future expansion
@calebccff
calebccff / abortwatch.py
Last active April 24, 2024 12:24
A script to watch U-Boot serial output and automatically decode register dumps when a synchronous abort occurs
#!/usr/bin/env python3
# SPDX-License-Identifier: GPL-2.0
# Copyright 2023 Linaro Ltd.
# Author: Caleb Connolly <[email protected]>
#
# Listens to a serial port and automatically detects and decodes
# Synchronous aborts. DO NOT run your serial monitor at the same
# time as this tool! It will configure a PTY and symlink it to
# /tmp/abortwatch.pty, you should point your serial monitor there
# instead!
@calebccff
calebccff / README.md
Last active October 4, 2023 10:08
regbits - pretty print numbers as binary

Register Bits

Dump in a register value and get a binary representation that makes decoding registers just that bit easier.

Demo

asciicast

kgdb notes

Kernel config

CONFIG_KGDB=y
CONFIG_KGDB_KDB=y
CONFIG_PANIC_TIMEOUT=y
CONFIG_PANIC_ON_OOPS=y
CONFIG_RANDOMIZE_BASE=n # Disable KASLR