Skip to content

Instantly share code, notes, and snippets.

View leighleighleigh's full-sized avatar

Leigh Oliver leighleighleigh

View GitHub Profile
@leighleighleigh
leighleighleigh / ulp_custom_instruction_encoder.py
Created March 2, 2026 11:44
Custom instruction encoder script for ESP32-S3 RISCV ULP co-processor.
#!/usr/bin/env python3
"""
/**
* This header file defines custom instructions for interrupt handling on the
* ULP RISC-V. The architecture of the processor and therefore, the interrupt
* handling is based on the PicoRV32 CPU. Details about the operations are
* available at https://github.com/YosysHQ/picorv32#custom-instructions-for-irq-handling
*/
@leighleighleigh
leighleighleigh / esp_hal_rs_ulp_gpio_interrupt_gist.rs
Created March 2, 2026 10:52
Useful functions to enable GPIO 5 interrupt, and accompanying interrupt handler, for ESP32S3 ULP core (not yet mainlined)
// Required to shadow the weakly-linked ulp_irq_handler
// that is defined by esp-lp-hal.
#[link_name = "ulp_irq_handler"]
#[unsafe(link_section = ".init")]
#[unsafe(no_mangle)]
extern "C" fn ulp_irq_handler(q1: u32) {
/* Internal Interrupts */
if (q1 & 0b1) > 0 {
// TODO
}
@leighleighleigh
leighleighleigh / ghidra_bulk_import.sh
Last active February 9, 2025 08:15
Ghidra bulk file import with dynamic library search for portable executable files
#!/usr/bin/env bash
### Ghidra project bulk file import with DLL library resolution
### Warning, this file takes bloody ages to run! (40 minutes for 140 files)
### ... but it's still faster than using the GUI!
### Leigh Oliver 23rd September 2024
###
### EXAMPLE USAGE
# Import one file...
# ./import.sh ./MyProject.gpr ./coredll.dll
# Import a list of files...
@leighleighleigh
leighleighleigh / svgbob_live.sh
Created December 18, 2022 05:57
svgbob_live.sh - live preview of ASCII diagrams as SVG using svgbob
#!/usr/bin/env bash
### svgbob live preview ###
# DESCRIPTION
# Runs svgbob_cli whenever a file is changed (specified at launch)
# and open it with eog (eye of gnome)
# AUTHOR
# Leigh Oliver, 18/12/2022
# USAGE
@leighleighleigh
leighleighleigh / auto_rotate.sh
Last active November 2, 2020 12:32 — forked from Links2004/auto_rotate.sh
Linux auto rotate screen and adjust touch matrix based on accelerometer data
#!/bin/bash
# Auto rotate screen based on device orientation
# based on https://linuxappfinder.com/blog/auto_screen_rotation_in_ubuntu
# install
# 1. apt-get install iio-sensor-proxy inotify-tools
# 2. add script to autostart
# Receives input from monitor-sensor (part of iio-sensor-proxy package)
# Screen orientation and launcher location is set based upon accelerometer position
#!/usr/bin/python3
import dbus, dbus.mainloop.glib, sys
from gi.repository import GLib
import datetime
from math import floor
track_dur = 0
def on_property_changed(interface, changed, invalidated):
global track_dur
@leighleighleigh
leighleighleigh / gpio_read_reg.ino
Created September 20, 2018 06:46
An example of using a GPIO input register to read pin inputs on NodeMCU (esp8266 based) board.
// Our super ultra fast input register
#define GPIO_IN READ_PERI_REG(0x60000318)
#define CHAN0 D1
#define CHAN1 D2
#define CHAN2 D3
#define CHAN3 D4
#define CHAN4 D5
void setup()
@leighleighleigh
leighleighleigh / favs.txt
Last active June 12, 2017 04:51
Some of my favourite comments from the Apollo 11 Source Code
# ****************************************************************************
# TRASHY LITTLE SUBROUTINES
# ****************************************************************************
# ASTRONAUT: PLEASE CRANK THE
# SILLY THING AROUND
# OFF TO SEE THE WIZARD ...
# PROCEED SEE IF HE'S LYING