-
Notifications
You must be signed in to change notification settings - Fork 49
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
resources: Add doc for riscv-fs-busybox-opensbi-nodisk resource #61
base: stable
Are you sure you want to change the base?
resources: Add doc for riscv-fs-busybox-opensbi-nodisk resource #61
Conversation
Inspired by riscv-fs-nodisk however, replacing legacy Berkeley bootloader (bbl) with OpenSBI FW_PAYLOAD bootloader, additionally just using default Linux and Busybox configurations instead of not up-to-date UCanLinux configs.
@powerjg or @BobbyRBruce i would like to add you as reviewers, but i am not sure, if i am authorized. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
First, thanks for the contribution! I think this information is great to get out to the broader community.
However, I'm not sure the appropriate place is gem5-resources. This repo is for the sources to build resources that are available on resources.gem5.org. Are you proposing that we (the gem5 community) distribute this kernel/bootloader/filesystem? If so, who are the users of this?
Maybe a better place for this document would be the gem5 blog: https://www.gem5.org/blog/
I'm open to a conversation, though :)
One last thing, if you could run a markdown linter, it would improve the formatting. E.g., https://github.com/markdownlint/markdownlint or https://marketplace.visualstudio.com/items?itemName=DavidAnson.vscode-markdownlint if you're using vscode.
[GNU toolchain for RISC-V](https://github.com/riscv-collab/riscv-gnu-toolchain). | ||
|
||
This step is necessary if you do not have basic libraries built for RISCV or | ||
if you're cross-compiling RISCV. | ||
|
||
```sh | ||
cd riscv-all-in-one/ | ||
git clone https://github.com/riscv-collab/riscv-gnu-toolchain.git | ||
cd riscv-gnu-toolchain | ||
git switch --detach 20f615317e2ce888dfc11b29ccde4a649494b654 # for reproducability, newer versions should work either | ||
mkdir build | ||
cd build | ||
# --prefix parameter specifying the installation location | ||
# --enable-multilib build either cross-compiler with support for both 32-bit and 64-bit | ||
../configure --prefix=/path/to/rvtoolchain --enable-multilib | ||
make linux -j$(nproc) | ||
``` | ||
To update the PATH environment variable so that the RISCV compilers can be | ||
found, | ||
```sh | ||
export PATH=/path/to/rvtoolchain/bin/:$PATH | ||
``` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we have to compile the toolchain? If there's a good reason not to use the precompiled toolchain from Ubuntu, then this step is OK, but if it's possible to use the precompiled toolchain, then we should do that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It might be helpful if you modify the toolchain itself, however in the default case for this resource the shipped toolchain is faily enough, so i changed it to use Debian's g++-12-riscv64-linux-gnu
package. See lines 43-74.
git clone --branch 1_36_stable https://git.busybox.net/busybox.git # choose a stable branch | ||
|
||
# alternatively downloading tar | ||
wget https://git.busybox.net/busybox/snapshot/busybox-1_36_1.tar.bz2 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I assume we do have to compile busybox (unlike gcc above). But can you confirm this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, Busybox is not distributing for the required RISCV platform (see their download page). Also i configure it to use no shared libraries in order to simplify the guide.
make ARCH=riscv CROSS_COMPILE=riscv64-unknown-linux-gnu- defconfig | ||
make ARCH=riscv CROSS_COMPILE=riscv64-unknown-linux-gnu- menuconfig |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
riscv64-unknown-linux-gnu-
? Above you used riscv64-linux-gnu-
.
We should use just one cross compiler, and, unless there's a really good reason, it should be a precompiled toolchain, not one that we compile ourselves.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the initial commit the lines that referred to riscv64-linux-gnu-
just mentioned an alternative usage if the toolchain was not prefixed by the default riscv64-unknown-linux-gnu-
. Sorry for the confusion.
As i use the Debian shipped compilers now, i have to specify the toolchain prefix for scons
anyways. See line 109.
You can run the created bootloader with Linux and Busybox payload using the example riscv `fs_linux.py` config, | ||
```sh | ||
cd gem5 | ||
./build/RISCV/gem5.opt configs/example/riscv/fs_linux.py --kernel="../gem5-resources/src/riscv-fs/riscv-all-in-one/opensbi/build/platform/generic/firmware/fw_payload.elf" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would prefer all examples to use the stdlib. If you could describe how to turn this into a Workload
it would improve the description.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the hard part for me. As far as i see, only specifying a bootloader without kernel and disk image is not intended by the boards, e.g. RiscvBoard or RISCVMatchedBoard.
Therefore i just show how to slightly modify the riscv-fs.py
by obtaining the new kernel
or bootloader
resource and leaving the disk_image
(and kernel
) parameter of the set_kernel_disk_workload
call unmodified (as dummy resource). See lines 266-282
In the end it might look like
# Set the Full System workload.
board.set_kernel_disk_workload(
kernel=obtain_resource(
"riscv-bootloader-vmlinux-5.10", resource_version="1.0.0"
), # dummy resource
disk_image=obtain_resource("riscv-disk-img", resource_version="1.0.0"), # dummy resource
bootloader=obtain_resource(
"riscv-fs-busybox-opensbi-nodisk", resource_version="1.0.0"
),
)
following suggestion of review on PR gem5#61 to use the more convinient precompiled toolchain. self-compiled is useful for modified toolchain, but not required for reproducibility of the standard resource though
improvements for PR gem5#61 - fix markdown formatting (blank lines, links, etc.) - clarify comment alternative initramfs.cpio archive generation
- change permalink and add a tag to highlight nodisk charakter - reorder tags to align with other resource READMEs - describe how to use the resource within the gem5 stdlib framework as a bootloader or kernel passed to set_kernel_disk_workload() - add licensing notes for OpenSBI, Linux and Busybox
Thank you very much for the thorough review and the hints for improvement! I should have incorporated your suggestions somehow (see comments on your comments :).
Regarding the appropriate place. So why to distribute via gem5-resources? -- It might be a good starting point for people to check whether this type of "nodisk resource" already fits their needs. |
- move m5 exit to beginning of script and extract shell setup into extra script for better readability - swap setsid,hotplug lines (script doesn't proceed after setsid line) - fix version in busybox docs link
Inspired by riscv-fs-nodisk however, replacing legacy Berkeley bootloader (bbl) with OpenSBI FW_PAYLOAD bootloader, additionally just using default Linux and Busybox configurations instead of not up-to-date UCanLinux configs.
I was missing an up-to-date guide for fully self-build simple linux environment for Gem5 RISC-V full system simulations.
Therefore i compiled this guide from other guide here and online together.
The use case could be playing around with custom RISC-V instructions and custom toolchain.
Btw: i tried to use pre-commit, but i got the error
No .pre-commit-config.yaml file was found
on commit.