forked from rv2036/rvspoc-p2308-xv6-riscv
-
Notifications
You must be signed in to change notification settings - Fork 1
Xv6 for RISC-V
License
xhackerustc/rvspoc-p2308-xv6-riscv
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
# xv6 ports to real riscv platforms port xv6 to Sophgo CV1800B platforms such as Milkv Duo, Sophgo SG00X platforms such as Milkv-duo256, milkv Duo-S and T-HEAD TH1520 platforms such as Sipeed Lichee Pi 4A. While Milkv Duo holds the highest priority porting effort. Currently, peripherals such as uart, gpio, adc, pwm, i2c and spi are well supported for milkv duo. Qemu and TH1520 only support uart. I also wrote some userspace tools to demo the peripherals usage. Check below. ## Build for milkv duo: ./build_for_milkv_duo.sh the built img will be duo-imgtools/milkv-duo_sdcard.img, then burn it to tf card on PC: dd if=milkv-duo_sdcard.img of=/dev/sdX (take care "sdX" must be the tfcard appeared on your PC, you have been warned!) *gpio demo: $ ./blink 5 //will link 5 loops *adc demo: ADC1 is used. Connect GP26 to GND $ ./adc $ adc raw: 0 then connect GP26 to 3v3(out). $ ./adc $ adc raw: 4095 *pwm demo: PWM6 is used for demo. Connect a Light Emitting Diode(don't forget proper resistance, I use a 100 ohm) to GP5, another peer connects to GND. $ ./pwm 1000000 900000 $ ./pwm 1000000 800000 $ ./pwm 1000000 600000 $ ./pwm 1000000 500000 $ ./pwm 1000000 300000 $ ./pwm 1000000 200000 $ ./pwm 1000000 100000 and so on. The Diode light changes each time you modify the duty cycles... *i2c demo: I2C0 is used for demo. I used max30102 sensor for demo. If you use different I2C device, check the device manual for read and write details. Connect GP0 to its SCL pin and GP1 to its SDA pin, don't forget GND and VCC(connect to 3V3(out) $ ./i2c 0x57 0xff $ 0x15 $ ./i2c 0x57 0x21 1 $ ./i2c 0x57 0x1f 0xF $ ./i2c 0x57 0x20 0x3 The integer temperature is 15, frac temperature is 0x3, so the tempearture is about 15.19 centigrade. (plz check max30102 TRM for details) *spi demo: SPI2 is used for demo. I will demo external spi loop back test, this is simliar as the spidev_test under linux. The demo will print the received contents. $ ./spi $ 0 0 0 0 0 0 0 0 ... Then connect GP7 and GP8 $ ./spi $ 1 2 3 4 5 6 7 8 ... ## Build for qemu: git checkout kernel/config.h make make kernel/kernel.bin ## Build for TH1520: cp kernel/config.h.th1520 kernel/config.h make make kernel/kernel.bin Build for SG200X: Just replace the fip.bin then build as milkv duo ;) xv6 is a re-implementation of Dennis Ritchie's and Ken Thompson's Unix Version 6 (v6). xv6 loosely follows the structure and style of v6, but is implemented for a modern RISC-V multiprocessor using ANSI C. ACKNOWLEDGMENTS xv6 is inspired by John Lions's Commentary on UNIX 6th Edition (Peer to Peer Communications; ISBN: 1-57398-013-7; 1st edition (June 14, 2000)). See also https://pdos.csail.mit.edu/6.1810/, which provides pointers to on-line resources for v6. The following people have made contributions: Russ Cox (context switching, locking), Cliff Frey (MP), Xiao Yu (MP), Nickolai Zeldovich, and Austin Clements. We are also grateful for the bug reports and patches contributed by Takahiro Aoyagi, Silas Boyd-Wickizer, Anton Burtsev, carlclone, Ian Chen, Dan Cross, Cody Cutler, Mike CAT, Tej Chajed, Asami Doi, eyalz800, Nelson Elhage, Saar Ettinger, Alice Ferrazzi, Nathaniel Filardo, flespark, Peter Froehlich, Yakir Goaron, Shivam Handa, Matt Harvey, Bryan Henry, jaichenhengjie, Jim Huang, Matúš Jókay, John Jolly, Alexander Kapshuk, Anders Kaseorg, kehao95, Wolfgang Keller, Jungwoo Kim, Jonathan Kimmitt, Eddie Kohler, Vadim Kolontsov, Austin Liew, l0stman, Pavan Maddamsetti, Imbar Marinescu, Yandong Mao, Matan Shabtay, Hitoshi Mitake, Carmi Merimovich, Mark Morrissey, mtasm, Joel Nider, Hayato Ohhashi, OptimisticSide, Harry Porter, Greg Price, Jude Rich, segfault, Ayan Shafqat, Eldar Sehayek, Yongming Shen, Fumiya Shigemitsu, Cam Tenny, tyfkda, Warren Toomey, Stephen Tu, Rafael Ubal, Amane Uehara, Pablo Ventura, Xi Wang, WaheedHafez, Keiichi Watanabe, Nicolas Wolovick, wxdao, Grant Wu, Jindong Zhang, Icenowy Zheng, ZhUyU1997, and Zou Chang Wei. The code in the files that constitute xv6 is Copyright 2006-2022 Frans Kaashoek, Robert Morris, and Russ Cox. ERROR REPORTS Please send errors and suggestions to Frans Kaashoek and Robert Morris (kaashoek,rtm@mit.edu). The main purpose of xv6 is as a teaching operating system for MIT's 6.1810, so we are more interested in simplifications and clarifications than new features. BUILDING AND RUNNING XV6 You will need a RISC-V "newlib" tool chain from https://github.com/riscv/riscv-gnu-toolchain, and qemu compiled for riscv64-softmmu. Once they are installed, and in your shell search path, you can run "make qemu".
About
Xv6 for RISC-V
Resources
License
Stars
Watchers
Forks
Releases
No releases published
Packages 0
No packages published
Languages
- C 94.4%
- Assembly 3.3%
- Makefile 1.7%
- Other 0.6%