Linux Bluetooth audio bug fixes
26 Jan 2026Assorted bugs found while working on Bluetooth audio on an embedded Linux system. Two of these patches are bugs in Pulseaudio which have not been applied upstream.
Software LoRa demodulator
8 May 2022Here is an implementation of a LoRa demodulator in less than 900 lines of C. It reads I/Q samples from stdin has no dependencies outside of the standard library.
Tiny AVL trees
2 Dec 2021tavl is an implementation of AVL trees that keeps all nodes in a flat statically-allocated array. It's intended for use on embedded systems where one may want to index a set of items with a fixed upper bound, and where the set of items is too large for a linear search to be fast enough.
LPC54113 programming via OpenOCD
24 Sep 2021The LPC54113 doesn't currently have direct support for flash programming in OpenOCD, but it can be made to work purely via Tcl.
Markdown-based organizer
2 May 2020After trying a lot of different calendar and organizer programs I finally gave up and wrote my own. This script enables me to summarize and organize information by topic using a plain text format spread across multiple files. On request, all files are scanned for tags indicating TODO items or deadlines, and the result is printed in a short half-page hierarchial summary.
Speeding up Adler-32 on repeated subsequences
31 Jan 2020The Adler-32 checksum is used in the DEFLATE format as an integrity check on decompressed data. It's fast to calculate, but it can be even faster if you know that parts of your data consist of repeated subsequences.
PDF jumper diagrams with a simple Perl script
2 Jan 2020I recently needed to generate documentation in TeX for a board which was configured via jumpers placed on header pins. I wrote the Perl script shown here to quickly generate high-quality PDF images of different jumper settings for inclusion in the documentation. The script is approximately 200 lines, has no dependencies aside from the Perl interpreter itself, and can easily be modified to draw other kinds of diagrams.
C# INI-file parser
3 Jun 2019INI-like formats are understandably popular as human-readable configuration files for many server applications. Presented here is a very small (under 300 lines) parser written in C#, supporting a flexible variant of the format.
Low-latency bulk row transfer on a PostgreSQL server
25 Feb 2019Some applications will require bulk reads and writes of large collections of rows from a table on a PostgreSQL server. If the collection of rows is patternless (not falling into a contiguous subset), it would seem that a separate round-trip query is required for each row. Fortunately, this is not the case, and large operations of this kind can be done with a small fixed number of round-trips.
Building libmsp430.so on Linux
24 Jul 2018The following instructions are for building release Y of libmsp430.so from source on a 64-bit Debian-like Linux system for use with MSPDebug. These instructions may be applicable to other systems.
Fail-safe flexible remote firmware updates on almost any MCU
16 Apr 2018In-field and remote updates of firmware are a useful thing to have on most consumer products, but many update schemes aren't implemented well. A lot of devices suffer from vulnerability windows during firmware updates, where a power failure will lead to the device being bricked. Avoiding these vulnerability windows always means having some kind of bootloader on the device which doesn't get reprogrammed, in which case the methods of update might be frozen for the lifetime of the device.
pan2: poker odds calculator
15 Dec 2017pan2 is a poker odds calculator. For any game scenario, it produces a table showing win/loss probabilities for each player, plus the distribution of hand ranks that each player can expect. It can calculate odds for a variety of game rules including 5-card draw, Texas hold 'em, Omaha hold 'em, and lowball variants. Calculation for most games is extremely fast (tens of milliseconds on a modern PC). For more expensive evaluations, multithreaded processing is available.
Slirc: IRC interface to Slack
27 Nov 2017If you need to communicate with other people via Slack, but would prefer to avoid the web interface and Electron application, they offer an IRC gateway. Unfortunately, the gateway has some shortcomings that make it a fairly unsatisfactory solution. I ended up implementing my own gateway in the form of a locally-running Perl script that communicates with Slack's RTM interface.
Low-level PDF manipulation for F#
14 Mar 2017The code contained here consists of a module for manipulating PDF objects (pdf.fs), and a very simple parser for Adobe Font Metrics files and glyph-lists (afm.fs).
Jane tree file generator
20 Aug 2016This program is a utility which takes host and parasite trees (in NEXUS format), and a link matrix (in CSV format), and generates an input file for the Jane cophylogeny reconstruction software.
Enumerating fixed-weight bitstrings
6 Nov 2015Given the set of all bitstrings of length n with exactly k bits set, you can arrange them in lexicographical order. You can then convert between bitstrings and indices into this list. Can you do this efficiently when n is large and the list is too large to fit into memory?
Lightweight process supervisor for Linux
1 Sep 2015Rund is a lightweight stand-alone process supervisor for Linux. It takes an ordinary process and makes it into a supervised daemon, with automatic restart, rotating logs, and safe synchronized shutdown and startup. It doesn't require any installation, configuration files or special directory structures.
Android/SGX on the Gumstix Overo
9 Aug 2015This document explains how I, with some assistance and quite a bit of background research by Simon Guest at TracMap, got the PowerVR SGX drivers (3_01_00_03) working with Android 4.3 on the Gumstix Overo. What's described here isn't a finished product, but it's enough to get SurfaceFlinger up and running with hardware acceleration.
uFAT: small VFAT/FAT32 implementation
19 Jun 2015uFAT is small but feature-complete VFAT/FAT32 implementation. It supports all basic filesystem operations and has minimal memory requirements.
MSPDebug: debugging tool for MSP430 MCUs
8 Jun 2015MSPDebug is a free debugger for use with MSP430 MCUs. It supports FET430UIF, eZ430, RF2500 and Olimex MSP-JTAG-TINY programmers. It can be used as a proxy for gdb or as an independent debugger with support for programming, disassembly and reverse engineering.
Windows 32/64 cross GCC with C++11 threads support
5 Apr 2015This document explains how to build, on a POSIX system, a cross-compiling GCC targeting both 32 and 64 bit Windows systems, with C++11 threads support. It uses MinGW-w64.
Touch-screen filtering
23 Jan 2015Although the tslib library is often used on embedded Linux systems for touch-screen filtering, it can be done in a flexible and effective way in just a hundred or so lines of C++. The method described here has been tested on both a resistive touch-screen and a capacitative touch-pad.
Lightweight SQLite3 wrapper for C++
6 Jan 2015This pair of files implement a very lightweight wrapper for the public-domain SQLite3 database library. There are no external dependencies, apart from the SQLite3 library itself.
Simple HTML decluttering
24 Oct 2014Some time ago, I implemented a very simple Perl script for the removal of HTML boilerplate (advertising, comments and other clutter surrounding the content on commercial websites). The script is less than 300 lines long, and uses very simple a series of tree-processing algorithms which can be customized and tuned.
Fast multi-word software shift registers
14 Sep 2014This article describes a method of implementing fixed-size bit-queues, or shift registers, for very fast real-time operation. The method described is far faster and more flexible than shifting through multiple machine words.
Curve25519 and Ed25519 for low-memory systems
25 Apr 2014This package contains portable public-domain implementations of Daniel J. Bernstein's Curve25519 Diffie-Hellman function, and of the Ed25519 signature system. The memory consumption is low enough that they could be reasonably considered for most microcontroller applications. In particular, Curve25519 scalar multiplication uses less than half a kB of peak stack usage.
Simple and effective NOR-flash shadow paging
14 Apr 2014This package implements a simple and effective shadow-paging scheme for use with NOR flash or EEPROM. It allows small sets of data (such as configuration) to be stored atomically and reliably in the face of power and programming failures.
NaCl cryptography primitives for small MCUs
29 Dec 2013These are NaCl-compatible primitives optimized for use on small (8 and 16-bit) MCUs. They use a very small amount of stack space, at a modest performance penalty. The implementation is in the public domain.
Dhara: a small and reliable NAND flash translation layer
10 Dec 2013Dhara is a small flash translation layer designed to be used in resource-constrained systems for managing NAND flash. It provides a mutable block interface with standard read and write operations.
Anuweb: web interface for Totem
1 Aug 2013Anuweb is a Totem plugin which provides a simple web interface. Via the interface, you can control playback (play, pause, toggle full-screen, seek, etc.) and browse for files.
Static stack analysis with AVR-GCC
31 May 2013A static stack analysis tool for AVR-GCC (but portable to other architectures.
Introduction to asynchronous programming
19 Mar 2013This article serves as an introduction to asynchronous programming, explaining the differences between asynchronous and event-based programming, and describing some basic techniques.
Converting a PDF document to HTML
3 Jan 2013G.H. Hardy's autobiography, has been made available in PDF format by the University of Alberta's Mathematical Science Society. Attempts to convert the document to HTML using tools like pdftotext or pdftohtml yield poor results -- out-of-order text, missing paragraph breaks, unwanted page numbers and inconveniently placed footnotes. By extracting and examining all available typesetting information in a PDF, we can do a better job than this.
Saraswati: text-mode EPUB reader for Linux.
29 Dec 2012Saraswati is a text-mode EPUB reader for Linux. It is fast, small and easy to use.
Quirc: a fast and portable QR-code recognition library
29 Dec 2012QR codes are a type of high-density matrix barcodes, and quirc is a library for extracting and decoding them from images.
An std::map replacement with efficient range queries.
7 Dec 2012A summary map is a drop-in replacement for std::map with the additional property that it supports efficient computation of aggregate functions over contiguous ranges.
Katcat: Sanyo 6650 (Katana II) user data extraction
28 Jun 2012Katcat is a tool for extracting media files from a Sanyo 6650 CDMA phone (also known as Katana II) via the USB data cable.
Cdok: calcudoku puzzle generator
24 May 2012Calcudoku is a sudoku-like game invented by Tetsuya Miyamoto (marketed under the trademarked name "KenKen"). This program can be used to examine, print, solve and generate Calcudoku problems of any size up to 16x16.
Reliable packetization over a noisy serial line
10 May 2012Many peripherals still use raw UART-based protocols like RS-232 and RS-485, particularly in industrial electronics. Any protocol for communication over one of these serial lines needs to be able to cope with transmission errors and garbage.
Getcast: simple command-line podcast downloader
24 Jan 2012This script is a simple tool for managing podcast subscriptions. It doesn't use any global configuration or database. Instead, each subscribed podcast is kept in its own directory, which contains the downloaded media files. This is referred to as a podcast repository.
Miscellaneous patches
24 Jan 2012Often, libraries need to be modified before they can be used in an embedded system. These patches add or fix functionality for specific uses of various popular open source software packages.
A better FFT-based audio visualization
25 Oct 2011There are a lot of FFT-based audio visualizations available, but they usually make the mistake of displaying a raw FFT-based bar graph. This leads to a display which flickers wildly and doesn't appear to move in time with the audio. This problem can be fixed though, with a few simple modifications.
Robust I2C slave without a sampling clock
25 Aug 2011I2C is a popular two-wire serial bus protocol for communicating between devices. Most MCUs support it, so it's a good choice of interface for many chips. This article shows how to implement an I2C slave interface without the use of a bus sampling clock.
Generating difficult Sudoku puzzles quickly
13 Jun 2011This article explains a simple method to quickly estimate the difficulty of a Sudoku puzzle which correlates reasonably well with human estimates of difficulty. It also gives an algorithm which can be used to generate difficult puzzles reliably and efficiently. Source code for an implementation of this algorithm is also provided.
Pulse Density Modulation for software DACs
8 Mar 2011PDM is a method of continuously varying the average value of a digital signal, but without having a fixed modulation period, as in PWM. It allows generation of a time-varying signal in software with less CPU load than an equivalent PWM scheme.
Efficient aggregate computation on B+Trees
10 Feb 2011This article describes an enhancement to the B+Tree data structure which enables certain types of summaries to be computed on arbitrary contiguous subsets of a B+ tree in O(log n) time. The time complexities of the usual B+Tree operations for insertion and deletion are not affected, and still run in O(log n) time.