bootimage icon indicating copy to clipboard operation
bootimage copied to clipboard

Issue parsing Cargo.toml

Open largenumberhere opened this issue 1 year ago • 7 comments

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.

largenumberhere avatar Nov 16 '24 04:11 largenumberhere

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).

Freax13 avatar Nov 16 '24 11:11 Freax13

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).

Thanks for the suggestion, I gave that a go but the error still persists

largenumberhere avatar Nov 16 '24 12:11 largenumberhere

My bad, you actually need to downgrade bootloader to 0.9.

Freax13 avatar Nov 16 '24 13:11 Freax13

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))

largenumberhere avatar Nov 16 '24 13:11 largenumberhere

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.

Freax13 avatar Nov 16 '24 13:11 Freax13

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.

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

largenumberhere avatar Nov 17 '24 05:11 largenumberhere

Feel free to open a PR.

Freax13 avatar Nov 22 '24 07:11 Freax13