This repository provides a cross-development environment for RISC-V using QEMU, OpenSBI, Linux, and Buildroot. The setup script automates the preparation of toolchains, QEMU, OpenSBI, Linux kernel, and Buildroot.
Ensure you have the following dependencies installed on your system:
- Git
- wget
- tar
- build-essential
- cmake
- ninja-build
- python3-venv
- cpio
- Rust (with nightly toolchain)
You can install these dependencies using the following command:
sudo apt-get update
sudo apt-get install -y git wget tar build-essential cmake ninja-build python3-venv cpioTo install Rust and the required nightly toolchain, use the following commands:
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
source $HOME/.cargo/env
rustup toolchain install nightly
rustup default nightlyTo set up the cross-development environment, run the run.sh script with the setup task:
./run.sh setupThis will perform the following steps:
- Install dependencies
- Prepare toolchains
- Prepare QEMU
- Prepare OpenSBI
- Prepare Linux kernel
- Prepare Buildroot
To run QEMU with the prepared images, use the run_qemu task:
./run.sh run_qemuTo connect to the running QEMU instance via SSH, use the run_ssh task:
./run.sh run_sshTo run GDB with the prepared environment, use the run_gdb task:
./run.sh run_gdb.work: Contains the working directories for toolchains, QEMU, OpenSBI, Linux, and Buildroot.scripts: Contains custom scripts and configurations.images: Contains the generated images for QEMU.
You can customize the setup by modifying the run.sh script and the configuration files in the scripts directory.
The crossdev library provides the core functionality for setting up and managing the cross-development environment. It includes modules for handling configurations, toolchains, QEMU, OpenSBI, Linux, and Buildroot.
Here is an example of how to use the crossdev library in your Rust code:
use crossdev::{config::*, crossdev::*, utils::*};
use color_eyre::Result;
fn main() -> Result<()> {
color_eyre::install()?;
let config_path = "path/to/config.toml";
let config = read_config_from_file(config_path)?;
let mut xdev = CrossDev::new(config)?;
xdev.setup()?;
xdev.run_qemu(None)?;
Ok(())
}This project is licensed under the MIT License. See the LICENSE file for details.
This project uses the following open-source projects:
Contributions are welcome! Please open an issue or submit a pull request for any improvements or bug fixes.
For any questions or support, please contact auking45@gmail.com.