How to Write a Bare-Metal Rust Application

Create a no_std project with a panic handler and a no_mangle entry point to run Rust directly on hardware.

To write a bare-metal Rust application, create a project with no_std, define a #[panic_handler], and implement a #[no_mangle] entry point that loops infinitely.

#![no_std]
#![no_main]

use core::panic::PanicInfo;

#[panic_handler]
fn panic(_info: &PanicInfo) -> ! {
    loop {}
}

#[no_mangle]
pub extern "C" fn _start() -> ! {
    loop {}
}

Add panic = "abort" to your Cargo.toml under [profile.dev] and [profile.release] to avoid linking the unwinder.