Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue parsing Cargo.toml #95

Open
largenumberhere opened this issue Nov 16, 2024 · 7 comments
Open

Issue parsing Cargo.toml #95

largenumberhere opened this issue Nov 16, 2024 · 7 comments

Comments

@largenumberhere
Copy link

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.

@Freax13
Copy link
Member

Freax13 commented Nov 16, 2024

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

@largenumberhere
Copy link
Author

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

@Freax13
Copy link
Member

Freax13 commented Nov 16, 2024

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

@largenumberhere
Copy link
Author

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

@Freax13
Copy link
Member

Freax13 commented Nov 16, 2024

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.

@largenumberhere
Copy link
Author

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

@Freax13
Copy link
Member

Freax13 commented Nov 22, 2024

Feel free to open a PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants