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
git clone https://git.busybox.net/busybox
cd busybox
git checkout 1_32_1
make defconfig
make menuconfig
dd if=/dev/zero of=root.bin bs=1M count=64
mkfs.ext2 -F root.bin
mkdir mnt
sudo mount -o loop root.bin mnt
cd mnt
sudo mkdir -p bin etc dev lib proc sbin tmp usr usr/bin usr/lib usr/sbin
sudo cp ~/busybox/busybox bin
@paranlee
paranlee / vmlinux.lds.S
Last active June 2, 2021 01:47
Linux kernel v5.4.123 64bit RISC-V vmlinux.lds.S
/* SPDX-License-Identifier: GPL-2.0-only */
/*
* Copyright (C) 2012 Regents of the University of California
* Copyright (C) 2017 SiFive
*/
#define LOAD_OFFSET PAGE_OFFSET
#include <asm/vmlinux.lds.h>
#include <asm/page.h>
#include <asm/cache.h>
@paranlee
paranlee / vmlinux.lds
Last active June 2, 2021 10:45
Linux kernel v5.4.123 64bit RISC-V vmlinux.lds
OUTPUT_ARCH(riscv)
ENTRY(_start)
jiffies = jiffies_64;
SECTIONS
{
. = 0xffffffe000000000;
_start = .;
__init_begin = .;
.head.text : AT(ADDR(.head.text) - 0xffffffe000000000) { KEEP(*(.head.text)) }
. = ALIGN((1 << (12))); .init.text : AT(ADDR(.init.text) - 0xffffffe000000000) { _sinittext = .; *(.init.text .init.text.*) *(.text.startup) *(.meminit.text*) _einittext = .; }
@paranlee
paranlee / vmlinux.lds.h
Last active June 2, 2021 10:59
Linux kernel v5.4.123 64bit RISC-V linux/include/asm-generic/vmlinux.lds.h
/*
* Helper macros to support writing architecture specific
* linker scripts.
*
* A minimal linker scripts has following content:
* [This is a sample, architectures may have special requiriements]
*
* OUTPUT_FORMAT(...)
* OUTPUT_ARCH(...)
* ENTRY(...)
@paranlee
paranlee / cache.h
Last active June 2, 2021 10:59
Linux kernel v5.4.123 64bit RISC-V linux/arch/riscv/include/asm/cache.h
/* SPDX-License-Identifier: GPL-2.0-only */
/*
* Copyright (C) 2017 Chen Liqin <liqin.chen@sunplusct.com>
* Copyright (C) 2012 Regents of the University of California
*/
#ifndef _ASM_RISCV_CACHE_H
#define _ASM_RISCV_CACHE_H
#define L1_CACHE_SHIFT 6
@paranlee
paranlee / page.h
Last active June 2, 2021 10:59
Linux kernel v5.4.123 64bit RISC-V linux/arch/riscv/include/asm/page.h
/* SPDX-License-Identifier: GPL-2.0-only */
/*
* Copyright (C) 2009 Chen Liqin <liqin.chen@sunplusct.com>
* Copyright (C) 2012 Regents of the University of California
* Copyright (C) 2017 SiFive
* Copyright (C) 2017 XiaojingZhu <zhuxiaoj@ict.ac.cn>
*/
#ifndef _ASM_RISCV_PAGE_H
#define _ASM_RISCV_PAGE_H
@paranlee
paranlee / thread_info.h
Last active June 2, 2021 10:59
Linux kernel v5.4.123 64bit RISC-V linux/arch/riscv/include/asm/thread_info.h
/* SPDX-License-Identifier: GPL-2.0-only */
/*
* Copyright (C) 2009 Chen Liqin <liqin.chen@sunplusct.com>
* Copyright (C) 2012 Regents of the University of California
* Copyright (C) 2017 SiFive
*/
#ifndef _ASM_RISCV_THREAD_INFO_H
#define _ASM_RISCV_THREAD_INFO_H
@paranlee
paranlee / vmlinux-sample.lds.S
Created June 2, 2021 11:07
Linux kernel v5.4.123 64bit RISC-V vmlinux.lds sample lds comment
/*
* Helper macros to support writing architecture specific
* linker scripts.
*
* A minimal linker scripts has following content:
* [This is a sample, architectures may have special requiriements]
*/
OUTPUT_FORMAT(...)
OUTPUT_ARCH(...)
@paranlee
paranlee / fork_anon_vma.c
Last active June 14, 2021 10:40
Try to Study Rmap.
/**
* Rmap Study in Linux Kernel v5.1
*
* [kernel/fork.c -> rmap.c] rmap init routine.
*
* do_fork [kernel/fork.c]
* - _do_fork [kernel/fork.c]
* -- copy_process [kernel/fork.c]
* --- copy_mm [kernel/fork.c]
*