当前位置:网站首页>MIT 6. S081/fall 2020 build risc-v and xv6 development and debugging environment
MIT 6. S081/fall 2020 build risc-v and xv6 development and debugging environment
2022-06-23 03:06:00 【bright】
2022-01-19 Daily update
- Many people use M1 There are errors in schema compilation Then I also repeated the mistake and found a solution
- The different installation procedures are described in more detail
This article mainly records the learning MIT6.S081 The detailed process of course deployment experiment environment .
Course link :https://pdos.csail.mit.edu/6.S081/2020/
My environment :
Computer model :MacBook Pro (14-inch, 2021)
System version :macOS Monterey 12.1
My notebook is arm64(M1 chip ) Architecturally , But this article applies to M1 And Intel.
Premise ( Must install ):
By default, you need to install brew This tool is needed in many places later
# install Brew If it is already installed, you can go to the next step /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" # Check if the installation is successful brew -v # Printing the following represents success Homebrew 3.3.11-21-gec389a6 Homebrew/homebrew-core (git revision 68defcb5dd3; last commit 2022-01-18) Homebrew/homebrew-cask (git revision c6cfd6f92b; last commit 2022-01-18) # The installation is basically dependent on the environment brew install python3 gawk gnu-sed gmp mpfr libmpc isl zlib expat gsed brew tap discoteq/discoteq brew install flock # Qemu Need to rely on ninja brew install ninja
About GCC / LLVM + CLANG( Optional )
Mac By default, the pre installed environment is LLVM+CLANG instead of GCC Although there are GCC The order of But it's actually CLANG
Test the following perform gcc -v:
gcc -v Configured with: --prefix=/Library/Developer/CommandLineTools/usr --with-gxx-include-dir=/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/4.2.1 Apple clang version 13.0.0 (clang-1300.0.29.30) Target: arm64-apple-darwin21.2.0 Thread model: posix InstalledDir: /Library/Developer/CommandLineTools/usr/bin
Compiling riscv-gnu-toolchain Tool chain , This machine is GCC still LLVM+CLANG Will not affect , I can compile successfully in my personal test , So this place can keep the default , If you need to install GCC To replace LLVM + CLANG You can follow the steps below :
# install
brew install gcc
# Version is gcc 11.2.0_3
# Set the environment variable :
# Add the following to ~/.zshrc perhaps ~/.bash_profile perhaps /etc/profile
# Because I use zsh So configure it to ~/.zshrc in
vim ~/.zshrc
# Add the following
export GCCPATH=/opt/homebrew/Cellar/gcc/11.2.0_3/
export PATH=$PATH:${GCCPATH//://bin:}/bin
alias gcc='gcc-11'
alias cc='gcc-11'
alias g++='g++-11'
alias c++='c++-11'
# Make the environment work
source ~/.zshrc
# test
gcc -v
Using built-in specs.
COLLECT_GCC=gcc-11
COLLECT_LTO_WRAPPER=/opt/homebrew/Cellar/gcc/11.2.0_3/bin/../libexec/gcc/aarch64-apple-darwin21/11/lto-wrapper
Target: aarch64-apple-darwin21
.... Omit
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 11.2.0 (Homebrew GCC 11.2.0_3)install riscv-gnu-toolchain
Select one of the following installations How happy you are, how you choose I use it 2. Source code compilation and installation
1. Use brew Installation ( Optional )
I used this step to install There will be some problems So it depends on luck here .
brew tap riscv-software-src/riscv brew install riscv-tools
2. Source code compilation and installation ( Optional )
Clone Source
git clone --recursive https://github.com/riscv/riscv-gnu-toolchain
The version I installed
riscv-gnu-toolchain commit: f640044a947afb39c78b96fa1ba1db8aa31b1d89 tag: 2022.01.17
qemu commit: 553032db17440f8de011390e5a1cfddd13751b0b tag: v5.2.0
riscv-binutils commit: 116a737f438d03a1bd6aa706b6ea0b4022f3b7e2(riscv-binutils-2.37)
riscv-dejagnu commit: 4ea498a8e1fafeb568530d84db1880066478c86b(riscv-dejagnu-1.6)
riscv-gcc commit: ca312387ab141060c20c388d83d6fc4b2099af1d(riscv-gcc-10.2.0)
riscv-gdb commit: 5da071ef0965b8054310d8dde9975037b0467311(fsf-gdb-10.1-with-sim)
riscv-glibc commit: 9826b03b747b841f5fc6de2054bf1ef3f5c4bdf3 tag: glibc-2.33
riscv-newlib commit: 415fdd4279b85eeec9d54775ce13c5c412451e08 tag: newlib-4.1.0
The source code is very large 6.5G about So cloning is slow You can clone the main warehouse first Separate clone sub warehouses
git clone https://github.com/riscv/riscv-gnu-toolchain cd riscv-gnu-toolchain git submodule update --init --recursive
Baidu cloud download my side upload good You can download and decompress directly
Address : Source package Extraction code :nmvw Package name : riscv-gnu-toolchain-src-2022-01-17.tar.gz
Compilation and installation
( important ) notes : If your Mac yes arm framework M1 Series of chips The configuration needs to be changed
Revised as follows :
# Entry directory
cd riscv-gnu-toolchain
# Unregister configuration
# Edit the file
vim riscv-gcc/gcc/config.host
# Cancellation 96 That's ok 97 That's ok
96 #out_host_hook_obj=host-darwin.o
97 #host_xmake_file="${host_xmake_file} x-darwin"compile Longer time consuming Take your time Visual inspection 1 Hour or so
cd riscv-gnu-toolchain ./configure --prefix=/opt/riscv-gnu-toolchain --with-cmodel=medany --enable-multilib # Because Ann arrived opt So... Is added to the directory sudo If not installed in this directory May not be used sudo sudo make
If the installation is successful The following is displayed :
Configure environment variables
# Add the following to ~/.zshrc perhaps ~/.bash_profile perhaps /etc/profile
# Because I use zsh So configure it to ~/.zshrc in
export RISCV_HOME=/opt/riscv-gnu-toolchain
export PATH=${PATH}:${RISCV_HOME}/bin
# use source command Let environment variables reload
source ~/.zshrc 3. Use the precompiled version directly ( Optional )
download :
x86_64(intel)
Address : Source package Extraction code :nmvw Package name : riscv-gnu-toolchain-bin-2020.04.01-x86_64-apple-darwin.tar.gz
aarm(m1)
Address : Source package Extraction code :nmvw Package name : riscv-gnu-toolchain-bin-2022.01.18-arm64-apple-darwin.tar.gz
decompression
tar xf { The package name you downloaded above } -C /opt/
ls /opt/riscv-gnu-toolchain
drwxr-xr-x 33 root wheel 1056 Jan 19 09:39 bin
drwxr-xr-x 3 root wheel 96 Jan 19 09:39 include
drwxr-xr-x 8 root wheel 256 Jan 19 09:39 lib
drwxr-xr-x 3 root wheel 96 Jan 18 23:54 libexec
drwxr-xr-x 5 root wheel 160 Jan 18 23:59 riscv64-unknown-elf
drwxr-xr-x 7 root wheel 224 Jan 19 09:39 shareConfigure environment variables
# Add the following to ~/.zshrc perhaps ~/.bash_profile perhaps /etc/profile
# Because I use zsh So configure it to ~/.zshrc in
export RISCV_HOME=/opt/riscv-gnu-toolchain
export PATH=${PATH}:${RISCV_HOME}/bin
# use source command Let environment variables reload
source ~/.zshrc 4. Verify that the installation was successful
// perform riscv64-unknown-elf-gcc -v // If the following contents are printed, the installation will be successful riscv64-unknown-elf-gcc -v Using built-in specs. COLLECT_GCC=riscv64-unknown-elf-gcc COLLECT_LTO_WRAPPER=/opt/riscv-gnu-toolchain/libexec/gcc/riscv64-unknown-elf/11.1.0/lto-wrapper Target: riscv64-unknown-elf Thread model: single Supported LTO compression algorithms: zlib gcc version 11.1.0 (GCC)
install Qemu
qemu Is a powerful virtual machine operating system simulator , In this course , We use qemu To simulate the hardware , send xv6 Running on the simulator .
I installed qemu Version is 6.2.0
** Select one of the following installations How happy you are, how you choose I use it 1. Use brew install
1. Use brew install ( Optional )
// I used this method to install brew install qemu
2. Use the source code to install ( Optional )
Download the source code and compile it
wget https://download.qemu.org/qemu-6.2.0.tar.xz tar xf qemu-6.2.0.tar.xz cd qemu-6.2.0 ./configure --prefix=/opt/qemu make make install
Configure environment variables
# Add the following to ~/.zshrc perhaps ~/.bash_profile perhaps /etc/profile
# Because I use zsh So configure it to ~/.zshrc in
export QEMU_HOME=/opt/qemu
export PATH=${PATH}:${QEMU_HOME}/bin
# use source command Let environment variables reload
source ~/.zshrc 3. Verify that the installation was successful
// perform If the following information is printed, the installation is successful qemu-system-riscv64 --version QEMU emulator version 6.1.0 Copyright (c) 2003-2021 Fabrice Bellard and the QEMU Project developers
Compile and run xv6
clone
git clone https://github.com/mit-pdos/xv6-riscv.git
compile
cd xv6-riscv make
Use qemu function
make qemu
The following display indicates successful operation
Use qemu-gdb Yes xv6 debug
need 2 A window ( terminal )
window 1
cd xv6-riscv make CPUS=1 qemu-gdb
It is shown as follows This means that the startup is successful qemu-gdb
window 2
cd xv6-riscv riscv64-unknown-elf-gdb
It is shown as follows This represents success
notes : xv6-riscv Directory is .gdbinit To configure In some cases riscv64-unknown-elf-gdb It will load automatically If it is not automatically loaded, you need to manually source .gdbinit When printing 0x0000000000001000 in ?? () Delegates can debug .
Reference material :
边栏推荐
- Transformation solution of digital intelligent supply chain platform for project management in engineering industry
- 2022-01-28: for example, {5, 3, 1, 4} all number pairs are: (5,3), (5,1)
- Micro build low code to realize user login and registration
- Construction and exploration of vivo database and storage platform
- Wwdc21 - App store server API practice summary
- The logical operators |, & &!
- Win11 client remote ECS black screen
- Initial xxE
- Line to line interviewer | one side of ByteDance
- How does the easyplayer streaming video player set up tiling?
猜你喜欢

Soft exam information system project manager_ Contract Law_ Copyright_ Implementation Regulations - Senior Information System Project Manager of soft exam 030

C language series - Section 4 - arrays

Vulnhub DC-5

5. concept of ruler method
What is sitelock? What is the function?

Soft exam information system project manager_ Information system comprehensive testing and management - Senior Information System Project Manager of soft test 027

8. greed

How to store, manage and view family photos in an orderly manner?

6. template for integer and real number dichotomy
随机推荐
CFs of cifs/smb protocol is mounted on win10/2019. Error 1272 is reported. The security policy prevents unauthenticated guest access
Learning about urldns chains
Quic implementation in rust --- Quinn
Using promise to process asynchronous operations
Concept and function of ES6 symbol
Use ES6 new Target to simulate abstract classes
How to use fortress on mobile devices
How to generate DataMatrix code in batch through TXT file
Operating wechat cache by using wechat low code
Precision loss problem
Summary of website navigation design and website link optimization
Delta oscillation in EEG
[data preparation and Feature Engineering] data cleaning
New uniapp+uniui background management uniuadmin
February 6, 2022: Arithmetic Sequence Division II - subsequence. Give you an integer array n
MySQL gets the top 1 and top n records after grouping
Network security memorabilia - Summary of vulnerability exploitation events in 2021
Exploration on the framework of stream batch integration technology and its practice in kangaroo cloud number stack
Qingdao stadium has made headlines again, but it has nothing to do with sports
Xiamen's hidden gaopuge smart park has finally been uncovered