#![no_std] #![no_main] extern crate alloc; use alloc::vec::Vec; use core::panic::PanicInfo; use cortex_m_rt::entry; // Linked-List First Fit Heap allocator (feature = "llff") use embedded_alloc::LlffHeap as Heap; // Two-Level Segregated Fit Heap allocator (feature = "tlsf") // use embedded_alloc::TlsfHeap as Heap; #[global_allocator] static HEAP: Heap = Heap::empty(); #[entry] fn main() -> ! { // Initialize the allocator BEFORE you use it { use core::mem::MaybeUninit; const HEAP_SIZE: usize = 1024; static mut HEAP_MEM: [MaybeUninit; HEAP_SIZE] = [MaybeUninit::uninit(); HEAP_SIZE]; unsafe { HEAP.init(HEAP_MEM.as_ptr() as usize, HEAP_SIZE) } } let mut xs = Vec::new(); xs.push(1); #[allow(clippy::empty_loop)] loop { /* .. */ } } #[panic_handler] fn panic(_: &PanicInfo) -> ! { loop {} }