Go to file
Lu Sitong 3f3ed61d9b Rename kalloc.c/h to pm.c/h;
Add primitive kmalloc module (not being used yet).
2021-04-25 13:22:09 +08:00
bootloader/SBI Add trace syscall; 2021-04-03 22:32:56 +08:00
debug add debug suport 2020-11-16 07:54:23 +09:00
doc Change another way of ext-intr handling. 2021-03-14 17:03:08 +08:00
img add SD driver doc v2 2021-03-09 15:32:23 +08:00
kernel Rename kalloc.c/h to pm.c/h; 2021-04-25 13:22:09 +08:00
linker update readme.md 2020-12-13 08:05:52 +09:00
tools first commit 2020-10-19 04:44:14 +09:00
xv6-user Rename kalloc.c/h to pm.c/h; 2021-04-25 13:22:09 +08:00
.gitignore Modify some file operations; 2021-04-07 09:47:29 +08:00
LICENSE add license 2020-11-18 19:20:55 +09:00
Makefile Rename kalloc.c/h to pm.c/h; 2021-04-25 13:22:09 +08:00
README add user 2020-11-01 00:15:28 +09:00
README.md Update README. 2021-04-16 20:26:44 +08:00
README_cn.md Update README. 2021-04-16 20:26:44 +08:00

README.md

XV6-RISCV On K210

Run xv6-riscv on k210 board
English | 中文

 (`-')           (`-')                   <-.(`-')                            
 (OO )_.->      _(OO )                    __( OO)                            
 (_| \_)--.,--.(_/,-.\  ,--.    (`-')    '-'. ,--.  .----.   .--.   .----.   
 \  `.'  / \   \ / (_/ /  .'    ( OO).-> |  .'   / \_,-.  | /_  |  /  ..  \  
  \    .')  \   /   / .  / -.  (,------. |      /)    .' .'  |  | |  /  \  . 
  .'    \  _ \     /_)'  .-. \  `------' |  .   '   .'  /_   |  | '  \  /  ' 
 /  .'.  \ \-'\   /   \  `-' /           |  |\   \ |      |  |  |  \  `'  /  
`--'   '--'    `-'     `----'            `--' '--' `------'  `--'   `---''   

run-k210

Dependencies

Installation

git clone https://github.com/HUST-OS/xv6-k210

Build

First you need to connect your k210 board to your PC.
And check the USB serial port:

ls /dev/ | grep USB

In my situation it will be ttyUSB0

cd xv6-k210
make build

Run on k210 board

Instead of the original file system, xv6-k210 runs with FAT32. You might need an SD card with FAT32 format.
To start shell, you need to rename the "_init" and "_sh" in the "/xv6-user" to "init" and "sh" after building, then copy them to the root of your SD card.
Also, you can copy other programs start with "_". Or you can directly run the command as below with your SD card connected to your PC (SD card reader required).

Warning: this will format your SD card and clean your original data!

make sdcard sd="your SD card device's path"

To run on k210:

make run

Sometimes you should change the USB serial port:

make run k210-serialport=`Your-USB-port`(default by ttyUSB0)

Ps: Most of the k210-port in Linux is ttyUSB0, if you use Windows or Mac OS, this doc may help you: maixpy-doc

Run on qemu-system-riscv64

First, make sure qemu-system-riscv64 is installed on your system.
Second, make a disk image file with FAT32 file system.

make fs

It will generate a disk image file fs.img, and compile some user programs like shell then copy them into the fs.img.
As long as the fs.img exists, you don't need to do this every time before running, unless you want to update it.

Finally, start running.

make run platform=qemu

Ps: Press Ctrl + A then X to quit qemu.

About shell

The shell commands are user programs, too. Those program should be put in a "/bin" directory in your SD card or the fs.img.
Now we support a few useful commands, such as cd, ls, cat and so on.

In addition, shell supports some shortcut keys as below:

  • Ctrl-H -- backspace
  • Ctrl-U -- kill a line
  • Ctrl-D -- end of file (EOF)
  • Ctrl-P -- print process list

Add my programs on xv6-k210

  1. Make a new C source file in xv6-user/ like myprog.c, and put your codes;
  2. You can include user.h to use the functions declared in it, such as open, gets and printf;
  3. Add a line "$U/_myprog\" in Makefile as below:
    UPROGS=\
        $U/_init\
        $U/_sh\
        $U/_cat\
        ...
        $U/_myprog\      # Don't ignore the leading '_'
    
  4. Then make:
    make userprogs
    
    Now you might see _myprog in xv6-user/ if no error detected. Finally you need to copy it into your SD (see here) or FS image (see here).

Progress

  • Multicore boot
  • Bare-metal printf
  • Memory alloc
  • Page Table
  • Timer interrupt
  • S mode extern interrupt
  • Receive uarths message
  • SD card driver
  • Process management
  • File system
  • User program
  • Steady keyboard input(k210)

TODO

Fix the bugs of U-mode exception caught by RUSTSBI.