Skip to content
No description, website, or topics provided.
Branch: master
Clone or download
phil-opp Use package.metadata.bootloader.target key for building bootloader
Instead of using the default target from the `.cargo/config`.
Latest commit ef235ed Apr 4, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
example-kernels Remove now unused `tester` example crate Apr 2, 2019
src Use package.metadata.bootloader.target key for building bootloader Apr 4, 2019
.gitignore
Cargo.lock
Cargo.toml
Changelog.md
LICENSE-APACHE
LICENSE-MIT
Readme.md
azure-pipelines.yml
bors.toml

Readme.md

bootimage

Creates a bootable disk image from a Rust OS kernel.

Installation

> cargo install bootimage

Usage

First you need to add a dependency on the bootloader crate:

# in your Cargo.toml

[dependencies]
bootloader = "0.5.0"

Note: At least bootloader version 0.5.0 is required since bootimage 0.7.0. For earlier bootloader versions, use bootimage 0.6.6.

If you want to use a custom bootloader with a different name, you can use Cargo's rename functionality.

Building

Now you can build the kernel project and create a bootable disk image from it by running:

bootimage build --target your_custom_target.json [other_args]

The command will invoke cargo xbuild, forwarding all passed options. Then it will build the specified bootloader together with the kernel to create a bootable disk image.

If you prefer a cargo subcommand, you can use the equivalent cargo bootimage command:

cargo bootimage --target your_custom_target.json [other_args]

Running

To run your kernel in QEMU, you can use bootimage run:

bootimage run --target your_custom_target.json [other_args] -- [qemu args]

All arguments after -- are passed to QEMU. If you want to use a custom run command, see the Configuration section below.

If you prefer working directly with cargo, you can use bootimage runner as a custom runner in your .cargo/config:

[target.'cfg(target_os = "none")']
runner = "bootimage runner"

Now you can run your kernel through cargo xrun --target […].

Configuration

Configuration is done through a through a [package.metadata.bootimage] table in the Cargo.toml of your kernel. The following options are available:

    [package.metadata.bootimage]
    # This target is used if no `--target` is passed
    default-target = ""

    # The command invoked on `bootimage run` or `bootimage runner`
    # (the "{}" will be replaced with the path to the bootable disk image)
    run-command = ["qemu-system-x86_64", "-drive", "format=raw,file={}"]

    # Additional arguments passed to the runner on `bootimage run` or `bootimage runner`
    # (this is useful when you want to add some arguments to the default QEMU command)
    run-args = []

    # The timeout for running an integration test through `bootimage test` in seconds
    test-timeout = 300

License

Licensed under either of

at your option.

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

You can’t perform that action at this time.