This is a simple note on running xv6 teaching OS on ARM64 arch Macintosh, which’s a combination of several tutorials I searched online:)
预准备
THE MOST IMPORTANT
请确保你已连接国际互联网,并有能力阅读英文资料,且愿意为自己的行为负责,否则请勿继续阅读,以避免不必要的损失!!!
Install Intergrated Tools
- Feel free to paste the following magic words to the Terminal and hit ⏎:
1
xcode-select --install
Install Homebrew
- Next, running the following code to install the package manager :
1
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
- Check if Homebrew is ready:
brew doctor
If it’s not, STFW to solve the problem and head back here @anytime.
Install Packages
All you have to do is running the following prompts one by one, and it SHOULD works fine. At least my machine works fine:)
If your computer has some mysterious problems, I’m afraid you’ll have to work on your own:(1
2
3
4
5
6
7brew install python3 gawk gnu-sed gmp mpfr libmpc isl zlib expat texinfo flock libslirp qemu
brew tap riscv-software-src/riscv
brew install riscv-tools riscv64-elf-gdb
git clone https://github.com/mit-pdos/xv6-riscv.git
cd xv6-riscv
export PATH="/opt/homebrew/opt/riscv-gnu-toolchain/bin:$PATH"
source ~/.zshrcYou have to downgrade gcc for xv6 to run,
1
2
3
4
5brew unlink i386-elf-binutils
brew unlink gcc
brew link --overwrite riscv-gnu-toolchain
brew link --overwrite riscv-gnu-toolchain --dry-run
riscv64-unknown-elf-gcc --version
Building the OS
Run following commands:
make clean
make
make qemu
The output should looks like this:
1 | hart 2 starting |
Try run ls
and you’ll get:
1 | $ ls |
To exit from QEMU kernel, press control⌃+A and then press X.
You will be encountered with error if you don’t downgrade gcc. Once downgraded, your codes won’t run on Code Editors. So after successful booting of xv6, you can run the command brew link gcc
to get back to correct lane!