#![no_std] problem

#1

I want to try Rust on STM32 microcontroller. The compiler is rust-1.33 stable. I use #![no_std], and the error:

error: language item required, but not found: eh_personality
error: aborting due to previous error
error: Could not compile blink.

Here is a x86 test code, which writes the same error:

#![no_std]

use core::panic::PanicInfo;
#[panic_handler]
pub fn panic(_panicinfo: &PanicInfo) -> !{
loop {}
}

fn main() {
}

How can I avoid this error?

#2

Put this in Cargo.toml:

[profile.dev]
panic = "abort"

[profile.release]
panic = "abort"

Read about it here https://os.phil-opp.com/freestanding-rust-binary/

1 Like
#3

You may also want to check out The Embedded Book or the older Discovery guide.

Both resources go through the various requirements that a #[no_std] application have and ways they’ve already been solved by the ecosystem.