Skip to content

Instantly share code, notes, and snippets.

@hansemro
hansemro / mesa-pvr-21.1.6.PKGBUILD
Last active April 4, 2022 06:26
mesa-pvr-21.1.6.PKGBUILD
# This is an example PKGBUILD file. Use this as a start to creating your own,
# and remove these comments. For more information, see 'man PKGBUILD'.
# NOTE: Please fill out the license field for your package! If it is unknown,
# then please put 'unknown'.
pkgname=mesa-pvr-dri-classic
pkgver=21.1.6
pkgrel=1
epoch=
#_tag=mesa-pvr-21.1.6
@hansemro
hansemro / make_all_godot4.sh
Last active August 9, 2022 21:02
Godot 4 build script for Linux, OSX, Windows
#!/usr/bin/env bash
# godot 4 version
set -e
NPROC=10
# clean to prevent build issues
scons --clean
@hansemro
hansemro / cm.py
Created September 9, 2022 21:46
CM Pro S RGB usb com test
#!/usr/bin/env python3
import usb.core
import usb.util
def send_recv_cmd(dev, cmd):
"""
Write USB command over endpoint 4 and return response from endpoint 3 as an
array.
"""
@hansemro
hansemro / decode_bit_band_alias.py
Created September 30, 2022 09:04
[ARM Cortex] Encode/Decode Bit-band Alias Address
#!/usr/bin/env python3
# SPDX-License-Identifier: MIT
# Copyright (c) 2022 Hansem Ro <hansemro@outlook.com>
def encode_bit_band_alias(addr_offset:int, bit_number:int, alias_base:int):
return alias_base + addr_offset*32 + bit_number*4
def decode_bit_band_alias(bit_alias:int, alias_base:int, addr_base:int):
bit_alias_tmp = bit_alias - alias_base
addr_offset = int(bit_alias_tmp / 32)
@hansemro
hansemro / led_pos.py
Created October 10, 2022 23:11
QMK led_config_t: TKL LED Index to Position
#!/usr/bin/env python3
import numpy as np
# formatted:
# ./led_pos.py | sed -E "s/\[/{/g" | sed -E "s/\]/\}/g" | sed -E "s/\{(\s+?)([0-9]+)(\s+)([0-9]+)}/{\1\2,\3\4},/g" | sed -E "s/\},\}/}}/g"
x_max = 224
y_max = 64
@hansemro
hansemro / build_linux_toolchain.sh
Created October 19, 2022 10:07
Build script for nds32 v3 toolchain
# git clone -b ast-v3_2_5-release-v3 https://github.com/andestech/nds-gnu-toolchain
# cd nds-gnu-toolchain
# git submodule update --init --recursive
# patch binutils and gcc...
TARGET=nds32le-linux
PREFIX=`pwd`/nds32le-linux-glibc-v3
ARCH=v3
CPU=n9
BUILD=`pwd`/build-nds32le-linux-glibc-v3
@hansemro
hansemro / holtek_isp.py
Last active December 17, 2022 20:14
Holtek ISP USB communication test
#!/usr/bin/env python3
# SPDX-License-Identifier: MIT
# Copyright (c) 2022 Hansem Ro
# Holtek HT32 ISP Test
# Tested on HT32F1654 and HT32F52352
import struct
import time
from argparse import ArgumentParser
@hansemro
hansemro / Makefile.dump
Last active June 24, 2024 13:21
cocotb Makefile with waveform dumping for vcs/icarus/verilator
## include this in your normal cocotb Makefile in place of standard cocotb
## include to support waveform dumping with SIM=<vcs|icarus|verilator>
## For vcs:
## To select between *.vcd and *.vpd waveform dumps, set WAVES=<VCD|VPD>
## variable. This variable can be an environmental varaiable, a variable
## defined in the Makefile, or a variable passed to make.
## For icarus or verilator:
## To select between *.vcd and *.fst waveform dumps, set WAVES=<VCD|FST>
@hansemro
hansemro / library_double_sides.il
Last active March 4, 2023 20:58
[Cadence SKILL] Double width of sides of layout/abstract shapes/labels/boundaries/blockages
; SPDX-License-Identifier: MIT
; Copyright (c) 2023 Hansem Ro <hansemro@outlook.com>
procedure(library_double_sides(libName)
let(()
; Version: 1.1
; Description:
; This doubles the width and height of all layout/abstract cells
; in the given library including:
; - prBoundary
@hansemro
hansemro / Nangate_replace_mos.il
Created March 4, 2023 06:52
[FreePDK45-NanGate][Cadence SKILL] Replace analog MOSFET models to NCSU models
; SPDX-License-Identifier: MIT
; Copyright (c) 2023 Hansem Ro <hansemro@outlook.com>
procedure(Nangate_replace_mos(libName)
let((lib cell cellName views cvId instList inst)
lib=ddGetObj(libName)
foreach(cell lib~>cells
cellName = cell~>name
printf("%s %d\n" cellName cell)
views = ddGetObjChildren(cell)