14 releases
0.2.14 | Nov 5, 2022 |
---|---|
0.2.13 | Nov 5, 2022 |
0.2.10 | Oct 22, 2022 |
0.1.5 | Oct 3, 2022 |
#9 in #flipper-zero
36 downloads per month
Used in flipper0
3.5MB
101K
SLoC
Bindings for Flipper Zero
Automatically generated bindings (or "externs") for Flipper Zero Fw with some little hand-crafted wrappers and additions as upper abstraction layer.
This can be built with:
- without Flipper fw sources using default feature
prebuild
- with modified fw using feature
use-local-sdk
- with enabled feature
use-remote-sdk
official fw will be downloaded, then build as withuse-local-sdk
feature.
Compatibility
Minimal supported version:
Latest supported version can be determined by git tags starting with fw-
.
Prerequisites
- Rust toolchain,
nightly
- target
thumbv7em-none-eabihf
libclang
for bindgen- clone of Flipper Zero firmware (optional)
- ARM toolchain, run
fbt
to easily get it (optional)
For build using pre-generated bindings (prebuild
feature) just Rust toolchain is required, nightly channel.
For build using non-modified official fw just Rust toolchain and firmware sources are required.
For other cases see documentation and examples.
Hello-world
Just add dependency to your cargo manifest file:
[dependencies]
flipper0-sys = "*"
And follow instructions for examples.
#![crate_type = "staticlib"] #![no_main] #![no_std]
extern crate flipper0_sys;
use flipper0_sys::ffi::*;
#[no_mangle]
pub unsafe extern "C" fn init(_: *mut u8) -> i32 {
static MESSAGE: &[u8] = b"Hello, World!";
furi_thread_stdout_write(MESSAGE.as_ptr() as _, MESSAGE.len());
0
}
Features:
allocator
: include allocator implementationallocator-global
: default, include global allocator implementationoom-global
: default, out-of-mem handler. Disable it to use you custom handler or#![feature(default_alloc_error_handler)]
.panic
: default, include global panic & OoM handlermacro
: include#[main]
macro for FAP entry point.
Bindings gen customization features:
Can be used with use-local-sdk
or use-remote-sdk
features.
derive-default
derive-eq
derive-copy
derive-hash
derive-ord
derive-partialeq
derive-partialord
derive-debug
- deriveDebug
, enabled by default for debug profile
All of these derive-
features are used for bindgen configuration.
Build methods features:
By default prebuild
is turned on. It uses pre-generated bindings, so fw not needed.
Feature | Default | Description | Used ENV vars |
---|---|---|---|
prebuild |
+ | use pre-generated bindings | |
use-local-sdk |
+ | look at FLIPPER_FW_SRC_PATH , build from source |
FLIPPER_FW_SRC_PATH (required), ARM_TOOLCHAIN (optional) |
use-remote-sdk |
- | clone remote git repo, initial setup with fbt, then build from source. | FLIPPER_REPO_REV , FLIPPER_REPO_BRANCH , FLIPPER_REPO_CLONE_PATH , ARM_TOOLCHAIN (all vars optional) |
Dependencies
~1.5–5.5MB
~98K SLoC