Skip to content

Commit fa14a3f

Browse files
committed
[docs,qemu] Move QEMU setup documentation
To allow for more general OpenTitan QEMU documentation, move the current setup / build system documentation to its own separate `setup.md` page. Make a new general QEMU `README.md` containing documentation not specific to setup / using a local build override. Signed-off-by: Alex Jones <[email protected]>
1 parent e4a102c commit fa14a3f

File tree

3 files changed

+61
-57
lines changed

3 files changed

+61
-57
lines changed

SUMMARY.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,13 @@
1212
- [Building (and Testing) Software](./doc/getting_started/build_sw.md)
1313
- [Building Documentation](./doc/getting_started/build_docs.md)
1414
- [Using OpenOCD](./doc/getting_started/using_openocd.md)
15+
- [Using QEMU](./third_party/qemu/README.md)
1516

1617
- [Tools Setup](./doc/getting_started/tools-setup.md)
1718
- [FPGA Setup](./doc/getting_started/setup_fpga.md)
1819
- [Verilator Setup](./doc/getting_started/setup_verilator.md)
1920
- [Installing Vivado](./doc/getting_started/install_vivado/README.md)
20-
- [QEMU setup](./third_party/qemu/README.md)
21+
- [QEMU setup](./third_party/qemu/setup.md)
2122

2223
- [Unofficial Guides](./doc/getting_started/unofficial/README.md)
2324
- [RedHat/Fedora](./doc/getting_started/unofficial/fedora.md)

third_party/qemu/README.md

Lines changed: 1 addition & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,6 @@
11
# QEMU
22

3-
By default, the build system will download a pre-built release of our [QEMU fork](https://github.com/lowRISC/qemu/).
4-
In order to support local development and testing, the build system also supports a way to build QEMU from source.
5-
See instructions below.
6-
7-
## Building from source using Bazel
8-
9-
To perform local development, you first need to check out a copy of [QEMU fork](https://github.com/lowRISC/qemu/) and switch to the correct branch.
10-
11-
The following step must only be done once:
12-
```bash
13-
# Run the following commands at the root of your QEMU checkout.
14-
touch REPO.bazel
15-
ln -s "/path/to/your/opentitan/repo/third_party/qemu/BUILD.qemu_opentitan.bazel" "BUILD.bazel"
16-
```
17-
18-
Once done, every time you compile something using QEMU in OpenTitan, you need to tell Bazel to use your QEMU repository instead of downloading a release archive.
19-
This is done by passing the following command-line argument to bazel:
20-
```
21-
--override_repository="+qemu+qemu_opentitan_src=/path/to/your/qemu/repo/"
22-
```
23-
For example:
24-
```bash
25-
./bazelisk.sh cquery --override_repository=... @qemu_opentitan//:build/qemu-system-riscv32
26-
```
27-
Since this can become quite tedious, you also have the option of adding this to your local bazelrc file. The recommended way of doing is to create a `.bazelrc-site` file at the root of the repo (if does not exists) and add:
28-
```
29-
common --override_repository=...
30-
```
31-
32-
**Important note:** when using this override, Bazel will essentially share your QEMU source repository.
33-
In particular, the content of the `build/` directory will be used to support incremental compilation in Bazel.
34-
The content of this directory can change when you run Bazel command.
35-
Bazel will automatically watch all files in the QEMU repository so that it can rebuild it if it changes.
3+
For instructions on setting up QEMU for local development and troubleshooting steps, see the [setup guide](./setup.md).
364

375
## Test parameters
386

@@ -67,26 +35,3 @@ opentitan_test(
6735
# ...
6836
)
6937
```
70-
71-
## Troubleshooting
72-
73-
### Bazel tells me that `+qemu+qemu_opentitan_src` is not a valid repository name
74-
75-
Unfortunately bazel requires the canonical name of the repository to be given on the command line and this name may change in the future.
76-
If this happens, you can run the following commands to figure out the canonical name:
77-
```bash
78-
./bazelisk.sh mod dump_repo_mapping "" | jq .qemu_opentitan_src
79-
```
80-
If the opentitan repository is not the root repository,
81-
you will need to update the above command to pass the canonical name of the opentitan repository
82-
instead of `""`.
83-
84-
### How does it work?
85-
86-
When passing `--override_repository="+qemu+qemu_opentitan_src=/path/to/your/qemu/repo/"`, the `qemu_bazel_build_or_forward` repository rules
87-
detect the override by looking for a specific marker file which is added to the release archive.
88-
If an override is detected, the repository rule will run the `build_qemu.sh` script inside the user's QEMU source directory.
89-
This script configures QEMU if necessary and then builds everything using ninja.
90-
Finally, it uses the OpenTitan release script to create a fake release archive.
91-
The repository rule then extracts this archive into the repository so that the content looks identical to normal, downloaded release.
92-
Finally, the repository rule also asks Bazel to watch all the files in the QEMU source directory, except for the `build/` directory.

third_party/qemu/setup.md

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
# Setting up OpenTitan for local QEMU development
2+
3+
By default, the build system will download a pre-built release of our [QEMU fork](https://github.com/lowRISC/qemu/).
4+
In order to support local development and testing, the build system also supports a way to build QEMU from source.
5+
See instructions below.
6+
7+
## Building from source using Bazel
8+
9+
To perform local development, you first need to check out a copy of [QEMU fork](https://github.com/lowRISC/qemu/) and switch to the correct branch.
10+
11+
The following step must only be done once:
12+
```bash
13+
# Run the following commands at the root of your QEMU checkout.
14+
touch REPO.bazel
15+
ln -s "/path/to/your/opentitan/repo/third_party/qemu/BUILD.qemu_opentitan.bazel" "BUILD.bazel"
16+
```
17+
18+
Once done, every time you compile something using QEMU in OpenTitan, you need to tell Bazel to use your QEMU repository instead of downloading a release archive.
19+
This is done by passing the following command-line argument to bazel:
20+
```
21+
--override_repository="+qemu+qemu_opentitan_src=/path/to/your/qemu/repo/"
22+
```
23+
For example:
24+
```bash
25+
./bazelisk.sh cquery --override_repository=... @qemu_opentitan//:build/qemu-system-riscv32
26+
```
27+
Since this can become quite tedious, you also have the option of adding this to your local bazelrc file. The recommended way of doing is to create a `.bazelrc-site` file at the root of the repo (if does not exists) and add:
28+
```
29+
common --override_repository=...
30+
```
31+
32+
**Important note:** when using this override, Bazel will essentially share your QEMU source repository.
33+
In particular, the content of the `build/` directory will be used to support incremental compilation in Bazel.
34+
The content of this directory can change when you run Bazel command.
35+
Bazel will automatically watch all files in the QEMU repository so that it can rebuild it if it changes.
36+
37+
## Troubleshooting
38+
39+
### Bazel tells me that `+qemu+qemu_opentitan_src` is not a valid repository name
40+
41+
Unfortunately bazel requires the canonical name of the repository to be given on the command line and this name may change in the future.
42+
If this happens, you can run the following commands to figure out the canonical name:
43+
```bash
44+
./bazelisk.sh mod dump_repo_mapping "" | jq .qemu_opentitan_src
45+
```
46+
If the opentitan repository is not the root repository,
47+
you will need to update the above command to pass the canonical name of the opentitan repository
48+
instead of `""`.
49+
50+
### How does it work?
51+
52+
When passing `--override_repository="+qemu+qemu_opentitan_src=/path/to/your/qemu/repo/"`, the `qemu_bazel_build_or_forward` repository rules
53+
detect the override by looking for a specific marker file which is added to the release archive.
54+
If an override is detected, the repository rule will run the `build_qemu.sh` script inside the user's QEMU source directory.
55+
This script configures QEMU if necessary and then builds everything using ninja.
56+
Finally, it uses the OpenTitan release script to create a fake release archive.
57+
The repository rule then extracts this archive into the repository so that the content looks identical to normal, downloaded release.
58+
Finally, the repository rule also asks Bazel to watch all the files in the QEMU source directory, except for the `build/` directory.

0 commit comments

Comments
 (0)