心之所向,素履以往

Run XV6 on MacOS (ARM64)

2024-12-26

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

Install Homebrew

Install Packages

Building the OS

Run following commands:

The output should looks like this:

1
2
3
4
hart 2 starting
hart 1 starting
init: starting sh
$

Try run ls and you’ll get:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
$ ls
. 1 1 1024
.. 1 1 1024
README 2 2 2292
cat 2 3 35544
echo 2 4 34368
forktest 2 5 16376
grep 2 6 39000
init 2 7 34840
kill 2 8 34312
ln 2 9 34112
ls 2 10 37640
mkdir 2 11 34368
rm 2 12 34352
sh 2 13 57144
stressfs 2 14 35232
usertests 2 15 181728
grind 2 16 50616
wc 2 17 36448
zombie 2 18 33712
console 3 19 0
file.txt 2 20 0
$

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!

References

[1] XV6 booting on macOS.
[2] How I Set Up Xv6 On macOS