#heap-allocator #mips #allocator #pic32 #heap-memory #memory-management #no-std

nightly no-std mips-mcu-alloc

A heap allocator for MIPS based microcontrollers

4 releases

0.6.2 Feb 4, 2024
0.6.1 Jun 29, 2023
0.6.0 Jun 9, 2023
0.5.0 Sep 26, 2022

#1424 in Embedded development

25 downloads per month

MIT/Apache

98KB
1.5K SLoC

GNU Style Assembly 1K SLoC // 0.1% comments Alex 434 SLoC Rust 261 SLoC // 0.0% comments Python 2 SLoC // 1.0% comments

mips-mcu-alloc

Crates.io docs.rs

A heap allocator for PIC32 microcontrollers (based on the alloc-cortex-m crate)

The heap is placed at a location determined by the linker and automatically extended to fullfil allocation requests. Automatic heap extension fails if the heap would collide with the stack.

Memory allocation and heap extension can be traced via logging by activating the log feature.

Example:

#![feature(global_allocator)]
#![feature(alloc_error_handler)]

// Plug in the allocator crate
extern crate alloc;
use alloc::Vec;
use mips_mcu_alloc::MipsMcuHeap;

#[global_allocator]
static ALLOCATOR: MipsMcuHeap = MipsMcuHeap::empty();

#[entry]
fn main() -> ! {
    ALLOCATOR.init();
    let mut xs = Vec::new();
    xs.push(1);
    loop { /* .. */ }
}

#[alloc_error_handler]
fn alloc_error(layout: core::alloc::Layout) -> ! {
    panic!("Cannot allocate heap memory: {:?}", layout);
}

License

Licensed under either of

at your option.

Dependencies

~0.4–0.9MB
~20K SLoC