Skip to content

Instantly share code, notes, and snippets.

View z4yx's full-sized avatar
☢️

Yuxiang Zhang z4yx

☢️
View GitHub Profile
@z4yx
z4yx / Info.plist
Created November 21, 2019 04:29
macOS 10.14.6 (18G1012) /usr/libexec/SmartCardServices/drivers/ifd-ccid.bundle/Contents/Info.plist
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>English</string>
<key>CFBundleExecutable</key>
<string>libccid.dylib</string>
<key>CFBundleIdentifier</key>
<string>org.debian.alioth.pcsclite.smartcardccid</string>
@z4yx
z4yx / extra-instr.s
Last active November 21, 2019 13:02
.set noreorder
.set noat
.globl __start
.text
__start:
li $s0, 0x80100000
li $s1, 0
li $s2, 1
lw $a1, 4($s0) # selection
lw $a2, 8($s0) # random
/**************** from pn53x-internal.h **********/
// Register addresses
#define PN53X_REG_Control_switch_rng 0x6106
#define PN53X_REG_CIU_Mode 0x6301
#define PN53X_REG_CIU_TxMode 0x6302
#define PN53X_REG_CIU_RxMode 0x6303
#define PN53X_REG_CIU_TxControl 0x6304
#define PN53X_REG_CIU_TxAuto 0x6305
#define PN53X_REG_CIU_TxSel 0x6306
#define PN53X_REG_CIU_RxSel 0x6307
@z4yx
z4yx / mipsel-none-elf-binutils.rb
Created January 18, 2020 13:57
MIPS GCC for Homebrew
class MipselNoneElfBinutils < Formula
desc "FSF Binutils for mipsel cross development"
homepage "https://www.gnu.org/software/binutils/"
url "https://ftp.gnu.org/gnu/binutils/binutils-2.32.tar.gz"
sha256 "9b0d97b3d30df184d302bced12f976aa1e5fbf4b0be696cdebc6cca30411a46e"
def install
system "./configure", "--target=mipsel-none-elf",
"--disable-multilib",
"--disable-nls",
package main
// bash -c 'CGO_ENABLED=0 GOARCH=amd64 GOOS=linux go build -o clean clean.go'
// Usage:
// bandersnatch -c /tmp/b.conf verify --delete --dry-run &>verify-dry-run.log
// ./clean <verify-dry-run.log >clean.log
import ( "fmt";"log"; "os"; "time";"bufio";"strings" )
func main() {
@z4yx
z4yx / W25Q128-ID.c
Created March 8, 2020 12:23
kernel driver code snippet to read unique ID of W25Q128
#include <linux/random.h>
int spi_nor_scan(struct spi_nor *nor, const char *name, enum read_mode mode) {
// ...
// after mutex_init(&nor->lock);
if(memcmp(info->id, "\xef\x40\x18", 3) == 0) {
int ret;
u8 buf[4+8]; // 4 dummy + 64-bit ID
dev_warn(dev, "reading unique ID\n");
ret = nor->read_reg(nor, 0x4B, buf, sizeof(buf)); // Read Unique ID number
From 84a933323d59b27ae85cf16deddc254a0b17e450 Mon Sep 17 00:00:00 2001
From: Shraddha Chaudhari <Shraddha.Chaudhari@imgtec.com>
Date: Tue, 5 Jan 2016 11:16:43 +0530
Subject: mtd: spi-nor: add support for winbond OTP
Few winbond spi nor devices support 3 x 256 bytes
of security registers, add support for read, write, lock
of these registers as user OTP.
Also add support for reading winbond devices unique ID
@z4yx
z4yx / rhel-nginx-module.md
Last active March 12, 2020 12:03
如何为rhel编译nginx module (how to compile dynamic nginx modules on rhel)

下载源码

wget 'http://nginx.org/packages/centos/7/SRPMS/nginx-1.14.2-1.el7_4.ngx.src.rpm'
rpm -i nginx-1.14.2-1.el7_4.ngx.src.rpm
tar -xf rpmbuild/SOURCES/nginx-1.14.2.tar.gz

下载module源码

/* SPDX-License-Identifier: GPL-2.0 */
#ifndef __BPF_HELPERS_H
#define __BPF_HELPERS_H
/* helper macro to place programs, maps, license in
* different sections in elf_bpf file. Section names
* are interpreted by elf_bpf loader
*/
#define SEC(NAME) __attribute__((section(NAME), used))
echo "" >>/media/removable/boot/config.txt
echo "enable_uart=1" >>/media/removable/boot/config.txt
touch /media/removable/boot/ssh
cat >/media/removable/boot/wpa_supplicant.conf <<EOF
country=CN
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
network={
ssid="dd-wrt"