rust-osdev / bootimage Goto Github PK
View Code? Open in Web Editor NEWTool to create bootable disk images from a Rust OS kernel.
License: Apache License 2.0
Tool to create bootable disk images from a Rust OS kernel.
License: Apache License 2.0
error[E0461]: couldn't find crate core
with expected target triple x86_64-bootloader-8493042128464191786
|
= note: the following crate versions were found:
crate core
, target triple x86_64-bootloader-14747452034751789700: /home/tinyman/Documents/kern/target/bootimage/bootloader/bootloader-sysroot/lib/rustlib/x86_64-bootloader/lib/libcore-6c95d5ee8df52f8b.rmeta
crate core
, target triple x86_64-bootloader-14747452034751789700: /home/tinyman/Documents/kern/target/bootimage/bootloader/bootloader-sysroot/lib/rustlib/x86_64-bootloader/lib/libcore-6c95d5ee8df52f8b.rlib
error: aborting due to previous error
####################################################################################################
I dont know why this is happening tbh...
Cargo.toml.txt
x64_target.json.txt
NIGHTLY VERSION: 1.46
RUST EDITION: 2018
BOOTIMAGE VERSION: 0.9.4 (tried that all the way down to 0.9.2
I'm not exactly sure whats the problem but you can check out the issues here
ableos
and running the following command
sh src/arch/x86_64/run.sh
I cant cargo install bootimage it throws out these errors
error: expected one of ,
or as
, found ::
--> .cargo\registry\src\github.com-1ecc6299db9ec823\bootimage-0.4.3\src\config.rs:27:17
|
27 | use std::{fs::File, io::Read};
| ^^ expected one of ,
or as
here
error: expected one of ;
or as
, found ::
--> .cargo\registry\src\github.com-1ecc6299db9ec823\bootimage-0.4.3\src\config.rs:27:17
|
27 | use std::{fs::File, io::Read};
| ^^ expected one of ;
or as
here
error: expected item, found ;
--> .cargo\registry\src\github.com-1ecc6299db9ec823\bootimage-0.4.3\src\config.rs:27:34
|
27 | use std::{fs::File, io::Read};
| ^
~/bin/qemu-system-x86_64
put exec /mnt/c/Program\ Files/qemu/qemu-system-x86_64.exe "$@"
and make the file executablecargo xrun
cargo xtest
The xrun command works because it provides a relative path to the target to run to qemu. However xtest fails because it provides an absolute path which native QEMU doesn't understand. Passing a relative path just like xrun does should fix the issue.
Running: `qemu-system-x86_64 -drive format=raw,file=/mnt/c/projects/blog_os/target/x86_64-blog_os/debug/deps/bootimage-blog_os-f9b6181f9decdfac.bin -device isa-debug-exit,iobase=0xf4,iosize=0x04 -serial stdio -display none`
C:\Program Files\qemu\qemu-system-x86_64.exe: -drive format=raw,file=/mnt/c/projects/blog_os/target/x86_64-blog_os/debug/deps/bootimage-blog_os-f9b6181f9decdfac.bin: Could not open '/mnt/c/open/blog_os/target/x86_64-blog_os/debug/deps/bootimage-blog_os-f9b6181f9decdfac.bin': The system cannot find the path specified.
The debug sections (eg. debug_line) are stripped even in debug builds, even though kernels might want to use that for things like line numbers.
I was following along with Writing an OS in Rust post-06; after writing the stack_overflow() test I also tried testing the failure case. The posts suggests commenting out the .set_stack_index(DOUBLE_FAULT_IST_INDEX)
line of the double-fault handler, so I did that and ran the test again.
The test doesn't fail, instead it enters a bootloop where the stack overflows, pushes the interrupt handler to the stack, triple-faults, and reboots QEMU. This is reproducible in the post-06 branch of phil-opp/blog_os as well.
I tried setting QEMU's -no-reboot
option in test-args; this stops the bootlooping, but the test still passes because QEMU has a return code of 0 in this case. Bootimage passes this exit code on to cargo-test, which marks the test as passed.
I think it's a small change, but by considering all non test-success-exit-codes
as test failures, we could set up tests that fail on any unexpected reboot of the system with -no-reboot
. Successful runs would then only be reported by the test framework itself.
Currently if you try to compile a boot-loader by yourself with --build-bootloader, you have to delete target/x86_64-unknown-blog_os/{debug,release}/bootloader.bin
(if you already ran the tool, using precompiled boot-loader or by compiling yourself), otherwise it will keep using old bootloader.
Moreover if you want to use an other git repository than the default, you have to delete target/x86_64-unknown-blog_os/{debug,release}/bootloader/
if "bootloader" was the name of the old repository. If you don't the tool will keep using the old repository. Not that this issue apply even if new repository is called differently, but does not if old repository was anything different than "bootloader".
An easy fix is to just run cargo clean
, but this should be documented somewhere
error[E0463]:` can't find crate for `std`
|
= note: the `x86_64-blog_os-15208490549555036839` target may not support the standard library
= note: `std` is required by `serde` because it does not declare `#![no_std]`
= help: consider building the standard library from source with `cargo build -Zbuild-std`
Code:
// src/main.rs
#![no_std] // don't link the Rust standard library
#![no_main] // disable all Rust-level entry points
use core::panic::PanicInfo;
/// This function is called on panic.
#[panic_handler]
fn panic(_info: &PanicInfo) -> ! {
loop {}
}
static HELLO: &[u8] = b"Hello World!";
#[no_mangle] // don't mangle the name of this function
pub extern "C" fn _start() -> ! {
// this function is the entry point, since the linker looks for a function
// named `_start` by default
let vga_buffer = 0xb8000 as *mut u8;
for (i, &byte) in HELLO.iter().enumerate(){
unsafe {
*vga_buffer.offset(i as isize * 2) = byte;
*vga_buffer.offset(i as isize * 2 + 1) = 0xb;
}
}
loop {}
}
.cargo/config.toml
:
[unstable]
build-std-features = ["compiler-builtins-mem"]
build-std = ["core", "compiler_builtins"]
[build]
target = "x86_64-blog_os.json"
Should I delete the no_std line? or build using "-Zbuild-std"
What did I do wrong? Maybe it's obvious, but I can be inattentive. .
Just for the record: i added the "#![no_std]" and "#![no_main]" to the top of my main file.
When trying to install bootimage (using cargo install bootimage
) , when reaching the 21st dependency it starts spitting out warnings like this:
error[E0425]: cannot find function, tuple struct or tuple variant `Ok` in this scope
--> /home/threadexception/.cargo/registry/src/github.com-1ecc6299db9ec823/serde-1.0.136/src/de/impls.rs:2139:52
|
2139 | ... "nanos_since_epoch" => Ok(Field::Nanos),
| ^^ not found in this scope
error[E0425]: cannot find function, tuple struct or tuple variant `Err` in this scope
--> /home/threadexception/.cargo/registry/src/github.com-1ecc6299db9ec823/serde-1.0.136/src/de/impls.rs:2140:34
|
2140 | ... _ => Err(Error::unknown_field(value, FIELDS)),
| ^^^ not found in this scope
error[E0425]: cannot find function, tuple struct or tuple variant `Ok` in this scope
--> /home/threadexception/.cargo/registry/src/github.com-1ecc6299db9ec823/serde-1.0.136/src/de/impls.rs:2149:52
|
2149 | ... b"secs_since_epoch" => Ok(Field::Secs),
| ^^ not found in this scope
error[E0425]: cannot find function, tuple struct or tuple variant `Ok` in this scope
--> /home/threadexception/.cargo/registry/src/github.com-1ecc6299db9ec823/serde-1.0.136/src/de/impls.rs:2150:53
|
2150 | ... b"nanos_since_epoch" => Ok(Field::Nanos),
| ^^ not found in this scope
error[E0425]: cannot find function, tuple struct or tuple variant `Err` in this scope
--> /home/threadexception/.cargo/registry/src/github.com-1ecc6299db9ec823/serde-1.0.136/src/de/impls.rs:2153:33
|
2153 | ... Err(Error::unknown_field(&value, FIELDS))
| ^^^ not found in this scope
error[E0531]: cannot find tuple struct or tuple variant `Some` in this scope
--> /home/threadexception/.cargo/registry/src/github.com-1ecc6299db9ec823/serde-1.0.136/src/de/impls.rs:2169:17
|
2169 | Some(_) => Ok(()),
| ^^^^ not found in this scope
|
help: consider importing this tuple variant
|
1 | use __private::de::Content::Some;
|
error[E0425]: cannot find function, tuple struct or tuple variant `Ok` in this scope
--> /home/threadexception/.cargo/registry/src/github.com-1ecc6299db9ec823/serde-1.0.136/src/de/impls.rs:2169:28
|
2169 | Some(_) => Ok(()),
| ^^ not found in this scope
error[E0425]: cannot find function, tuple struct or tuple variant `Err` in this scope
--> /home/threadexception/.cargo/registry/src/github.com-1ecc6299db9ec823/serde-1.0.136/src/de/impls.rs:2170:25
|
2170 | None => Err(E::custom("overflow deserializing SystemTime epoch offset")),
| ^^^ not found in this scope
error[E0531]: cannot find tuple struct or tuple variant `Some` in this scope
--> /home/threadexception/.cargo/registry/src/github.com-1ecc6299db9ec823/serde-1.0.136/src/de/impls.rs:2188:21
|
2188 | Some(value) => value,
| ^^^^ not found in this scope
|
help: consider importing this tuple variant
|
1 | use __private::de::Content::Some;
|
error[E0425]: cannot find function, tuple struct or tuple variant `Err` in this scope
--> /home/threadexception/.cargo/registry/src/github.com-1ecc6299db9ec823/serde-1.0.136/src/de/impls.rs:2190:32
|
2190 | return Err(Error::invalid_length(0, &self));
| ^^^ not found in this scope
error[E0531]: cannot find tuple struct or tuple variant `Some` in this scope
--> /home/threadexception/.cargo/registry/src/github.com-1ecc6299db9ec823/serde-1.0.136/src/de/impls.rs:2194:21
|
2194 | Some(value) => value,
| ^^^^ not found in this scope
|
help: consider importing this tuple variant
|
1 | use __private::de::Content::Some;
|
error[E0425]: cannot find function, tuple struct or tuple variant `Err` in this scope
--> /home/threadexception/.cargo/registry/src/github.com-1ecc6299db9ec823/serde-1.0.136/src/de/impls.rs:2196:32
|
2196 | return Err(Error::invalid_length(1, &self));
| ^^^ not found in this scope
error[E0425]: cannot find function, tuple struct or tuple variant `Ok` in this scope
--> /home/threadexception/.cargo/registry/src/github.com-1ecc6299db9ec823/serde-1.0.136/src/de/impls.rs:2200:17
|
2200 | Ok(Duration::new(secs, nanos))
| ^^ not found in this scope
error[E0425]: cannot find value `None` in this scope
--> /home/threadexception/.cargo/registry/src/github.com-1ecc6299db9ec823/serde-1.0.136/src/de/impls.rs:2207:45
|
2207 | let mut secs: Option<u64> = None;
| ^^^^ not found in this scope
|
help: consider importing this unit variant
|
1 | use __private::de::Content::None;
|
error[E0425]: cannot find value `None` in this scope
--> /home/threadexception/.cargo/registry/src/github.com-1ecc6299db9ec823/serde-1.0.136/src/de/impls.rs:2208:46
|
2208 | let mut nanos: Option<u32> = None;
| ^^^^ not found in this scope
|
help: consider importing this unit variant
|
1 | use __private::de::Content::None;
|
error[E0531]: cannot find tuple struct or tuple variant `Some` in this scope
--> /home/threadexception/.cargo/registry/src/github.com-1ecc6299db9ec823/serde-1.0.136/src/de/impls.rs:2209:27
|
2209 | while let Some(key) = try!(map.next_key()) {
| ^^^^ not found in this scope
|
help: consider importing this tuple variant
|
1 | use __private::de::Content::Some;
|
error[E0425]: cannot find function, tuple struct or tuple variant `Err` in this scope
--> /home/threadexception/.cargo/registry/src/github.com-1ecc6299db9ec823/serde-1.0.136/src/de/impls.rs:2213:40
|
2213 | ... return Err(<A::Error as Error>::duplicate_field(
| ^^^ not found in this scope
error[E0425]: cannot find function, tuple struct or tuple variant `Some` in this scope
--> /home/threadexception/.cargo/registry/src/github.com-1ecc6299db9ec823/serde-1.0.136/src/de/impls.rs:2217:36
|
2217 | ... secs = Some(try!(map.next_value()));
| ^^^^ not found in this scope
|
help: consider importing this tuple variant
|
1 | use __private::de::Content::Some;
|
error[E0425]: cannot find function, tuple struct or tuple variant `Err` in this scope
--> /home/threadexception/.cargo/registry/src/github.com-1ecc6299db9ec823/serde-1.0.136/src/de/impls.rs:2221:40
|
2221 | ... return Err(<A::Error as Error>::duplicate_field(
| ^^^ not found in this scope
error[E0425]: cannot find function, tuple struct or tuple variant `Some` in this scope
--> /home/threadexception/.cargo/registry/src/github.com-1ecc6299db9ec823/serde-1.0.136/src/de/impls.rs:2225:37
|
2225 | ... nanos = Some(try!(map.next_value()));
| ^^^^ not found in this scope
|
help: consider importing this tuple variant
|
1 | use __private::de::Content::Some;
|
error[E0531]: cannot find tuple struct or tuple variant `Some` in this scope
--> /home/threadexception/.cargo/registry/src/github.com-1ecc6299db9ec823/serde-1.0.136/src/de/impls.rs:2230:21
|
2230 | Some(secs) => secs,
| ^^^^ not found in this scope
|
help: consider importing this tuple variant
|
1 | use __private::de::Content::Some;
|
error[E0425]: cannot find function, tuple struct or tuple variant `Err` in this scope
--> /home/threadexception/.cargo/registry/src/github.com-1ecc6299db9ec823/serde-1.0.136/src/de/impls.rs:2231:36
|
2231 | None => return Err(<A::Error as Error>::missing_field("secs_since_epoch")),
| ^^^ not found in this scope
my cargo.toml:
[package]
name = "Something"
version = "0.1.0"
edition = "2021"
[profile.dev]
panic = "abort"
[profile.release]
panic = "abort"
[dependencies]
bootloader = "0.9.22"
my cargo.lock:
version = 3
[[package]]
name = "Something"
version = "0.1.0"
dependencies = [
"bootloader",
]
[[package]]
name = "bootloader"
version = "0.9.22"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "de78decc37247c7cfac5dbf3495c7298c6ac97cb355161caa7e15969c6648e6c"
my config.toml:
[build]
target = "x86_64-os.json"
[unstable]
build-std-features = ["compiler-builtins-mem"]
build-std = ["core", "compiler_builtins"]
[target.'cfg(target_os = "none")']
runner = "bootimage runner"
I was following the OS tutorial, and ran into an issue when using cargo bootimage
.
→ cargo bootimage --target ./x64_86-darkos.json
Building kernel
Compiling compiler_builtins v0.1.105
Compiling core v0.0.0 (C:\Users\ticta\.rustup\toolchains\nightly-x86_64-pc-windows-msvc\lib\rustlib\src\rust\library\core)
Compiling bootloader v0.9.23
Compiling rustc-std-workspace-core v1.99.0 (C:\Users\ticta\.rustup\toolchains\nightly-x86_64-pc-windows-msvc\lib\rustlib\src\rust\library\rustc-std-workspace-core)
Compiling os v0.1.0 (C:\Users\ticta\Deno\os)
Finished dev [unoptimized + debuginfo] target(s) in 21.97s
Error: Failed to find kernel binary in cargo metadata output
When looking through to target folder, it did spit out a file that looks to be the kernel binary:
Not exactly sure how to solve this issue.
My os is Windows (11) and my cargo version is cargo 1.77.0-nightly (1ae631085 2024-01-17)
I have installed the nightly build, xbuild, and bootimage and checked that the versions all seem correct. Everything works up to the point of creating an image, the project even builds with cargo xbuild --target...but when I run bootimage build --target ... I get this error, here is the backtrace:
wwestlake@kali:~/Projects/rust/os-dev$ RUST_BACKTRACE=1 bootimage build --target x86_64-hacker-os.json
thread 'main' panicked at 'Could not read crate name from cargo metadata', src/libcore/option.rs:1038:5
stack backtrace:
0: std::sys::unix::backtrace::tracing::imp::unwind_backtrace
at src/libstd/sys/unix/backtrace/tracing/gcc_s.rs:39
1: std::sys_common::backtrace::_print
at src/libstd/sys_common/backtrace.rs:70
2: std::panicking::default_hook::{{closure}}
at src/libstd/sys_common/backtrace.rs:58
at src/libstd/panicking.rs:200
3: std::panicking::default_hook
at src/libstd/panicking.rs:215
4: std::panicking::rust_panic_with_hook
at src/libstd/panicking.rs:478
5: std::panicking::continue_panic_fmt
at src/libstd/panicking.rs:385
6: rust_begin_unwind
at src/libstd/panicking.rs:312
7: core::panicking::panic_fmt
at src/libcore/panicking.rs:85
8: core::option::expect_failed
at src/libcore/option.rs:1038
9: bootimage::build::build_impl
10: bootimage::build::build
11: bootimage::main
12: std::rt::lang_start::{{closure}}
13: std::panicking::try::do_call
at src/libstd/rt.rs:49
at src/libstd/panicking.rs:297
14: __rust_maybe_catch_panic
at src/libpanic_unwind/lib.rs:92
15: std::rt::lang_start_internal
at src/libstd/panicking.rs:276
at src/libstd/panic.rs:388
at src/libstd/rt.rs:48
16: main
17: __libc_start_main
18: _start
For some reason VirtualBox expects that disk images are a multiple of 512 bytes. We had an option to add the required padding in an old version of bootimage
but we haven't ported that option to the new build system yet.
Reported in phil-opp/blog_os#403 (comment)
Can we have a way to select the first x tests, so that we can run (for example) 4 testing Jobs running bootimage test
When I try to build blog_os or intermezzOS or my "OS" I get this error:
Error: Failed to build bootloader: Could not open bootloader: No such file or directory (os error 2)
And I can't see to find the reason why since all of them already have the bootloader
package as dependency
Would be nice to have minimal support for aarch64 and riscv bare metal targets.
Starting in version 0.10.1
of the bootloader
crate, they removed the package.metadata.bootloader.target
key in their Cargo.toml
. This causes an error to be thrown by this crate whenever using a version of bootimage
than version 0.10.0
.
The error looks as follows:
Error: An error occured while trying to build the bootloader: The `bootloader` dependency has not the right format: No `package.metadata.bootloader.target` key found in Cargo.toml of bootloader
(If you're using the official bootloader crate, you need at least version 0.5.1)
Caused by:
The `bootloader` dependency has not the right format: No `package.metadata.bootloader.target` key found in Cargo.toml of bootloader
(If you're using the official bootloader crate, you need at least version 0.5.1)
Perhaps, for the time being, the error could include a message that a version higher than 0.10.0
cannot be used also, until a legitimate fix is created.
Hi,
First of all, I want to say big thanks because your blog that explains quite well how to start with kernel OS using Rust! This language is always compared to C language but it's very rare to find an interesting blog about how to write kernel OS in Rust.
When I'm trying to play with A Minimal Rust Kernel example, I actually got an error from cargo bootimage. I don't really know where the error comes from but I've setup a workspace project compares to your example such that my directory looks like:
The top Cargo.toml
:
[workspace]
members = [
"src/dummy_os",
]
# the profile used for `cargo build`
[profile.dev]
panic = "abort" # disable stack unwinding on panic
# the profile used for `cargo build --release`
[profile.release]
panic = "abort" # disable stack unwinding on panic
The .cargo/config
:
[build]
target = "x86_64-dummy_os.json"
[target.'cfg(target_os = "none")']
runner = "bootimage runner"
The src/dummy_os/Cargo.toml
:
[package]
name = "dummy_os"
version = "0.1.0"
edition = "2018"
[[bin]]
name = "dummy_os"
path = "main.rs"
[dependencies]
bootloader = "*"
The src/dummy_os/main.rs
:
#![no_std] // don't link the Rust standard library
#![no_main] // disable all Rust-level entry points
use core::panic::PanicInfo;
/// This function is called on panic.
#[panic_handler]
fn panic(_info: &PanicInfo) -> ! {
loop {}
}
static HELLO: &[u8] = b"Hello World!";
#[no_mangle] // don't mangle the name of this function
pub extern "C" fn _start() -> ! {
let vga_buffer = 0xb8000 as *mut u8;
for (i, &byte) in HELLO.iter().enumerate() {
unsafe {
*vga_buffer.offset(i as isize * 2) = byte;
*vga_buffer.offset(i as isize * 2 + 1) = 0xb;
}
}
loop {}
}
Here's the error:
Building kernel
WARNING: There is no root package to read the cargo-xbuild config from.
Updating crates.io index
Compiling core v0.0.0 (~/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/libcore)
Compiling compiler_builtins v0.1.27
Compiling rustc-std-workspace-core v1.99.0 (~/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/tools/rustc-std-workspace-core)
Compiling alloc v0.0.0 (/tmp/cargo-xbuild.B83qpoInHGhF)
Finished release [optimized] target(s) in 39.40s
Compiling bootloader v0.9.2
Compiling dummy_os v0.1.0 (~/dummy_os/src/dummy_os)
Finished dev [unoptimized + debuginfo] target(s) in 0.94s
Error: Could not find required key `packages[manifest_path = `~/dummy_os/Cargo.toml`]` in cargo metadata output
$ bootimage -h
Creates a bootable disk image from a Rust kernel
USAGE:
cargo bootimage [BUILD_OPTS] Create a bootable disk image
bootimage runner EXECUTABLE [RUN_OPTS] Convert and run an executable
For more information about a subcommand run `[subcommand] --help`.
GENERAL OPTIONS:
-h, --help Prints help information and exit
--version Prints version information and exit
$ bootimage --version
Error: Unsupported subcommand `"--version"`. See `bootimage --help` for an overview of supported subcommands.
Right now the CI build only invokes cargo test
, but does not try to run bootimage
. This caused a lot of churn in recent releases because some bugs on Windows were only discovered after publishing. To avoid this in the future, we should try to build a test project on all three platforms.
I am trying to provide a package to the kernel, but somehow, anything I provide ends up with a length of 0. Reading the code, that should not happen, but strangely enough, it does. I tried with multiple file types even though it should not be a problem, but still the same result.
I want to use serial output for pretty much everything, but runs into some problems with what bootimage test
expects. For example, this test adapted from your blog fails when it probably shouldn't:
RUN: test-exception-breakpoint
FAIL: Invalid Output:
EXCEPTION: BREAKPOINT
ExceptionStackFrame {
instruction_pointer: VirtAddr(0x205ae1),
code_segment: 8,
cpu_flags: 0x16,
stack_pointer: VirtAddr(0x57ac001fffa0),
stack_segment: 0
}
ok
Unless there is a good reason for this behavior which I'm unaware of, this is what I suggest:
diff --git a/src/test.rs b/src/test.rs
index 6d31af4..39b94a8 100644
--- a/src/test.rs
+++ b/src/test.rs
@@ -92,15 +92,15 @@ pub(crate) fn test(args: Args) -> Result<(), Error> {
let output = fs::read_to_string(&output_file).with_context(|e| {
format_err!("Failed to read test output file {}: {}", output_file, e)
})?;
- if output.starts_with("ok\n") {
- test_result = TestResult::Ok;
- println!("OK: {}", target.name);
- } else if output.starts_with("failed\n") {
+ if output.contains("failed\n") {
test_result = TestResult::Failed;
writeln!(io::stderr(), "FAIL:")?;
for line in output[7..].lines() {
writeln!(io::stderr(), " {}", line)?;
}
+ } else if output.contains("ok\n") {
+ test_result = TestResult::Ok;
+ println!("OK: {}", target.name);
} else {
test_result = TestResult::Invalid;
writeln!(io::stderr(), "FAIL: Invalid Output:")?;
With this patch, the test passes.
(It might be better to replace, e.g., if output.contains("failed\n")
with something like if Regex::new(r"^failed$").unwrap().is_match(output)
, but I'll let you decide if you end up keeping this change.)
When I try to cargo install bootimage, I get the following error.
error[E0425]: cannot find function `read_to_string` in module `fs`
--> src/test.rs:66:34
|
66 | let output = fs::read_to_string(&output_file)
| ^^^^^^^^^^^^^^ did you mean `read_string`?
error: aborting due to previous error
error: failed to compile `bootimage v0.4.3`, intermediate artifacts can be found at `/tmp/cargo-install.bb6pN4pqkVxR`
Build Error ->
Building bootloader
Compiling bootloader v0.9.23 (/home/vishwak/.cargo/registry/src/github.com-1ecc6299db9ec823/bootloader-0.9.23)
error: linking with rust-lld
failed: exit status: 1
|
= note: "rust-lld" "-flavor" "gnu" "/tmp/rustce5sqQC/symbols.o" "/home/vishwak/Desktop/rob_os/target/bootimage/bootloader/x86_64-bootloader/release/deps/bootloader-450374ad17af6ce7.bootloader.cc87495c-cgu.0.rcgu.o" "/home/vishwak/Desktop/rob_os/target/bootimage/bootloader/x86_64-bootloader/release/deps/bootloader-450374ad17af6ce7.bootloader.cc87495c-cgu.1.rcgu.o" "/home/vishwak/Desktop/rob_os/target/bootimage/bootloader/x86_64-bootloader/release/deps/bootloader-450374ad17af6ce7.bootloader.cc87495c-cgu.10.rcgu.o" "/home/vishwak/Desktop/rob_os/target/bootimage/bootloader/x86_64-bootloader/release/deps/bootloader-450374ad17af6ce7.bootloader.cc87495c-cgu.11.rcgu.o" "/home/vishwak/Desktop/rob_os/target/bootimage/bootloader/x86_64-bootloader/release/deps/bootloader-450374ad17af6ce7.bootloader.cc87495c-cgu.12.rcgu.o" "/home/vishwak/Desktop/rob_os/target/bootimage/bootloader/x86_64-bootloader/release/deps/bootloader-450374ad17af6ce7.bootloader.cc87495c-cgu.13.rcgu.o" "/home/vishwak/Desktop/rob_os/target/bootimage/bootloader/x86_64-bootloader/release/deps/bootloader-450374ad17af6ce7.bootloader.cc87495c-cgu.14.rcgu.o" "/home/vishwak/Desktop/rob_os/target/bootimage/bootloader/x86_64-bootloader/release/deps/bootloader-450374ad17af6ce7.bootloader.cc87495c-cgu.15.rcgu.o" "/home/vishwak/Desktop/rob_os/target/bootimage/bootloader/x86_64-bootloader/release/deps/bootloader-450374ad17af6ce7.bootloader.cc87495c-cgu.2.rcgu.o" "/home/vishwak/Desktop/rob_os/target/bootimage/bootloader/x86_64-bootloader/release/deps/bootloader-450374ad17af6ce7.bootloader.cc87495c-cgu.3.rcgu.o" "/home/vishwak/Desktop/rob_os/target/bootimage/bootloader/x86_64-bootloader/release/deps/bootloader-450374ad17af6ce7.bootloader.cc87495c-cgu.4.rcgu.o" "/home/vishwak/Desktop/rob_os/target/bootimage/bootloader/x86_64-bootloader/release/deps/bootloader-450374ad17af6ce7.bootloader.cc87495c-cgu.5.rcgu.o" "/home/vishwak/Desktop/rob_os/target/bootimage/bootloader/x86_64-bootloader/release/deps/bootloader-450374ad17af6ce7.bootloader.cc87495c-cgu.6.rcgu.o" "/home/vishwak/Desktop/rob_os/target/bootimage/bootloader/x86_64-bootloader/release/deps/bootloader-450374ad17af6ce7.bootloader.cc87495c-cgu.7.rcgu.o" "/home/vishwak/Desktop/rob_os/target/bootimage/bootloader/x86_64-bootloader/release/deps/bootloader-450374ad17af6ce7.bootloader.cc87495c-cgu.8.rcgu.o" "/home/vishwak/Desktop/rob_os/target/bootimage/bootloader/x86_64-bootloader/release/deps/bootloader-450374ad17af6ce7.bootloader.cc87495c-cgu.9.rcgu.o" "--as-needed" "-L" "/home/vishwak/Desktop/rob_os/target/bootimage/bootloader/x86_64-bootloader/release/deps" "-L" "/home/vishwak/Desktop/rob_os/target/bootimage/bootloader/release/deps" "-L" "/home/vishwak/Desktop/rob_os/target/bootimage/bootloader/x86_64-bootloader/release/build/bootloader-fde440b665d7cabe/out" "-L" "/home/vishwak/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-bootloader/lib" "-Bstatic" "/home/vishwak/Desktop/rob_os/target/bootimage/bootloader/x86_64-bootloader/release/deps/libxmas_elf-1b0eb3c9e888241a.rlib" "/home/vishwak/Desktop/rob_os/target/bootimage/bootloader/x86_64-bootloader/release/deps/libzero-57189841b2339f05.rlib" "/home/vishwak/Desktop/rob_os/target/bootimage/bootloader/x86_64-bootloader/release/deps/libx86_64-e25559ea51de7d3f.rlib" "/home/vishwak/Desktop/rob_os/target/bootimage/bootloader/x86_64-bootloader/release/deps/libvolatile-d6ac5c40aab33080.rlib" "/home/vishwak/Desktop/rob_os/target/bootimage/bootloader/x86_64-bootloader/release/deps/libbitflags-31a974eb394720c5.rlib" "/home/vishwak/Desktop/rob_os/target/bootimage/bootloader/x86_64-bootloader/release/deps/libbit_field-9221251971479c34.rlib" "/home/vishwak/Desktop/rob_os/target/bootimage/bootloader/x86_64-bootloader/release/deps/libusize_conversions-62d1ca308bc02994.rlib" "/home/vishwak/Desktop/rob_os/target/bootimage/bootloader/x86_64-bootloader/release/deps/libfixedvec-ff02a9f57794635e.rlib" "/home/vishwak/Desktop/rob_os/target/bootimage/bootloader/x86_64-bootloader/release/deps/libbootloader-2367883e8c24fdcd.rlib" "/home/vishwak/Desktop/rob_os/target/bootimage/bootloader/x86_64-bootloader/release/deps/librlibc-49b62c07f530266c.rlib" "/home/vishwak/Desktop/rob_os/target/bootimage/bootloader/x86_64-bootloader/release/deps/librustc_std_workspace_core-22c20f375a03a6ed.rlib" "/home/vishwak/Desktop/rob_os/target/bootimage/bootloader/x86_64-bootloader/release/deps/libcore-12df7a30b9be6a65.rlib" "/home/vishwak/Desktop/rob_os/target/bootimage/bootloader/x86_64-bootloader/release/deps/libcompiler_builtins-b00de6a92c2e2781.rlib" "-Bdynamic" "--eh-frame-hdr" "-znoexecstack" "-L" "/home/vishwak/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-bootloader/lib" "-o" "/home/vishwak/Desktop/rob_os/target/bootimage/bootloader/x86_64-bootloader/release/deps/bootloader-450374ad17af6ce7" "--gc-sections" "-O1"
= note: rust-lld: error: undefined symbol: _rest_of_bootloader_start_addr
>>> referenced by bootloader.cc87495c-cgu.1
>>> /home/vishwak/Desktop/rob_os/target/bootimage/bootloader/x86_64-bootloader/release/deps/bootloader-450374ad17af6ce7.bootloader.cc87495c-cgu.1.rcgu.o:(.boot-first-stage+0x60)
>>> referenced by bootloader.cc87495c-cgu.1
>>> /home/vishwak/Desktop/rob_os/target/bootimage/bootloader/x86_64-bootloader/release/deps/bootloader-450374ad17af6ce7.bootloader.cc87495c-cgu.1.rcgu.o:(.boot-first-stage+0x7B)
rust-lld: error: undefined symbol: _rest_of_bootloader_end_addr
>>> referenced by bootloader.cc87495c-cgu.1
>>> /home/vishwak/Desktop/rob_os/target/bootimage/bootloader/x86_64-bootloader/release/deps/bootloader-450374ad17af6ce7.bootloader.cc87495c-cgu.1.rcgu.o:(.boot-first-stage+0x81)
rust-lld: error: undefined symbol: _kernel_buffer
>>> referenced by bootloader.cc87495c-cgu.1
>>> /home/vishwak/Desktop/rob_os/target/bootimage/bootloader/x86_64-bootloader/release/deps/bootloader-450374ad17af6ce7.bootloader.cc87495c-cgu.1.rcgu.o:(.boot+0x59)
rust-lld: error: undefined symbol: _memory_map
>>> referenced by bootloader.cc87495c-cgu.1
>>> /home/vishwak/Desktop/rob_os/target/bootimage/bootloader/x86_64-bootloader/release/deps/bootloader-450374ad17af6ce7.bootloader.cc87495c-cgu.1.rcgu.o:(.boot+0xCA)
>>> referenced by main.rs:108 (src/main.rs:108)
>>> /home/vishwak/Desktop/rob_os/target/bootimage/bootloader/x86_64-bootloader/release/deps/bootloader-450374ad17af6ce7.bootloader.cc87495c-cgu.1.rcgu.o:(stage_4)
rust-lld: error: undefined symbol: __page_table_start
>>> referenced by bootloader.cc87495c-cgu.1
>>> /home/vishwak/Desktop/rob_os/target/bootimage/bootloader/x86_64-bootloader/release/deps/bootloader-450374ad17af6ce7.bootloader.cc87495c-cgu.1.rcgu.o:(.boot+0x1A1)
>>> referenced by bootloader.cc87495c-cgu.1
>>> /home/vishwak/Desktop/rob_os/target/bootimage/bootloader/x86_64-bootloader/release/deps/bootloader-450374ad17af6ce7.bootloader.cc87495c-cgu.1.rcgu.o:(.boot+0x20C)
>>> referenced by bootloader.cc87495c-cgu.1
>>> /home/vishwak/Desktop/rob_os/target/bootimage/bootloader/x86_64-bootloader/release/deps/bootloader-450374ad17af6ce7.bootloader.cc87495c-cgu.1.rcgu.o:(.boot+0x219)
>>> referenced 2 more times
rust-lld: error: undefined symbol: __page_table_end
>>> referenced by bootloader.cc87495c-cgu.1
>>> /home/vishwak/Desktop/rob_os/target/bootimage/bootloader/x86_64-bootloader/release/deps/bootloader-450374ad17af6ce7.bootloader.cc87495c-cgu.1.rcgu.o:(.boot+0x1A6)
>>> referenced by main.rs:111 (src/main.rs:111)
>>> /home/vishwak/Desktop/rob_os/target/bootimage/bootloader/x86_64-bootloader/release/deps/bootloader-450374ad17af6ce7.bootloader.cc87495c-cgu.1.rcgu.o:(stage_4)
>>> referenced by main.rs:105 (src/main.rs:105)
>>> /home/vishwak/Desktop/rob_os/target/bootimage/bootloader/x86_64-bootloader/release/deps/bootloader-450374ad17af6ce7.bootloader.cc87495c-cgu.1.rcgu.o:(stage_4)
rust-lld: error: undefined symbol: _p3
>>> referenced by bootloader.cc87495c-cgu.1
>>> /home/vishwak/Desktop/rob_os/target/bootimage/bootloader/x86_64-bootloader/release/deps/bootloader-450374ad17af6ce7.bootloader.cc87495c-cgu.1.rcgu.o:(.boot+0x1B4)
>>> referenced by bootloader.cc87495c-cgu.1
>>> /home/vishwak/Desktop/rob_os/target/bootimage/bootloader/x86_64-bootloader/release/deps/bootloader-450374ad17af6ce7.bootloader.cc87495c-cgu.1.rcgu.o:(.boot+0x1C9)
rust-lld: error: undefined symbol: _p4
>>> referenced by bootloader.cc87495c-cgu.1
>>> /home/vishwak/Desktop/rob_os/target/bootimage/bootloader/x86_64-bootloader/release/deps/bootloader-450374ad17af6ce7.bootloader.cc87495c-cgu.1.rcgu.o:(.boot+0x1BC)
>>> referenced by bootloader.cc87495c-cgu.1
>>> /home/vishwak/Desktop/rob_os/target/bootimage/bootloader/x86_64-bootloader/release/deps/bootloader-450374ad17af6ce7.bootloader.cc87495c-cgu.1.rcgu.o:(.boot+0x24C)
>>> referenced by main.rs:114 (src/main.rs:114)
>>> /home/vishwak/Desktop/rob_os/target/bootimage/bootloader/x86_64-bootloader/release/deps/bootloader-450374ad17af6ce7.bootloader.cc87495c-cgu.1.rcgu.o:(stage_4)
>>> referenced 1 more times
rust-lld: error: undefined symbol: _p2
>>> referenced by bootloader.cc87495c-cgu.1
>>> /home/vishwak/Desktop/rob_os/target/bootimage/bootloader/x86_64-bootloader/release/deps/bootloader-450374ad17af6ce7.bootloader.cc87495c-cgu.1.rcgu.o:(.boot+0x1C1)
>>> referenced by bootloader.cc87495c-cgu.1
>>> /home/vishwak/Desktop/rob_os/target/bootimage/bootloader/x86_64-bootloader/release/deps/bootloader-450374ad17af6ce7.bootloader.cc87495c-cgu.1.rcgu.o:(.boot+0x1D6)
>>> referenced by bootloader.cc87495c-cgu.1
>>> /home/vishwak/Desktop/rob_os/target/bootimage/bootloader/x86_64-bootloader/release/deps/bootloader-450374ad17af6ce7.bootloader.cc87495c-cgu.1.rcgu.o:(.boot+0x1FB)
rust-lld: error: undefined symbol: _p1
>>> referenced by bootloader.cc87495c-cgu.1
>>> /home/vishwak/Desktop/rob_os/target/bootimage/bootloader/x86_64-bootloader/release/deps/bootloader-450374ad17af6ce7.bootloader.cc87495c-cgu.1.rcgu.o:(.boot+0x1CE)
>>> referenced by bootloader.cc87495c-cgu.1
>>> /home/vishwak/Desktop/rob_os/target/bootimage/bootloader/x86_64-bootloader/release/deps/bootloader-450374ad17af6ce7.bootloader.cc87495c-cgu.1.rcgu.o:(.boot+0x231)
>>> referenced by bootloader.cc87495c-cgu.1
>>> /home/vishwak/Desktop/rob_os/target/bootimage/bootloader/x86_64-bootloader/release/deps/bootloader-450374ad17af6ce7.bootloader.cc87495c-cgu.1.rcgu.o:(.boot+0x371)
rust-lld: error: undefined symbol: __bootloader_end
>>> referenced by bootloader.cc87495c-cgu.1
>>> /home/vishwak/Desktop/rob_os/target/bootimage/bootloader/x86_64-bootloader/release/deps/bootloader-450374ad17af6ce7.bootloader.cc87495c-cgu.1.rcgu.o:(.boot+0x221)
>>> referenced by main.rs:113 (src/main.rs:113)
>>> /home/vishwak/Desktop/rob_os/target/bootimage/bootloader/x86_64-bootloader/release/deps/bootloader-450374ad17af6ce7.bootloader.cc87495c-cgu.1.rcgu.o:(stage_4)
>>> referenced by main.rs:105 (src/main.rs:105)
>>> /home/vishwak/Desktop/rob_os/target/bootimage/bootloader/x86_64-bootloader/release/deps/bootloader-450374ad17af6ce7.bootloader.cc87495c-cgu.1.rcgu.o:(stage_4)
rust-lld: error: undefined symbol: __bootloader_start
>>> referenced by main.rs:112 (src/main.rs:112)
>>> /home/vishwak/Desktop/rob_os/target/bootimage/bootloader/x86_64-bootloader/release/deps/bootloader-450374ad17af6ce7.bootloader.cc87495c-cgu.1.rcgu.o:(stage_4)
>>> referenced by main.rs:105 (src/main.rs:105)
>>> /home/vishwak/Desktop/rob_os/target/bootimage/bootloader/x86_64-bootloader/release/deps/bootloader-450374ad17af6ce7.bootloader.cc87495c-cgu.1.rcgu.o:(stage_4)
error: could not compile bootloader
due to previous error
Error: Bootloader build failed.
Stderr:
The crates.io page for bootimage doesn't have a link to this repository.
I want create iso, for my kernel, but seems bootimage supports only .bin.
Hello, loving this tool and your blog series!
I've been trying to get the image files built by bootimage
to run in VirtualBox to no avail. I looked through the comments on Minimal Rust Kernel and found #7 which added an option that would make files that would be convertible to VDI format, but it seems that option has since been removed. Trying to create a VDI file at the moment results in:
$ VBoxManage convertfromraw ./target/x86_64-blog_os/debug/bootimage-blog_os.bin /tmp/blog_os.vdi --format VDI --variant Standard --uuid <some UUID>
Converting from raw image file="./target/x86_64-blog_os/debug/bootimage-blog_os.bin" to file="/tmp/blog_os.vdi"...
Creating dynamic image with size 802816 bytes (1MB)...
VBoxManage: error: Cannot create the disk image "/tmp/blog_os.vdi": VERR_VD_INVALID_SIZE
Somewhere someone suggested just padding the file with zeroes up to 4MB. I tried that and was able to convert to VDI successfully, but when I tried to load the VDI in VirtualBox I got:
Result Code: | NS_ERROR_FAILURE (0x80004005)
-- | --
Component: | MediumWrap
Interface: | IMedium {4afe423b-43e0-e9d0-82e8-ceb307940dda}
Callee: | IVirtualBox {9570b9d5-f1a1-448a-10c5-e12f5285adad}
Callee RC: | VBOX_E_OBJECT_NOT_FOUND (0x80BB0001)
Are there other options or things I should try? If bootimage
was just never meant to work with VirtualBox that's a fine answer too.
Thanks!
Thanks to tools like Cargo.lock, --frozen, and cargo-vendor, it's possible to make fully reproducible builds. I propose allowing bootimage to take advantage to these tools to allow for reproducible boot images.
The main changes that would need to take place for this would be adding the ability to specify the bootloader url or git revision, and letting the user pass --frozen to the underlying calls to cargo and xargo.
I cannot install boot image. I am using the nightly-2020-07-15. When I run cargo install bootimage
it stops with three dependencies with about 2000 errors.
I won't be able to access my laptop until tomorrow, so I'll forward the errors then.
So, I'm working on updating intermezzos to the new version of bootimage, however I'm getting some failures on CI and locally that are strange. The only change I've made is to add the build
subcommand to `bootimage.
Here's the CI failure: https://travis-ci.org/intermezzOS/kernel/jobs/370152249#L521
error: current package believes it's in a workspace when it's not:
current: /home/travis/build/intermezzOS/kernel/target/intermezzos/debug/bootloader/Cargo.toml
workspace: /home/travis/build/intermezzOS/kernel/Cargo.toml
this may be fixable by ensuring that this crate is depended on by the workspace root: /home/travis/build/intermezzOS/kernel/Cargo.toml
thread 'main' panicked at 'Bootloader download failed.', src/build.rs:250:5
and locally:
> bootimage build --target=intermezzos
Building kernel
Compiling rlibc v1.0.0
Compiling vga v0.1.0 (file:///C:/Users/steve/src/intermezzos/kernel/vga)
error[E0463]: can't find crate for `compiler_builtins`
error: aborting due to previous error
For more information about this error, try `rustc --explain E0463`.
error: Could not compile `rlibc`.
warning: build failed, waiting for other jobs to finish...
error[E0463]: can't find crate for `compiler_builtins`
error: aborting due to previous error
For more information about this error, try `rustc --explain E0463`.
error: Could not compile `vga`.
To learn more, run the command again with --verbose.
Any ideas on what's going on here? I'm using bootimage 0.2.6 and rustc 1.27.0-nightly (ac3c2288f 2018-04-18)
.
In the README of bootimage
, it says that a custom bootloader
is supported, but reading the linked page does not really clear up what should be done to do this.
Should I fork locally the bootloader
crate, do my modifications and use it in my Cargo.toml
as this? If not how should it be done?
[dependencies.bootloader]
version = "*"
path = "../bootloader"
Thank you for the great tool. Currently, it allows us to create the main bootable image of the kernel but doesn't have too much of empty space left for other actions from within Qemu. Please allow zero padded binaries to play with disk drivers from kernel.
I'm currently trying to build rusty-hermit with bootimage in order to use your bootloader and custom test framework. However I can't seem to figure out where to place the dependency for bootloader.
In rusty-hermit the library containing the kernel libhermit-rs is built via a build script, since the application and the kernel are built with different targets. The library is then linked with the application.
Where exactly does bootimage expect the bootloader dependency? The Top level Cargo.toml is just a workspace, which also leads to WARNING: There is no root package to read the cargo-xbuild config from.
Also do I need to modify the build script to use cargo-xbuild ? I'm not sure if I'm doing something wrong in that regard but it doesn't seem to make a difference whether I use xbuild or build in the build script for the kernel. In both cases I have to pass "-Z build-std=core,alloc"
I tried:
bootloader = "0.9.2"
in every single Cargo.toml
file (except for the workspace one). For the 2015 edition crates I also added extern crate bootloader;
to the lib.rs file. I ran cargo bootimage --target x86_64-unknown-hermit -Z build-std=std,core,alloc,panic_abort
Created bootimage for `rusty_demo` at `/home/xxx/Dev/rusty-hermit/target/x86_64-unknown-hermit/debug/bootimage-rusty_demo.bin`
Error: An error occured while trying to build the bootloader: Bootloader dependency not found
You need to add a dependency on a crate named `bootloader` in your Cargo.toml.
Caused by:
Bootloader dependency not found
You need to add a dependency on a crate named `bootloader` in your Cargo.toml.
~/Dev/rusty-hermit$ KERNEL=target/x86_64-unknown-hermit/debug/rusty_demo KERNEL_MANIFEST=libhermit-rs/Cargo.toml cargo xbuild --release --features binary --target x86_64-unknown-hermit-kernel
. Here rusty_demo is the Kernel linked together with a demo application. The error is error: --features is not allowed in the root of a virtual workspace
.error: Package `rusty_demo v0.1.0 (/home/xxx/Dev/rusty-hermit/demo)` does not have these features: `binary`
.Do you have any ideas / hints on what I could do or look at to get this running?
(Sorry if this issue is filed in the wrong place)
I'm trying to compile a bootloader for my fledgling OS (FledgeOS), but I'm having trouble getting bootimage
to work correctly.
$ cat /etc/lsb-release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=19.04
DISTRIB_CODENAME=disco
DISTRIB_DESCRIPTION="Ubuntu 19.04"
$ rustup component list
cargo-x86_64-unknown-linux-gnu (installed)
clippy-x86_64-unknown-linux-gnu (installed)
llvm-tools-preview-x86_64-unknown-linux-gnu (installed)
...
$ cargo +nightly bootimage --target fledge.json
...
Building bootloader
Fresh nodrop v0.1.13
Fresh llvm-tools v0.1.1
Fresh bit_field v0.9.0
Fresh ux v0.1.3
Fresh cast v0.2.2
Fresh zero v0.1.2
Fresh fixedvec v0.2.4
Fresh usize_conversions v0.2.0
Fresh array-init v0.0.4
Fresh xmas-elf v0.6.2
Fresh bitflags v1.1.0
Compiling bootloader v0.7.1 (/home/tsm/.cargo/registry/src/github.com-1ecc6299db9ec823/bootloader-0.7.1)
Compiling x86_64 v0.7.4
Running `rustc --edition=2018 --crate-name x86_64 /home/tsm/.cargo/registry/src/github.com-1ecc6299db9ec823/x86_64-0.7.4/src/lib.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts --crate-type lib --emit=dep-info,metadata,link -C opt-level=3 -C panic=abort -C debuginfo=2 -C metadata=9b908b8ed60a7fa2 -C extra-filename=-9b908b8ed60a7fa2 --out-dir /home/tsm/Learn/FledgeOS/fledgeos-0/target/bootimage/bootloader/x86_64-bootloader/release/deps --target /home/tsm/.cargo/registry/src/github.com-1ecc6299db9ec823/bootloader-0.7.1/x86_64-bootloader.json -L dependency=/home/tsm/Learn/FledgeOS/fledgeos-0/target/bootimage/bootloader/x86_64-bootloader/release/deps -L dependency=/home/tsm/Learn/FledgeOS/fledgeos-0/target/bootimage/bootloader/release/deps --extern array_init=/home/tsm/Learn/FledgeOS/fledgeos-0/target/bootimage/bootloader/x86_64-bootloader/release/deps/libarray_init-cecd769fe74af588.rmeta --extern bit_field=/home/tsm/Learn/FledgeOS/fledgeos-0/target/bootimage/bootloader/x86_64-bootloader/release/deps/libbit_field-8bf6ec320a2ebdf6.rmeta --extern bitflags=/home/tsm/Learn/FledgeOS/fledgeos-0/target/bootimage/bootloader/x86_64-bootloader/release/deps/libbitflags-2ba702ed93258e5a.rmeta --extern cast=/home/tsm/Learn/FledgeOS/fledgeos-0/target/bootimage/bootloader/x86_64-bootloader/release/deps/libcast-b8f4afefb3392b63.rmeta --extern ux=/home/tsm/Learn/FledgeOS/fledgeos-0/target/bootimage/bootloader/x86_64-bootloader/release/deps/libux-9799f55390ca77e3.rmeta --cap-lints allow --sysroot /home/tsm/Learn/FledgeOS/fledgeos-0/target/bootimage/bootloader/bootloader-sysroot`
Running `/home/tsm/Learn/FledgeOS/fledgeos-0/target/bootimage/bootloader/release/build/bootloader-e08cd69e1cced972/build-script-build`
error: failed to run custom build command for `bootloader v0.7.1 (/home/tsm/.cargo/registry/src/github.com-1ecc6299db9ec823/bootloader-0.7.1)`
Caused by:
process didn't exit successfully: `/home/tsm/Learn/FledgeOS/fledgeos-0/target/bootimage/bootloader/release/build/bootloader-e08cd69e1cced972/build-script-build` (exit code: 1)
--- stderr
Error: llvm-tools not found
Maybe the rustup component `llvm-tools-preview` is missing?
Install it through: `rustup component add llvm-tools-preview`
warning: build failed, waiting for other jobs to finish...
error: build failed
Error: Bootloader build failed
Hi - Is support for multiple modules (such as an initrd) planned? Thanks!
Bootimage should be refactored to allow it to be expanded more easily.
I'm trying to build a project using bootimage and it successfully builds when I run cargo build
(not using bootimage to make it bootable), but fails to compile when I run cargo run
on the final step of compiling bootloader with bootimage. I wasn't sure whether to make this issue here or on bootloader, but my project compiles bootloader fine so I figured it was probably an issue with bootimage (or my environment!).
I get the following errors:
rust-lld: error: bootloader.30ac1y0p-cgu.0:(.boot-first-stage+0x81): relocation R_X86_64_16 out of range: 88576 is not in [-32768, 65535]; references _rest_of_bootloader_end_addr
rust-lld: error: bootloader.30ac1y0p-cgu.0:(.boot+0x6A): relocation R_X86_64_16 out of range: 88576 is not in [-32768, 65535]; references _kernel_start_addr
>>> defined in C:\Rust\Pogostick\target\bootimage\bootloader\x86_64-bootloader\release\deps\libbootloader-0325a9ea9e448093.rlib(kernel_bin-pogostick.o)
rust-lld: error: bootloader.30ac1y0p-cgu.0:(.boot+0x85): relocation R_X86_64_16 out of range: 880472 is not in [-32768, 65535]; references _kernel_size
>>> defined in C:\Rust\Pogostick\target\bootimage\bootloader\x86_64-bootloader\release\deps\libbootloader-0325a9ea9e448093.rlib(kernel_bin-pogostick.o)
My target JSON file looks like this:
{
"llvm-target": "x86_64-unknown-none",
"data-layout": "e-m:e-i64:64-f80:128-n8:16:32:64-S128",
"arch": "x86_64",
"target-endian": "little",
"target-pointer-width": "64",
"target-c-int-width": "32",
"os": "none",
"executables": true,
"linker-flavor": "ld.lld",
"linker": "rust-lld",
"panic-strategy": "abort",
"disable-redzone": true,
"features": "-mmx,-sse,+soft-float"
}
As a side note, it tells me I can run with --verbose
to get additional info, but when I do, it only applies to the original build and not to bootloader's runner. I've already tried rebooting and running cargo clean
.
Any advice would be much appreciated!
I'm writing a kernel that runs on both the Raspberry Pi 3 and x86_64. I'm trying to use bootloader+bootimage exclusively for the x86_64 version, but not any other architecture. As a result, my Cargo.toml looks like this:
[dependencies]
# common, architecture-independent dependencies
[target.'cfg(target_arch = "x86_64")'.dependencies]
bootloader = "^0.9.8"
When I compile this project with cargo bootimage --target targets/x86_64-unknown-none-softfloat.json --release
I get this error message:
Error: An error occured while trying to build the bootloader: Could not find required key `packages[name = `bootloader`` in cargo metadata output
However, if I change the bootloader dependency to not be conditional, i.e. if I just put it in the [dependencies] section, the above error goes away and the project boots perfectly.
Is there some extra configuration I need to do to make this work? It would be nice for me to be able to completely exclude the bootloader dependency off of x86.
Hi,
I saw in "run.rs" and "args/runners.rs" that there is a quiet argument which silences the "Running: ......" console output - which is exactly what I'd like to do.
Now I was wondering if there is any way to enable it in the "Cargo.toml" file, so I can use it with "cargo run" or "cargo test".
Thank you
Hi! I am executing bootimage runner
on MacOS, and my bios-256k.bin
of QEMU is not under normal path, so I have to manually add "-L ~/XXX/QEMU/pc-bios" to the qemu-system-x86_64
command and it can successfully run it. However, when I try to use [package.metadata.bootimage]'s run-args = ["-L ~/Code/QEMU/pc-bios"] to invoke cargo xrun
, it shows
Running:
qemu-system-x86_64 -drive format=raw,file=target/minikernel/debug/bootimage-minikernel.bin -L ~/Code/QEMU/pc-bios
Error: Failed to execute"qemu-system-x86_64" "-drive" "format=raw,file=target/minikernel/debug/bootimage-minikernel.bin" "-L ~/Code/QEMU/pc-bios"
: No such file or directory (os error 2)
Am I doing it the wrong way? Thanks!
The README lists bootloader.target
as a valid option.
[package.metadata.bootimage.bootloader]
name = "bootloader" # The bootloader crate name
version = "" # The bootloader version that should be used
git = "" # Use the bootloader from this git repository
branch = "" # The git branch to use (defaults to master)
path = "" # Use the bootloader from this local path
precompiled = false # Whether the bootloader crate is precompiled
target = "x86_64-bootloader" # Target triple for compiling the bootloader
Using the option causes an error.
$ bootimage build --target x86_64-rxinu
Error: Config("unexpected `package.metadata.bootimage.bootloader` key `target` with value `\"x86_64-bootloader\"`")
target
is not included as a valid key here: https://github.com/rust-osdev/bootimage/blob/master/src/config.rs#L58-L71
0.3 and i'm guessing 0.4 worked, but now
> bootimage build
Building kernel
Finished dev [unoptimized + debuginfo] target(s) in 0.05s
Error: Failed to build bootloader
Anything more I can do to help figure out what's wrong?
Currently the error message is just "No such file or directory (os error 2)" when QEMU isn't installed.
I think bootimage has some problems with the custom test runner on CLion/Rust plugin.
CLion can create a Cargo run configuration for tests. This creates the following cargo command:
C:/Programming/Rust/cargo/bin/cargo.exe test --color=always --no-fail-fast -- -Z unstable-options --format=json --show-output
Unfortunately, the arguments after --
are passed to qemu as is
Running: `qemu-system-x86_64 -drive format=raw,file=C:\dev\Workspace\gerrix\target\x86_64-blog_os\debug\deps\bootimage-gerrix-d6bdb98945edd169.bin -no-reboot -device isa-debug-exit,iobase=0xf4,iosize=0x04 -Z unstable-options --format=json --show-output`
qemu-system-x86_64: -Z: invalid option
Running the test via cargo test
works, though.
As the title says. Here is the program output (x64
is the name of my target JSON) when running cargo xrun
:
Finished dev [unoptimized + debuginfo] target(s) in 0.35s
Running `cargo bootimage runner target/x64/debug/test01`
Building kernel
Blocking waiting for file lock on x64's sysroot
.cargo/config
[build]
target = "x64.json"
[target.'cfg(target_os = "none")']
runner = "cargo bootimage runner"
Hello !
I didn't find this project on the Arch User Repository, so I decided to write a PKGBUILD for it. Is it fine if I publish it ?
Here it is :
# Maintainer: Absobel <[email protected]>
pkgname=cargo-bootimage-git
_pkgname=cargo-bootimage
pkgver=v0.10.3.12.g63b52fe
pkgrel=1
pkgdesc='Tool to create bootable disk images from a Rust OS kernel.'
arch=('x86_64')
url="https://github.com/rust-osdev/bootimage"
_git="https://github.com/rust-osdev/bootimage.git"
license=('MIT' 'Apache')
depends=()
makedepends=('git' 'cargo')
source=("${_pkgname}::git+${_git}")
sha256sums=('SKIP')
pkgver() {
cd "${_pkgname}"
git describe --tags | sed 's/-/./g'
}
prepare() {
cd "${_pkgname}"
export RUSTUP_TOOLCHAIN=stable
cargo update
cargo fetch --locked --target "$CARCH-unknown-linux-gnu"
}
build() {
cd "${_pkgname}"
export RUSTUP_TOOLCHAIN=stable
export CARGO_TARGET_DIR=target
cargo build --frozen --release --all-features
}
check() {
cd "${_pkgname}"
cargo test --frozen --all-features
}
package() {
cd "${_pkgname}"
install -Dm755 -t "${pkgdir}/usr/bin" \
target/release/cargo-bootimage \
target/release/bootimage
install -Dm644 Readme.md -t "${pkgdir}/usr/share/doc/${pkgname}"
install -Dm644 LICENSE-MIT -t "${pkgdir}/usr/share/licenses/${pkgname}"
install -Dm644 LICENSE-APACHE -t "${pkgdir}/usr/share/licenses/${pkgname}"
}
I run in an issue by the attempt to run example-kernels and hope to find help this way.
The cli cargo bootimage --target x86_64-bootimage-example-kernels.json
finished successfully, but cargo xrun
failed
✔ ~/git/github/rust-osdev/bootimage/example-kernels [master|✔]
14:47 $ git log --oneline -n1
d590098 (HEAD -> master, origin/master, origin/HEAD) CI: Use choco to install QEMU 6.0.0
✔ ~/git/github/rust-osdev/bootimage/example-kernels [master|✔]
14:47 $ cargo xrun --target x86_64-bootimage-example-kernels.json
WARNING: There is no root package to read the cargo-xbuild config from.
Compiling core v0.0.0 (/home/XXX/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core)
Compiling compiler_builtins v0.1.49
Compiling rustc-std-workspace-core v1.99.0 (/home/XXX/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/rustc-std-workspace-core)
error[E0465]: multiple rmeta candidates for `core` found
--> /home/XXX/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/rustc-std-workspace-core/lib.rs:4:9
|
4 | pub use core::*;
| ^^^^
|
note: candidate #1: /tmp/cargo-xbuild0mSUnk/target/x86_64-bootimage-example-kernels/release/deps/libcore-8386ca77507e6ddc.rmeta
--> /home/XXX/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/rustc-std-workspace-core/lib.rs:4:9
|
4 | pub use core::*;
| ^^^^
note: candidate #2: /tmp/cargo-xbuild0mSUnk/target/x86_64-bootimage-example-kernels/release/deps/libcore-cb62582e916e4b2a.rmeta
--> /home/XXX/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/rustc-std-workspace-core/lib.rs:4:9
|
4 | pub use core::*;
| ^^^^
error: could not compile `rustc-std-workspace-core` due to previous error
warning: build failed, waiting for other jobs to finish...
error: build failed
error: `"/home/XXX/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/bin/cargo" "rustc" "-p" "alloc" "--release" "--manifest-path" "/tmp/cargo-xbuild0mSUnk/Cargo.toml" "--target" "x86_64-bootimage-example-kernels.json" "--" "-Z" "force-unstable-if-unmarked"` failed with exit code: Some(101)
Running bootimage build --target x86_64-rxinu
with the following bootloader option fails to compile:
[package.metadata.bootimage.bootloader]
precompiled = false
There are 29 errors similar to the following:
Compiling bootloader v0.2.0-alpha-001 (file:///home/rob/.cargo/registry/src/github.com-1ecc6299db9ec823/bootloader-0.2.0-alpha-001)
error[E0432]: unresolved import `x86_64::structures::paging::PAGE_SIZE`
--> src/page_table.rs:3:34
|
3 | use x86_64::structures::paging::{PAGE_SIZE, PageTable, PageTableFlags, PageTableEntry, Page, PhysFrame};
| ^^^^^^^^^ no `PAGE_SIZE` in `structures::paging`
Building bootloader
Compiling bootloader v0.2.0-alpha-001 (file:///home/rob/.cargo/registry/src/github.com-1ecc6299db9ec823/bootloader-0.2.0-alpha-001)
error[E0432]: unresolved import `x86_64::structures::paging::PAGE_SIZE`
--> src/page_table.rs:3:34
|
3 | use x86_64::structures::paging::{PAGE_SIZE, PageTable, PageTableFlags, PageTableEntry, Page, PhysFrame};
| ^^^^^^^^^ no `PAGE_SIZE` in `structures::paging`
error[E0432]: unresolved import `x86_64::structures::paging::PAGE_SIZE`
--> src/frame_allocator.rs:2:34
|
2 | use x86_64::structures::paging::{PAGE_SIZE, PhysFrame};
| ^^^^^^^^^ no `PAGE_SIZE` in `structures::paging`
error[E0599]: no method named `sort_memory_map` found for type `os_bootinfo::BootInfo` in the current scope
--> src/main.rs:114:15
|
114 | boot_info.sort_memory_map();
| ^^^^^^^^^^^^^^^
error[E0599]: no method named `step_by` found for type `core::ops::Range<x86_64::VirtAddr>` in the current scope
--> src/page_table.rs:22:68
|
22 | let virt_page_iter = (stack_start..(stack_start + stack_size)).step_by(page_size);
| ^^^^^^^
|
= note: the method `step_by` exists but the following trait bounds were not satisfied:
`core::ops::Range<x86_64::VirtAddr> : core::iter::Iterator`
`&mut core::ops::Range<x86_64::VirtAddr> : core::iter::Iterator`
error[E0599]: no method named `set` found for type `&mut x86_64::structures::paging::PageTableEntry` in the current scope
--> src/page_table.rs:132:14
|
132 | p1_entry.set(phys_frame, flags);
| ^^^
error[E0599]: no method named `set` found for type `&mut x86_64::structures::paging::PageTableEntry` in the current scope
--> src/page_table.rs:106:28
|
106 | parent_table_entry.set(table_frame, PageTableFlags::PRESENT | PageTableFlags::WRITABLE);
| ^^^
error[E0308]: mismatched types
--> src/page_table.rs:114:13
|
114 | Some(frame) => unsafe { &mut *as_page_table_ptr(&frame) },
| ^^^^^^^^^^^ expected enum `core::result::Result`, found enum `core::option::Option`
|
= note: expected type `core::result::Result<x86_64::structures::paging::PhysFrame, x86_64::structures::paging::FrameError>`
found type `core::option::Option<_>`
error[E0308]: mismatched types
--> src/page_table.rs:115:13
|
115 | None => create_and_link_page_table(frame_allocator, page_table_entry)
| ^^^^ expected enum `core::result::Result`, found enum `core::option::Option`
|
= note: expected type `core::result::Result<x86_64::structures::paging::PhysFrame, x86_64::structures::paging::FrameError>`
found type `core::option::Option<_>`
error[E0609]: no field `start_addr` on type `&mut os_bootinfo::MemoryRegion`
--> src/frame_allocator.rs:14:23
|
14 | if region.start_addr < PhysAddr::new(1024 * 1024) {
| ^^^^^^^^^^
error[E0609]: no field `len` on type `&mut os_bootinfo::MemoryRegion`
--> src/frame_allocator.rs:21:23
|
21 | if region.len < page_size {
| ^^^
error[E0609]: no field `start_addr` on type `&mut os_bootinfo::MemoryRegion`
--> src/frame_allocator.rs:24:34
|
24 | assert_eq!(0, region.start_addr.as_u64() & 0xfff,
| ^^^^^^^^^^
error[E0609]: no field `start_addr` on type `&mut os_bootinfo::MemoryRegion`
--> src/frame_allocator.rs:27:63
|
27 | frame = Some(PhysFrame::containing_address(region.start_addr));
| ^^^^^^^^^^
error[E0609]: no field `start_addr` on type `&mut os_bootinfo::MemoryRegion`
--> src/frame_allocator.rs:28:20
|
28 | region.start_addr += page_size;
| ^^^^^^^^^^
error[E0560]: struct `os_bootinfo::MemoryRegion` has no field named `start_addr`
--> src/frame_allocator.rs:41:13
|
41 | start_addr: addr,
| ^^^^^^^^^^ `os_bootinfo::MemoryRegion` does not have this field
|
= note: available fields are: `range`, `region_type`
error[E0560]: struct `os_bootinfo::MemoryRegion` has no field named `len`
--> src/frame_allocator.rs:42:13
|
42 | len,
| ^^^ `os_bootinfo::MemoryRegion` does not have this field
|
= note: available fields are: `range`, `region_type`
error[E0609]: no field `start_addr` on type `&mut os_bootinfo::MemoryRegion`
--> src/frame_allocator.rs:49:39
|
49 | let region_start = region.start_addr;
| ^^^^^^^^^^
error[E0609]: no field `start_addr` on type `&mut os_bootinfo::MemoryRegion`
--> src/frame_allocator.rs:50:37
|
50 | let region_end = region.start_addr + region.len;
| ^^^^^^^^^^
error[E0609]: no field `len` on type `&mut os_bootinfo::MemoryRegion`
--> src/frame_allocator.rs:50:57
|
50 | let region_end = region.start_addr + region.len;
| ^^^
error[E0609]: no field `len` on type `&mut os_bootinfo::MemoryRegion`
--> src/frame_allocator.rs:61:28
|
61 | region.len = used_start - region_start;
| ^^^
error[E0560]: struct `os_bootinfo::MemoryRegion` has no field named `start_addr`
--> src/frame_allocator.rs:64:25
|
64 | start_addr: used_end,
| ^^^^^^^^^^ `os_bootinfo::MemoryRegion` does not have this field
|
= note: available fields are: `range`, `region_type`
error[E0560]: struct `os_bootinfo::MemoryRegion` has no field named `len`
--> src/frame_allocator.rs:65:25
|
65 | len: region_end - used_end,
| ^^^ `os_bootinfo::MemoryRegion` does not have this field
|
= note: available fields are: `range`, `region_type`
error[E0609]: no field `start_addr` on type `&mut os_bootinfo::MemoryRegion`
--> src/frame_allocator.rs:72:32
|
72 | region.start_addr = used_end;
| ^^^^^^^^^^
error[E0609]: no field `len` on type `&mut os_bootinfo::MemoryRegion`
--> src/frame_allocator.rs:77:28
|
77 | region.len = used_start - region_start;
| ^^^
error[E0609]: no field `start_addr` on type `&mut os_bootinfo::MemoryRegion`
--> src/frame_allocator.rs:84:32
|
84 | region.start_addr = used_region.start_addr;
| ^^^^^^^^^^
error[E0609]: no field `start_addr` on type `os_bootinfo::MemoryRegion`
--> src/frame_allocator.rs:84:57
|
84 | region.start_addr = used_region.start_addr;
| ^^^^^^^^^^ unknown field
|
= note: available fields are: `range`, `region_type`
error[E0609]: no field `len` on type `&mut os_bootinfo::MemoryRegion`
--> src/frame_allocator.rs:85:32
|
85 | region.len += used_region.len;
| ^^^
error[E0609]: no field `len` on type `os_bootinfo::MemoryRegion`
--> src/frame_allocator.rs:85:51
|
85 | region.len += used_region.len;
| ^^^ unknown field
|
= note: available fields are: `range`, `region_type`
error[E0609]: no field `len` on type `&mut os_bootinfo::MemoryRegion`
--> src/frame_allocator.rs:90:32
|
90 | region.len += used_region.len;
| ^^^
error[E0609]: no field `len` on type `os_bootinfo::MemoryRegion`
--> src/frame_allocator.rs:90:51
|
90 | region.len += used_region.len;
| ^^^ unknown field
|
= note: available fields are: `range`, `region_type`
error: aborting due to 29 previous errors
Some errors occurred: E0308, E0432, E0560, E0599, E0609.
For more information about an error, try `rustc --explain E0308`.
error: Could not compile `bootloader`.
It looks like cargo is trying to compile outdated x86_64
and os_bootinfo
crates. To confirm, I checked the contents of ~/.cargo/registry/src/github.com-1ecc6299db9ec823/bootloader-0.2.0-alpha-001/Cargo.toml
.
[dependencies.os_bootinfo]
version = "0.2.0-alpha"
[dependencies.x86_64]
version = "0.2.0-alpha-001"
Cross-referencing these versions with what is available on crates.io shows that these versions are not the latest versions.
x86_64
= 0.2.0-alpha-016
0.1.2
as latestos_bootinfo
= 0.2.0-alpha-011
0.1.0
as latestHello, I get an error when trying to install bootimage, this is the output after running the install command:
Updating crates.io index
Installing bootimage v0.9.0
error: failed to compile bootimage v0.9.0
, intermediate artifacts can be found at C:\Users\(username)\AppData\Local\Temp\cargo-install2oyY9G
Caused by:
-Zbuild-std requires --target
I tried passing in different targets but I don't get it to work, any help on this?
Bootloaders like GRUB have a config file that can be used to pass in boot time parameters that can be used by kernel to enable disable some features at boot time. Is there a way to pass boot time command line parameters to the kernel booted via bootimage?
If not, it would be a great feature addition. For example in my hobby OS, right now I am statically setting up some configs during compile time, it would be great if I keep that configurable at boot tine.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.