Skip to content

Commit fc8fbaa

Browse files
authored
Merge pull request #24 from enkerewpo/main
update loongson 3a5000 quickstart guide
2 parents 7218616 + 2e1e0b1 commit fc8fbaa

File tree

2 files changed

+32
-5
lines changed

2 files changed

+32
-5
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
book
2+
.DS_Store

src/chap02/Loongson-3A5000.md

Lines changed: 31 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,28 +2,37 @@
22

33
韩喻泷 <[email protected]>
44

5-
更新时间:2024.11.6
5+
更新时间:2024.12.4
66

77
## 第一步:获取hvisor源码并编译
88

99
克隆代码到本地:
1010

1111
```bash
1212
git clone -b dev-loongarch https://github.com/syswonder/hvisor # dev-loongarch分支
13-
make ARCH=loongarch64 -j$(nproc)
13+
make ARCH=loongarch64
1414
```
1515
编译完成后在target目录下可以找到strip之后的hvisor.bin(编译输出的最后一行会显示文件路径)。
1616

1717
## 获取vmlinux.bin镜像
1818

19-
请从<https://github.com/enkerewpo/linux-hvisor-loongarch64/releases>下载最新发布的hvisor默认龙芯linux镜像(包括root linux kernel+root linux dtb+root linux rootfs,其中root linux rootfs中包括non root linux+nonroot linux dtb+nonroot linux rootfs)。如果你需要自行编译linux kernel以及rootfs,可参考该仓库的arch/loongarch目录中hvisor相关设备树以及其他相关代码。
19+
请从<https://github.com/enkerewpo/linux-hvisor-loongarch64/releases>下载最新发布的hvisor默认龙芯linux镜像(包括root linux kernel+root linux dtb+root linux rootfs,其中root linux rootfs中包括non root linux+nonroot linux dtb+nonroot linux rootfs)。如果你需要自行编译linux kernel以及rootfs,可参考该仓库的`arch/loongarch`目录中hvisor相关设备树以及我为3A5000移植的buildroot环境(<https://github.com/enkerewpo/buildroot-loongarch64>)。如果你需要手动编译hvisor-tool,请参考<https://github.com/enkerewpo/hvisor-tool>,关于所有环境的编译顺序和脚本调用流程请参考`Makefile.1`文件中`world`目标内的代码(<https://github.com/enkerewpo/hvisor_uefi_packer/blob/main/Makefile.1>),并通过运行`./make_world`脚本编译所有东西,如果你需要手动编译这些,则需要在Makefile.1内修改对应的代码路径变量,包括:
20+
21+
```
22+
HVISOR_LA64_LINUX_DIR = ../hvisor-la64-linux
23+
BUILDROOT_DIR = ../buildroot-loongarch64
24+
HVISOR_TOOL_DIR = ../hvisor-tool
25+
```
26+
27+
然后运行 `./make_world`,请注意,第一次编译linux和buildroot的时间可能相当长(可能长达几十分钟,取决于你的机器性能)。
2028

2129
## 获取hvisor UEFI Image Packer
2230

23-
由于3A5000采用UEFI启动,所以只能通过efi镜像的方法启动hvisor,克隆仓库<https://github.com/enkerewpo/hvisor_uefi_packer>到本地:
31+
由于3A5000以及之后的3系CPU的主板均采用UEFI启动,所以只能通过efi镜像的方法启动hvisor,克隆仓库<https://github.com/enkerewpo/hvisor_uefi_packer>到本地:
2432

2533
```bash
2634
make menuconfig # 配置为你本地的loongarch64 gcc工具链前缀、hvisor.bin路径、vmlinux.bin路径
35+
# 修改make_image中的HVISOR_SRC_DIR=../hvisor为你实际保存hvisor源码的路径,之后再运行脚本
2736
./make_image
2837
# 得到 BOOTLOONGARCH64.EFI 文件
2938
```
@@ -34,4 +43,21 @@ make menuconfig # 配置为你本地的loongarch64 gcc工具链前缀、hvisor.b
3443

3544
## 上板启动
3645

37-
主板上电开机,按 **F12** 进入UEFI Boot Menu,选择你插入的U盘后回车,会自动启动hvisor。
46+
主板上电开机,按 **F12** 进入UEFI Boot Menu,选择你插入的U盘后回车,会自动启动hvisor,并进入root linux的bash环境。
47+
48+
## 启动nonroot
49+
50+
如果你使用的是release中提供的相关镜像,启动后在root linux的bash内输入:
51+
52+
```bash
53+
./daemon.sh
54+
./linux2_virtio.sh
55+
```
56+
57+
之后会自动启动nonroot(一些相关配置文件位于root linux的`/tool`目录内,包括提供给hvisor-tool的nonroot zone配置json以及virtio配置json文件),之后回自动打开一个screen进程连接nonroot linux的virtio-console,你会看到一个打印了nonroot字样的bash出现,你可以在使用screen时按CTRL+A D快捷键detach(请记住显示的screen session名称),此时会返回root linux,如果希望返回nonroot linux,则运行
58+
59+
```bash
60+
screen -r {刚才的session全名 或者 只输入最前面的数字}
61+
```
62+
63+
之后会返回nonroot linux的bash。

0 commit comments

Comments
 (0)