Skip to content

Instantly share code, notes, and snippets.

View paranlee's full-sized avatar
🐧
Run RISC-V run!

Paran Lee paranlee

🐧
Run RISC-V run!
View GitHub Profile
@paranlee
paranlee / go-install-ubuntu-simple.sh
Last active June 20, 2021 05:20
go installation is so simple.
snap install --classic go # sudo apt -y install golang
go version
# go version go1.16.5 linux/amd64 # go version go1.13.8 linux/amd64
go get github.com/golang/example/hello
~/go/bin/hello
# Hello, Go examples!
@paranlee
paranlee / preinstall-chisel3.sh
Created June 24, 2021 08:01
preinstall chisel3
# apt snap
sudo apt update -y && \
sudo apt -y install snapd curl && \
sudo snap install intellij-idea-community --classic && \
sudo snap install code --classic
# sdkman
sudo apt -y install git make autoconf g++ flex bison
curl -s "https://get.sdkman.io" | bash
source "$HOME/.sdkman/bin/sdkman-init.sh"
@paranlee
paranlee / Ubuntu disk resize Hyper-V Quick.md
Last active March 22, 2026 23:46
Ubuntu disk resize Hyper-V Quick.

Expand Ubuntu disk after Hyper-V Quick Create

It is quick and easy to use Hyper-V Quick Create to get an Ubuntu virtual machine running on a Windows 10 computer. However, if this method is used, you may end up with a tiny Ubuntu virtual disk that will not be useful for any serious work and it is less obvious than the initial setup how to increase the size of this disk.

These steps fix the problem:

1. Turn off the VM.

2. Hyper-V Manager Settings Virtual hard disk.

@paranlee
paranlee / build.sh
Created August 10, 2021 07:12
build netlist svg file.
#!/bin/bash
yosys -q -p "prep -top $1; write_json $1.json" $1.v
netlistsvg $1.json -o $1.svg
@paranlee
paranlee / dff.v
Last active August 10, 2021 07:17
Setup from setup.sh. Build netlist svg file. $ bash netlist.sh dff
/**
* D flip-flop:
* https://github.com/edaplayground/eda-playground/blob/master/docs/code-examples/d-flip-flop.rst
*/
module dff (clk, reset,
d, q, qb);
input clk;
input reset;
input d;
output q;
@paranlee
paranlee / syscall-open-in-linux.c
Created October 19, 2021 01:24
from kernel to user syscall `open()` syscall in linux kernel 5.14.13 on arm64 and riscv.
/* https://elixir.bootlin.com/linux/v5.14.13/source/fs/open.c#L1224 */
SYSCALL_DEFINE3(open, const char __user *, filename, int, flags, umode_t, mode)
{
if (force_o_largefile())
flags |= O_LARGEFILE;
return do_sys_open(AT_FDCWD, filename, flags, mode);
}
#define SYSCALL_DEFINE3(name, ...) SYSCALL_DEFINEx(3, _##name, __VA_ARGS__)
@paranlee
paranlee / perf_event_template.c
Created November 9, 2021 04:23 — forked from teqdruid/perf_event_template.c
Template for using perf_event
/*
============================================================================
Name : branch_mispred.c
Author : John Demme
Version : Mar 21, 2011
Description : A template for perf_event. Requires Linux 2.6.32 or higher
============================================================================
*/
#define _GNU_SOURCE
/* https://elixir.bootlin.com/linux/v5.14.13/source/fs/open.c#L1224 */
SYSCALL_DEFINE3(open, const char __user *, filename, int, flags, umode_t, mode)
{
if (force_o_largefile())
flags |= O_LARGEFILE;
return do_sys_open(AT_FDCWD, filename, flags, mode);
}
/* /include/linux/syscalls.h::SYSCALL_DEFINE3 */
/* https://elixir.bootlin.com/linux/latest/source/tools/include/nolibc/nolibc.h#L2114 */
/* nolibc.h::open() */
static __attribute__((unused))
int open(const char *path, int flags, mode_t mode)
{
int ret = sys_open(path, flags, mode);
if (ret < 0) {
SET_ERRNO(-ret);
ret = -1;
}
/* arm64/include/asm/unistd32.h::__SYSCALL */
#undef __SYSCALL
#define __SYSCALL(nr, sym) asmlinkage long __arm64_##sym(const struct pt_regs *);
#include <asm/unistd.h>
#undef __SYSCALL
#define __SYSCALL(nr, sym) [nr] = __arm64_##sym,
/* arch/arm64/include/asm/unistd32.h::__NR_open */