Issue parsing Cargo.toml
Here's the error
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)
Here's my Cargo.toml
#cargo-features = ["per-package-target"]
[package.metadata.bootloader]
target = "x86_64-unknown-none"
[package]
name = "iron"
version = "0.1.0"
edition = "2021"
rust-version = "1.78.0"
[dependencies]
[profile.dev]
panic = "abort"
[profile.release]
panic = "abort"
[dev-dependencies]
bootloader = {version="0.11.8"}
main.rs:
#![no_std]
#![no_main]
// pub use core as core;
use core::panic::PanicInfo;
#[panic_handler]
fn panic(_: &PanicInfo) -> ! {
loop {}
}
#[no_mangle]
fn _start() -> ! {
loop {}
}
// #[no_mangle]
// fn entry_32_bit() -> ! {
// loop {}
// }
I've tried downgrading bootloader to various versions, I've tried changing the tag in various ways, I've tried instead
[dev-dependencies]
bootloader = {version="0.11.8", target="x86_64-unkown-none"}
Nothing has worked, I don't understand what the error message is telling me to do. I'm trying to follow the "Writing an OS in rust" tutorial. It has worked for me without issue in the past, I have no idea why things are breaking in bizarre ways this time.
Please let me know how to proceed, thanks.
Try putting bootloader in the normal dependencies section, not dev-dependencies. You'll also need to downgrade its version to 0.10 (0.11 doesn't work with bootimage).
Try putting
bootloaderin the normaldependenciessection, notdev-dependencies. You'll also need to downgrade its version to 0.10 (0.11 doesn't work with bootimage).
Thanks for the suggestion, I gave that a go but the error still persists
My bad, you actually need to downgrade bootloader to 0.9.
My bad, you actually need to downgrade bootloader to 0.9. Okay, so 0.9 does build the kernel but now I get a panic at runtime in qemu. (Typed out from the window)
panicked at src\page_table.rs:105:25 failed to map segment starting at Page[4KiB](0x1000): failed to map page Page[4KiB](0x1000) to frame PhysFrame[4KiB](0x400000): PageAlreadyMapped(PhysFrame[4KiB](0x400000))
Don't use x86_64-unknown-none, use your own target. It might also be possible to set -C relocation-model=static in RUSTFLAGS instead.
Don't use
x86_64-unknown-none, use your own target. It might also be possible to set-C relocation-model=staticin RUSTFLAGS instead.
Using a custom target seems to have fixed the issue. Thank you. If possible, I think some assertions should be added to give nicer warnings or errors for these edge cases
Feel free to open a PR.