Skip to content

Instantly share code, notes, and snippets.

@jkent
jkent / printf.c
Last active November 4, 2023 03:15
Public domain printf implementation (fp incomplete)
#include <ctype.h>
#include <stdarg.h>
#include <stddef.h>
#include <stdint.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <sys/types.h>
#!/usr/bin/env python3
from binascii import hexlify
from time import sleep
from zag import MHR, Radio
def main():
def packet_handler(data, rssi, link_quality):
mhr, offset = MHR.decode(data)
print(hexlify(mhr.encode() + data[offset:]).decode('utf8'))
@jkent
jkent / rpcclient.py
Last active August 15, 2022 21:05
Simple python RPC server/client
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# vim: set ts=4 et
import json
import socket
class RpcException(Exception):
pass
@jkent
jkent / linux-2.6.35.7-wheezy-udev-fix.patch
Created December 18, 2013 18:45
Fix for running debian wheezy using FriendlyARM's 2.6.35.7 kernel. Also fixes build with Android arm-eabi-4.6 toolchain
diff -ru linux-2.6.35.7.orig/arch/arm/include/asm/unistd.h linux-2.6.35.7/arch/arm/include/asm/unistd.h
--- linux-2.6.35.7.orig/arch/arm/include/asm/unistd.h 2011-08-07 23:52:04.000000000 -0500
+++ linux-2.6.35.7/arch/arm/include/asm/unistd.h 2013-12-18 11:50:52.123791000 -0600
@@ -392,6 +392,7 @@
#define __NR_rt_tgsigqueueinfo (__NR_SYSCALL_BASE+363)
#define __NR_perf_event_open (__NR_SYSCALL_BASE+364)
#define __NR_recvmmsg (__NR_SYSCALL_BASE+365)
+#define __NR_accept4 (__NR_SYSCALL_BASE+366)
/*
@jkent
jkent / hlkcrypt.c
Last active January 16, 2024 03:23
This tool encrypts and decrypts uImage formatted firmware for Hilink HLK-RM04 wireless modules. It will also truncate a dump of mtd6 and make it an image suitable for flashing via the stock firmware upgrade page. Build instructions: gcc hlkcrypt.c -lcrypto -o hlkcrypt
/* vim: set ts=4
*
* Copyright (C) 2013 Jeff Kent <jeff@jkent.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@jkent
jkent / rm04-tool.html
Created June 10, 2013 12:02
Another backdoor for the rm04, need I say any more?
<html>
<head>
<title>HLK-RM04 Tool</title>
<style>
form {
display: inline;
}
</style>
</head>
@jkent
jkent / squashfs-special.patch
Created June 10, 2013 07:59
Adds support for an odd lzma image format to unsquashfs. To be used against http://sourceforge.net/projects/squashfs/files/squashfs/squashfs4.2/squashfs4.2.tar.gz
diff -Nrup squashfs-tools/compressor.c squashfs-tools/compressor.c
--- squashfs-tools/compressor.c 2011-02-11 09:49:24.000000000 -0600
+++ squashfs-tools/compressor.c 2013-06-10 02:11:35.096301000 -0500
@@ -59,6 +59,7 @@ static struct compressor xz_comp_ops = {
extern struct compressor xz_comp_ops;
#endif
+extern struct compressor special_comp_ops;
static struct compressor unknown_comp_ops = {
#!/usr/bin/env python
# -*- coding: utf8 -*-
# vim: set ts=4 et
from serial import Serial
import sys
from threading import Thread, Condition
class Reader(Thread):
def __init__(self, ser):
@jkent
jkent / ftdi.py
Last active December 14, 2015 17:49
wrapper class for libftdi1 and mpsse i2c bus and device classes
# -*- coding: utf-8 -*-
# vim: ts=4 et sw=4 sts=4 ai
import ftdi1
NONE = ftdi1.NONE
ODD = ftdi1.ODD
EVEN = ftdi1.EVEN
MARK = ftdi1.MARK
SPACE = ftdi1.SPACE
@jkent
jkent / make_m3u.sh
Created March 3, 2013 10:43
bash m3u playlist generator
#!/bin/bash
add_song() {
file=`readlink -e "$1"`
name=`basename "$1" | sed 's/\(.flac\|\.m4a\|\.mp3\|\.ogg\|\.wma\)$//i'`
echo "#EXTINF:0,$name" >> $playlist
echo "$file" >> $playlist
}
playlist=$1