Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ctron/esp-idf-alloc
Rust allocator for ESP-IDF
https://github.com/ctron/esp-idf-alloc
alloc embedded esp esp32 rust
Last synced: about 1 month ago
JSON representation
Rust allocator for ESP-IDF
- Host: GitHub
- URL: https://github.com/ctron/esp-idf-alloc
- Owner: ctron
- License: epl-2.0
- Created: 2019-06-25T21:38:00.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2019-06-28T20:36:13.000Z (over 5 years ago)
- Last Synced: 2024-09-30T09:22:02.402Z (about 1 month ago)
- Topics: alloc, embedded, esp, esp32, rust
- Language: Rust
- Size: 13.7 KB
- Stars: 10
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Rust allocator, backed by ESP-IDF [![Crates.io](https://img.shields.io/crates/v/esp-idf-alloc.svg)](https://crates.io/crates/esp-idf-alloc)
This is a memory allocator for Rust, backed by the [ESP-IDF](https://docs.espressif.com/projects/esp-idf/en/latest/).
This is intended to be used on an ESP32, linked against the ESP-IDF. For more information see:
* https://github.com/ctron/rust-esp-container/
* https://github.com/ctron/rust-esp-template
* https://github.com/MabezDev/rust-xtensa.git
* https://quickhack.net/nom/blog/2019-05-14-build-rust-environment-for-esp32.html## Usage
Add the following to your main, application project:
~~~rust
extern crate esp_idf_alloc;#[global_allocator]
static A: esp_idf_alloc::EspIdfAllocator = esp_idf_alloc::EspIdfAllocator;
~~~### Error handler
If you use a custom global allocator in your application, you will also need an error handler.
The following code will use the ESP-IDF `abort()` method to handle the error:
~~~rust
#![feature(alloc_error_handler)]use core::alloc::Layout;
extern "C" {
fn abort() -> !;
}#[alloc_error_handler]
fn alloc_error(_layout: Layout) -> ! {
unsafe {
abort();
}
}
~~~## Using with `alloc`
Also be sure to link in the `alloc` create, as you might want this. Add the following to your `Xargo.toml`:
~~~toml
[target.xtensa-esp32-none-elf.dependencies]
alloc={}
~~~