Coder Social home page Coder Social logo

firesim / riscv-linux Goto Github PK

View Code? Open in Web Editor NEW

This project forked from riscvarchive/riscv-linux

4.0 22.0 6.0 1.57 GB

RISC-V Linux Port

License: Other

Makefile 0.25% C 96.02% Assembly 1.59% C++ 1.84% Objective-C 0.12% Shell 0.03% Prolog 0.04% Awk 0.01% Perl 0.08% Python 0.01% GDB 0.01% SourcePawn 0.01% Yacc 0.01% Lex 0.01% Perl 6 0.01% UnrealScript 0.01%

riscv-linux's Introduction

Linux/RISC-V

This is a port of Linux kernel for the RISC-V instruction set architecture. Development is currently based on the 4.6 longterm branch.

Checking Out

The kernel history is quite large, you may want to limit the branches and commit history that you checkout:

    $ git clone --depth 50 --single-branch https://github.com/riscv/riscv-linux.git

Obtaining the Toolchain

You will need the RISC-V tools in order to build linux. In addition to following the RISC-V tools README, you must build the linux version of the gnu toolchain:

$ cd path/to/riscv-gnu-toolchain
$ make linux

Building the kernel image

  1. Create kernel configuration based on architecture defaults:

     $ make ARCH=riscv defconfig
    
  2. Optionally edit the configuration via an ncurses interface:

     $ make ARCH=riscv menuconfig
    
  3. Build the uncompressed kernel image:

     $ make -j4 ARCH=riscv vmlinux
    
  4. Link the kernel to the Berkeley Boot Loader (bbl)

     $ cd /path/to/risv-tools/riscv-pk/build
     $ ../configure --with-payload=/path/to/riscv-linux/vmlinux --host=riscv64-unknown-linux-gnu
     $ make bbl
    
  5. Boot the kernel in the functional simulator.

     $ spike bbl
    

Booting from Initramfs

Block devices are not currently supported. If you want a useful linux, you will need to configure it to boot from an initramfs.

  1. Enable initramfs in the linux config:

     "General setup -> Initial RAM Filesystem..." (CONFIG_BLK_DEV_INITRD=y)
    
  2. Use a text file to specify contents of the initramfs:

     "General setup -> Initramfs source files = initramfs.txt" (CONFIG_INITRAMFS_SRC=initramfs.txt)
    

The file riscv-linux/initramfs.txt should contain a list of files to include. Here is a basic one to start with:

    dir /dev 755 0 0
    nod /dev/console 644 0 0 c 5 1
    nod /dev/null 644 0 0 c 1 3
    dir /proc 755 0 0
    slink /init /bin/busybox 755 0 0
    dir /bin 755 0 0
    file /bin/busybox /path/to/busybox 755 0 0
    dir /sbin 755 0 0
    dir /usr 755 0 0
    dir /usr/bin 755 0 0
    dir /usr/sbin 755 0 0
    dir /etc 755 0 0
    file /etc/inittab inittab 644 0 0
    dir /lib 755 0 0

Be sure to change "/path/to/busybox..." to point to your busybox binary (the RISC-V Tools README has instructions on building busybox). You will also need a riscv-linux/inittab file:

    ::sysinit:/bin/busybox --install
    ::sysinit:/bin/mount -t devtmpfs devtmpfs /dev
    ::sysinit:/bin/mount -t proc proc /proc
    /dev/console::sysinit:-/bin/ash

Now when you build and run linux, it should boot from the internal initramfs.

Exporting kernel headers

The riscv-gnu-toolchain repository includes a copy of the kernel header files. If the userspace API has changed, export the updated headers to the riscv-gnu-toolchain source directory:

$ make ARCH=riscv headers_check
$ make ARCH=riscv INSTALL_HDR_PATH=path/to/riscv-gnu-toolchain/linux-headers headers_install

Rebuild riscv64-unknown-linux-gnu-gcc with the linux target:

$ cd path/to/riscv-gnu-toolchain
$ make linux

riscv-linux's People

Contributors

acmel avatar adrianbunk avatar airlied avatar alexdeucher avatar arndb avatar axellin avatar bigguiness avatar broonie avatar bzolnier avatar danvet avatar davem330 avatar dhowells avatar geertu avatar gregkh avatar htejun avatar ickle avatar jmberg-intel avatar joeperches avatar larsclausen avatar linusw avatar mchehab avatar morimoto avatar olofj avatar pmundt avatar rafaeljw avatar ralfbaechle avatar rddunlap avatar tiwai avatar torvalds avatar vsyrjala avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.