diff --git a/src/SUMMARY.md b/src/SUMMARY.md index b5fdac59..10d36277 100644 --- a/src/SUMMARY.md +++ b/src/SUMMARY.md @@ -237,6 +237,7 @@ - [Welcome](welcome-bare-metal.md) - [`no_std`](bare-metal/no_std.md) + - [A minimal example](bare-metal/minimal.md) - [`core`]() - [`alloc`]() - [Microcontrollers]() diff --git a/src/bare-metal/minimal.md b/src/bare-metal/minimal.md new file mode 100644 index 00000000..8e58984c --- /dev/null +++ b/src/bare-metal/minimal.md @@ -0,0 +1,22 @@ +# A minimal `no_std` program + +```rust,editable +#![no_main] +#![no_std] + +use core::panic::PanicInfo; + +#[panic_handler] +fn panic(_panic: &PanicInfo<'_>) -> ! { + loop {} +} +``` + +
+ +* This will compile to an empty binary. +* `std` provides a panic handler; without it we must provide our own. +* Depending on the target, you may need to compile with `panic = "abort"` to avoid an error about + `eh_personality`. + +