Skip to content

Instantly share code, notes, and snippets.

View madushan1000's full-sized avatar

Madushan Nishantha madushan1000

View GitHub Profile
@madushan1000
madushan1000 / miopen.log
Created March 20, 2026 23:43
miopen.log
root@e66668d62a9a:/code/piper1-gpl# cat test.py
import torch
c = torch.nn.Conv1d(128, 128, 3, padding=2, dilation=2, bias=False).cuda()
x = torch.rand(1, 128, 302, dtype=torch.float32).cuda()
c(x)
root@e66668d62a9a:/code/piper1-gpl# python3 test.py
MIOpen(HIP): Warning [IsEnoughWorkspace] [GetSolutionsFallback WTI] Solver <GemmFwdRest>, workspace required: 463872, provided ptr: 0 size: 0
@madushan1000
madushan1000 / burn
Created December 7, 2025 21:39
tensor example
[[[-0.5323, 1.1509, -1.2466, -0.1808, -1.3224, 0.3614, 0.2781, 1.1339, -0.1805, -0.7471],
[-1.2535, -1.0930, -1.3010, 0.3243, -0.4782, -0.0493, -0.8164, -0.2335, -0.6023, -0.9540],
[-0.3200, 0.0803, 0.2877, -0.8148, -0.1710, 1.2067, -0.5816, 1.4084, -1.1918, -0.7204],
[0.0589, 1.4916, 0.3851, -0.0941, -1.3393, -0.0096, -1.6063, 0.0314, -0.8067, 1.0071],
[-0.9615, 1.3228, -0.2963, -0.8308, -0.2307, -0.9506, 0.3034, 0.1466, -1.3638, 0.2169],
[0.3725, -0.3141, 1.8697, 0.0627, -0.0170, -0.9448, 1.9442, 0.3522, 1.4926, -0.5919],
[-0.1878, 0.7114, 1.8772, -0.2393, -1.2131, 0.9085, -1.6744, 2.1503, -1.4187, 0.4601],
[0.6660, -1.5166, -0.3948, -1.4824, -2.2415, -0.6271, 1.1016, -0.0815, 1.2292, -0.2348],
[0.3735, 0.8327, 2.5236, -0.4769, 0.6389, 0.8491, -0.2100, -1.2092, 2.1527, 0.2349],
[-0.9572, 1.4462, 0.4278, 1.3431, -0.0346, 1.8803, 0.7505, -0.1407, -2.0318, 0.2478],
@madushan1000
madushan1000 / meson.build
Created November 27, 2024 12:06
libcore meson.build
project('libcore', ['java'])
openjdk_javadoc_files = [
'ojluni/src/main/java/java/awt/font/NumericShaper.java',
'ojluni/src/main/java/java/awt/font/TextAttribute.java',
'ojluni/src/main/java/java/beans/IndexedPropertyChangeEvent.java',
'ojluni/src/main/java/java/beans/PropertyChangeEvent.java',
'ojluni/src/main/java/java/beans/PropertyChangeListener.java',
'ojluni/src/main/java/java/beans/PropertyChangeListenerProxy.java',
'ojluni/src/main/java/java/beans/PropertyChangeSupport.java',
@madushan1000
madushan1000 / readme.md
Last active June 23, 2024 14:50
Reverese engineer a static library one function at a time.

GCC has an interesting flag we can use to switch out an implementation of a function at link time, called "wrap".  I think this is usually used for testing functions with unpredictable inputs. But we can use this to add a reverse-engineered implementation and redirect all references in the object code to our implementation. If we want to replace

void some_func() {}

We must name our implementation __wrap_some_func(). So we have to add __wrap_ to the beginning of the function name.

void __wrap_some_func() {
  //some code
@madushan1000
madushan1000 / zmk_split_battery_level_linux.py
Created January 16, 2024 22:25
See battery levels of a zmk split ble keyboard on linux
from dbus_next.aio import MessageBus
from dbus_next.constants import BusType
import asyncio
BLUEZ = "org.bluez"
#replace hci0 with your bluetooth adapter name and FF_FF_FF_FF_FF_FF with your keyboard address
BLUEZ_PATH = "/org/bluez/hci0/dev_FF_FF_FF_FF_FF_FF"
GATT_SERVICE = 'org.bluez.GattService1'
GATT_CHARACTERISCITC = 'org.bluez.GattCharacteristic1'
GATT_CHARACTERISCITC_DESCR = 'org.bluez.GattDescriptor1'
BATTERY_UUID = "0000180f-0000-1000-8000-00805f9b34fb"
@madushan1000
madushan1000 / wezterm.lua
Last active August 28, 2023 21:06
wezterm tmux keybindings
local config = {}
config.key_tables = {
tmux_bindings = {
{ key = "a", mods = "CTRL", action=wezterm.action{SendString="\x01"}},
{ key = "\"", mods = "SHIFT", action=wezterm.action{SplitVertical={domain="CurrentPaneDomain"}}},
{ key = "%",mods = "SHIFT", action=wezterm.action{SplitHorizontal={domain="CurrentPaneDomain"}}},
{
@madushan1000
madushan1000 / uuu-load-linux.lst
Last active April 14, 2023 21:34
bl808 load linux over fastboot using uuu
CFG: FB: -vid 0x18d1 -pid 0x4e40
FB: getvar version
FB: ucmd setenv fastboot_buffer 0x51000000
FB: download -f out/fw_payload.elf
FB: ucmd setenv fastboot_buffer 0x51500000
FB: download -f linux/arch/riscv/boot/Image.gz
FB: ucmd setenv fastboot_buffer 0x51400000

connect all the jtag pins and connect PU_CHIP pin to nReset/srst/sreset of the ftdi jtag adapter/rv debugger plus

and use the bellow config

pine64jtag.cfg

interface ftdi

#may need to change this to your adapters vid and pid
ftdi_vid_pid 0x0403 0x6014
@madushan1000
madushan1000 / 1-readme.md
Last active February 21, 2023 08:36
How to flash/boot bl808 over USB

Compile U-boot

Get riscv-32 musl toolchain. Get u-boot tree with usb support and compile it.

#toolchain
wget https://musl.cc/riscv32-linux-musl-cross.tgz
tar xf riscv32-linux-musl-cross.tgz
export PATH=$PWD/riscv32-linux-musl-cross/bin:$PATH

#u-boot
#
# Automatically generated file; DO NOT EDIT.
# Linux/x86 5.11.0-40-generic Kernel Configuration
#
CONFIG_CC_VERSION_TEXT="gcc (Ubuntu 10.3.0-1ubuntu1) 10.3.0"
CONFIG_CC_IS_GCC=y
CONFIG_GCC_VERSION=100300
CONFIG_LD_VERSION=236010000
CONFIG_CLANG_VERSION=0
CONFIG_LLD_VERSION=0