Skip to content

Instantly share code, notes, and snippets.

@binarycraft007
binarycraft007 / asus-s5507-dmesg.txt
Created September 21, 2025 12:03
ASUS Vivobook S 15 dmesg log
[ 0.000000] Booting Linux on physical CPU 0x0000000000 [0x512f0011]
[ 0.000000] Linux version 6.17.0-rc5-7-qcom-laptops (linux-qcom-laptops@archlinux) (aarch64-linux-gnu-gcc (GCC) 15.1.0, GNU ld (GNU Binutils) 2.44) #1 SMP PREEMPT Sun, 21 Sep 2025 11:22:04 +0000
[ 0.000000] KASLR enabled
[ 0.000000] Machine model: ASUS Vivobook S 15
[ 0.000000] efi: EFI v2.9 by INSYDE Corp.
[ 0.000000] efi: SMBIOS=0xd4462000 SMBIOS 3.0=0xd445f000 TPMFinalLog=0xd46e0000 ACPI 2.0=0xd47d3018 MEMATTR=0xd0a00018 ESRT=0xceb47d18 RNG=0xd47d3998 TPMEventLog=0xd4778018 INITRD=0xc484bd18 MEMRESERVE=0xc484b498
[ 0.000000] random: crng init done
[ 0.000000] esrt: Reserving ESRT space from 0x00000000ceb47d18 to 0x00000000ceb47dc8.
[ 0.000000] Reserved memory: created CMA memory pool at 0x0000000ff8000000, size 128 MiB
[ 0.000000] OF: reserved mem: initialized node linux,cma, compatible id shared-dma-pool
@binarycraft007
binarycraft007 / hid-asus-vivobook-s15.c
Last active September 21, 2025 10:02
HID driver for ASUS Vivobook S15 S5507 Keyboard
// SPDX-License-Identifier: GPL-2.0-only
/*
* HID driver for ASUS Vivobook S15 S5507 Keyboard
*
* Copyright (c) 2024 Elliot Huang (keep.it.sns@gmail.com)
*
* This driver handles special function keys for keyboard backlight control,
* Fn-Lock, and re-maps certain vendor-specific keys to standard consumer
* control usages (e.g., display brightness). It also handles suspend and
* resume by turning off the backlight on suspend and restoring the full
@binarycraft007
binarycraft007 / dtb-splitter.zig
Created May 24, 2025 15:29
A program to split dtb from appended kernel image
//! This program splits a kernel image file that has Device Tree Blobs (DTBs) appended to it.
//! It extracts the main kernel part and each DTB into separate files.
//! The kernel is saved as "kernel". DTBs are saved as "dtbdump_1.dtb", "dtbdump_2.dtb", etc.
const std = @import("std");
const fs = std.fs;
const mem = std.mem;
const heap = std.heap;
const fmt = std.fmt;
const process = std.process;
@binarycraft007
binarycraft007 / atcmd.zig
Created May 16, 2025 03:01
AT command tool in zig
const max_output_bytes = 4096;
pub fn main() !void {
var arena_state = std.heap.ArenaAllocator.init(std.heap.smp_allocator);
defer arena_state.deinit();
const arena = arena_state.allocator();
var file = try std.fs.openFileAbsolute("/dev/smd7", .{ .mode = .read_write });
defer file.close();
@binarycraft007
binarycraft007 / mnl.zig
Created April 20, 2025 14:18
mnl in zig
const std = @import("std");
const mem = std.mem;
const linux = std.os.linux;
const posix = std.posix;
const assert = std.debug.assert;
const testing = std.testing;
const AttrDataType = enum(u14) {
unspec,
u8,
@binarycraft007
binarycraft007 / event_loop.zig
Created April 16, 2025 06:00
epoll event loop in zig
// Allocation-free event loop inspired by uloop: fixed arrays, no heap allocations.
const std = @import("std");
const mem = std.mem;
const posix = std.posix;
const linux = std.os.linux;
const testing = std.testing;
const log = std.log.scoped(.event_loop);
pub const MAX_EVENTS = 64;
pub const MAX_HANDLERS = 128;
const std = @import("std");
pub fn main() !void {
// Use the debug allocator.
var gpa_state: std.heap.DebugAllocator(.{}) = .init;
defer _ = gpa_state.deinit();
const gpa = gpa_state.allocator();
// Expect two arguments: <elf_file> and <prefix>
const args = try std.process.argsAlloc(gpa);
const file_version = &[_]u8{ 0x02, 0x00, 0x00, 0x00, 0x00, 0x00 };
pub fn main() !void {
var gpa_state: std.heap.GeneralPurposeAllocator(.{}) = .init;
defer _ = gpa_state.deinit();
const gpa = gpa_state.allocator();
var raw = std.ArrayList(u8).init(gpa);
defer raw.deinit();
@binarycraft007
binarycraft007 / imei.zig
Created January 20, 2025 00:23
imei to raw hex
const std = @import("std");
const testing = std.testing;
const assert = std.debug.assert;
const IMEI = struct {
raw: [26]u8,
pub fn parse(imei_str: []const u8) !IMEI {
var imei: IMEI = undefined;
assert(imei_str.len == 15);
@binarycraft007
binarycraft007 / hdlc.zig
Created January 13, 2025 13:29
hdlc zig implementation
const std = @import("std");
const mem = std.mem;
const hdlc = @This();
const escape_char = '\x7d';
const trailer_char = '\x7e';
const Crc16Ccitt = std.hash.crc.Crc(u16, .{
.polynomial = 0x11021,
.initial = 0x0000,