forked from mit-pdos/xv6-riscv
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprep_env.sh
More file actions
executable file
·52 lines (37 loc) · 1.69 KB
/
prep_env.sh
File metadata and controls
executable file
·52 lines (37 loc) · 1.69 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#!/bin/bash
# works for ubuntu2204
# clone with sub module and not clone git history,only clone for build riscv-gnu-toolchain
git clone --depth 1 https://github.com/riscv/riscv-gnu-toolchain
cd riscv-gnu-toolchain
git submodule init
git submodule update --depth 1
# --depth 1 option only the latest commit in the history.
cd ./riscv-gnu-toolchain
sudo apt-get install autoconf automake autotools-dev curl python3 python3-pip libmpc-dev libmpfr-dev libgmp-dev gawk build-essential bison flex texinfo gperf libtool patchutils bc zlib1g-dev libexpat-dev ninja-build git cmake libglib2.0-dev -y
# gcc-riscv64-linux-gnu → 生成 riscv64 Linux ELF 可执行程序
# binutils-riscv64-linux-gnu → ld, as, objcopy, nm 等工具,适配 Linux ABI
# gdb-multiarch → 支持多架构调试,包括 riscv32/64 Linux 程序
# qemu-system-misc → 可模拟完整 RISC-V 64 系统(包括 Linux)
# git, build-essential → 用于源码编译,和 RISC-V 特定无关
# 支持 riscv64 Linux ABI,可以编译完整 Linux 用户空间程序
# 不适合裸机程序(裸机程序可能需要 -mno-relax 等特殊选项)
sudo mkdir -p /opt/riscv/bin
sudo chmod 777 /opt/riscv/bin
echo 'export PATH=$PATH:/opt/riscv/bin' >>~/.bashrc
source ~/.bashrc
# above not good.
# do this: will let make qemu work.
sudo apt-get install git build-essential gdb-multiarch qemu-system-misc gcc-riscv64-linux-gnu binutils-riscv64-linux-gnu -y
# quit qemu:
If you are running with nographic options below option worked for me
step 1:
Cntrl + a
Step 2
press c
Step 3
write quit
#
这个也行:
```
sudo apt install binutils-riscv64-linux-gnu gcc-riscv64-linux-gnu gdb-multiarch qemu-system-misc opensbi u-boot-qemu qemu-utils -y
```