Skip to content

SaiVK/xv6-riscv-docker

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 

Repository files navigation

xv6-riscv setup with docker


Setting up Docker image with Riscv-tools:

Step 1: Install Docker by referring to the following link: https://docs.docker.com/engine/install/

Step 2: Pull riscv-tools docker image.

docker pull svkv/riscv-tools:v1.0

Step 3: Verifying docker image

docker run -it svkv/riscv-tools:v1.0

The above command results in a bash. The /home/os-iitm is the home directory which houses the install/ directory where all the RiscV related tools and qemu binaries are located. Press Ctrl^D to exit from the docker container.

Building xv6-riscv with Docker

Step 1: Clone xv6-riscv repo into your host system.

git clone https://github.com/mit-pdos/xv6-riscv

Note the complete path of xv6-riscv in your host system using the pwd command.

Step 2: Executing xv6-riscv inside docker.
Execute the following command on host system. You will get a shell within the docker container. Note: In the below command add the full path to xv6-riscv repo that you have cloned to your host system after the -v flag. Use the pwd command to get complete path.

docker run -it -v <path to where xv6-riscv cloned in your host system>/xv6-riscv:/home/os-iitm/xv6-riscv svkv/riscv-tools:v1.0

Inside docker container shell, execute the following command to get started with xv6-riscv:

cd xv6-riscv && make qemu

The -v flag enables shared volumes between host system and docker container. The xv6-riscv cloned repo resides on the host system and is shared with the docker container.

Debugging xv6-riscv with gdb

Run the following commands. On host system:

docker run -it -v <path to xv6-riscv in your host system>:/home/os-iitm/xv6-riscv svkv/riscv-tools:v1.0

Inside docker container:

cd xv6-riscv && make qemu-gdb

On host system in another terminal tab:

docker ps

Note the container id for svkv/riscv-tools:v1.0 container on host system:

docker exec -it <container-id> bash

Inside the replica docker container created:

riscv64-unknown-elf-gdb xv6-riscv/kernel/kernel
target remote localhost:<tcp port id>

Note:

  1. The xv6-riscv repo should be cloned to your host system and not inside the docker container.
  2. The workflow is as follows: Use your host system to edit any xv6-riscv related source file. Share the xv6-riscv repo/volume with the docker container for build/execution with riscv-tools present in the docker container.
  3. Any files that you create within the docker container outside of the shared volume is non-persistent and gets deleted automatically when you exit from the container.
  4. Any file that is created within the docker container inside of the shared volume is persistent. But you need superuser permissions to edit them from your host system. There are ways to circumvent this, which you can refer it online.

About

xv6-riscv on Docker

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published