Quick flipper-zero test app

This commit is contained in:
Savanni D'Gerinel 2023-10-29 12:28:27 -04:00
parent 48113d6ccb
commit a9a552684b
12 changed files with 433 additions and 1 deletions

86
Cargo.lock generated
View File

@ -861,6 +861,56 @@ dependencies = [
"miniz_oxide 0.7.1", "miniz_oxide 0.7.1",
] ]
[[package]]
name = "flipperzero"
version = "0.11.0"
source = "git+https://github.com/flipperzero-rs/flipperzero.git#2d9ef4a23f4e055ad6489a406d250d61d24b996f"
dependencies = [
"bitflags 1.3.2",
"digest",
"flipperzero-sys",
"flipperzero-test",
"lock_api",
"rand_core 0.6.4",
"ufmt",
]
[[package]]
name = "flipperzero-rt"
version = "0.11.0"
source = "git+https://github.com/flipperzero-rs/flipperzero.git#2d9ef4a23f4e055ad6489a406d250d61d24b996f"
dependencies = [
"flipperzero-sys",
]
[[package]]
name = "flipperzero-sys"
version = "0.11.0"
source = "git+https://github.com/flipperzero-rs/flipperzero.git#2d9ef4a23f4e055ad6489a406d250d61d24b996f"
dependencies = [
"ufmt",
]
[[package]]
name = "flipperzero-test"
version = "0.11.0"
source = "git+https://github.com/flipperzero-rs/flipperzero.git#2d9ef4a23f4e055ad6489a406d250d61d24b996f"
dependencies = [
"flipperzero-sys",
"flipperzero-test-macros",
"ufmt",
]
[[package]]
name = "flipperzero-test-macros"
version = "0.11.0"
source = "git+https://github.com/flipperzero-rs/flipperzero.git#2d9ef4a23f4e055ad6489a406d250d61d24b996f"
dependencies = [
"proc-macro2",
"quote",
"syn 1.0.109",
]
[[package]] [[package]]
name = "fluent" name = "fluent"
version = "0.16.0" version = "0.16.0"
@ -2266,6 +2316,15 @@ dependencies = [
"version_check 0.9.4", "version_check 0.9.4",
] ]
[[package]]
name = "my-project"
version = "0.1.0"
dependencies = [
"flipperzero",
"flipperzero-rt",
"flipperzero-sys",
]
[[package]] [[package]]
name = "native-tls" name = "native-tls"
version = "0.2.11" version = "0.2.11"
@ -4141,6 +4200,33 @@ dependencies = [
"syn 1.0.109", "syn 1.0.109",
] ]
[[package]]
name = "ufmt"
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1a64846ec02b57e9108d6469d98d1648782ad6bb150a95a9baac26900bbeab9d"
dependencies = [
"ufmt-macros",
"ufmt-write",
]
[[package]]
name = "ufmt-macros"
version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d337d3be617449165cb4633c8dece429afd83f84051024079f97ad32a9663716"
dependencies = [
"proc-macro2",
"quote",
"syn 1.0.109",
]
[[package]]
name = "ufmt-write"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e87a2ed6b42ec5e28cc3b94c09982969e9227600b2e3dcbc1db927a84c06bd69"
[[package]] [[package]]
name = "unarray" name = "unarray"
version = "0.1.4" version = "0.1.4"

View File

@ -8,6 +8,7 @@ members = [
"dashboard", "dashboard",
"emseries", "emseries",
"file-service", "file-service",
"flipper-zero",
"fluent-ergonomics", "fluent-ergonomics",
"geo-types", "geo-types",
"gm-control-panel", "gm-control-panel",

View File

@ -0,0 +1,23 @@
[target.thumbv7em-none-eabihf]
rustflags = [
# CPU is Cortex-M4 (STM32WB55)
"-C", "target-cpu=cortex-m4",
# Size optimizations
"-C", "panic=abort",
"-C", "debuginfo=0",
"-C", "opt-level=z",
# LTO helps reduce binary size
"-C", "embed-bitcode=yes",
"-C", "lto=yes",
# Linker flags for relocatable binary
"-C", "link-args=--script=flipperzero-rt.ld --Bstatic --relocatable --discard-all --strip-all --lto-O3 --lto-whole-program-visibility",
# Required to link with `lld`
"-Z", "no-unique-section-names=yes",
]
[build]
target = "thumbv7em-none-eabihf"

6
flipper-zero/.gitignore vendored Normal file
View File

@ -0,0 +1,6 @@
# Generated by Cargo
# will have compiled files and executables
/target
# These are backup files generated by rustfmt
**/*.rs.bk

214
flipper-zero/Cargo.lock generated Normal file
View File

@ -0,0 +1,214 @@
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
version = 3
[[package]]
name = "autocfg"
version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa"
[[package]]
name = "bitflags"
version = "1.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a"
[[package]]
name = "block-buffer"
version = "0.10.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3078c7629b62d3f0439517fa394996acacc5cbc91c5a20d8c658e77abd503a71"
dependencies = [
"generic-array",
]
[[package]]
name = "crypto-common"
version = "0.1.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3"
dependencies = [
"generic-array",
"typenum",
]
[[package]]
name = "digest"
version = "0.10.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292"
dependencies = [
"block-buffer",
"crypto-common",
]
[[package]]
name = "flipperzero"
version = "0.11.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3380d6c3367774a275a79a5e914878828be697bdc099769507cd8757b4b28749"
dependencies = [
"bitflags",
"digest",
"flipperzero-sys",
"flipperzero-test",
"lock_api",
"rand_core",
"ufmt",
]
[[package]]
name = "flipperzero-rt"
version = "0.11.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e86417901345f40afd691706c8f34bde52cbe111d6fd517fb28465bd2e3e681f"
dependencies = [
"flipperzero-sys",
]
[[package]]
name = "flipperzero-sys"
version = "0.11.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ab88bf1a72204a89320d3ac60a39890a0112443b520cb9bbf560a128c3830acb"
dependencies = [
"ufmt",
]
[[package]]
name = "flipperzero-test"
version = "0.11.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8e3cb46bb9aa07d65662c4a3c60717cdedd19a7f4c55e5888ce83c2126786cda"
dependencies = [
"flipperzero-sys",
"flipperzero-test-macros",
"ufmt",
]
[[package]]
name = "flipperzero-test-macros"
version = "0.11.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3c93395d56046aa6c1bb8f18b38cb3bc56223e9fd5b5f8e9e885d14f422c9869"
dependencies = [
"proc-macro2",
"quote",
"syn",
]
[[package]]
name = "generic-array"
version = "0.14.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a"
dependencies = [
"typenum",
"version_check",
]
[[package]]
name = "lock_api"
version = "0.4.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c1cc9717a20b1bb222f333e6a92fd32f7d8a18ddc5a3191a11af45dcbf4dcd16"
dependencies = [
"autocfg",
"scopeguard",
]
[[package]]
name = "proc-macro2"
version = "1.0.66"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "18fb31db3f9bddb2ea821cde30a9f70117e3f119938b5ee630b7403aa6e2ead9"
dependencies = [
"unicode-ident",
]
[[package]]
name = "quote"
version = "1.0.33"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5267fca4496028628a95160fc423a33e8b2e6af8a5302579e322e4b520293cae"
dependencies = [
"proc-macro2",
]
[[package]]
name = "rand_core"
version = "0.6.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c"
[[package]]
name = "scopeguard"
version = "1.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49"
[[package]]
name = "syn"
version = "1.0.109"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237"
dependencies = [
"proc-macro2",
"quote",
"unicode-ident",
]
[[package]]
name = "hello-rust"
version = "0.1.0"
dependencies = [
"flipperzero",
"flipperzero-rt",
"flipperzero-sys",
]
[[package]]
name = "typenum"
version = "1.16.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "497961ef93d974e23eb6f433eb5fe1b7930b659f06d12dec6fc44a8f554c0bba"
[[package]]
name = "ufmt"
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1a64846ec02b57e9108d6469d98d1648782ad6bb150a95a9baac26900bbeab9d"
dependencies = [
"ufmt-macros",
"ufmt-write",
]
[[package]]
name = "ufmt-macros"
version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d337d3be617449165cb4633c8dece429afd83f84051024079f97ad32a9663716"
dependencies = [
"proc-macro2",
"quote",
"syn",
]
[[package]]
name = "ufmt-write"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e87a2ed6b42ec5e28cc3b94c09982969e9227600b2e3dcbc1db927a84c06bd69"
[[package]]
name = "unicode-ident"
version = "1.0.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "301abaae475aa91687eb82514b328ab47a211a533026cb25fc3e519b86adfc3c"
[[package]]
name = "version_check"
version = "0.9.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f"

22
flipper-zero/Cargo.toml Normal file
View File

@ -0,0 +1,22 @@
cargo-features = ["different-binary-name"]
[package]
name = "my-project"
version = "0.1.0"
edition = "2021"
rust-version = "1.64.0"
autobins = false
autoexamples = false
autotests = false
autobenches = false
[[bin]]
name = "my-project"
filename = "my-project.fap"
bench = false
test = false
[dependencies]
flipperzero = { git = "https://github.com/flipperzero-rs/flipperzero.git" }
flipperzero-sys = { git = "https://github.com/flipperzero-rs/flipperzero.git" }
flipperzero-rt = { git = "https://github.com/flipperzero-rs/flipperzero.git" }

47
flipper-zero/README.md Normal file
View File

@ -0,0 +1,47 @@
# `flipperzero-template`🚀
A template for kick-starting a Rust + FlipperZero project using [`flipperzero-rs`](https://github.com/flipperzero-rs/flipperzero) 🐬❤️🦀.
Currently supports SDK 35.0 ([flipperzero-firmware@0.89.0](https://github.com/flipperdevices/flipperzero-firmware/tree/0.89.0)).
# Usage
## Initial setup
1. Install [`rustup`](https://rust-lang.github.io/rustup/) by following the instructions on [`rustup.rs`](https://rustup.rs/).
1. Install the nightly build tool-chain to support the[`different-binary-name`](https://doc.rust-lang.org/cargo/reference/unstable.html#different-binary-name) feature:
```
rustup toolchain install nightly
```
1. Install [`cargo-generate`](https://github.com/cargo-generate/cargo-generate):
```
cargo install cargo-generate
```
1. Use `rustup` to install the `thumbv7em-none-eabihf` target to the nightly build:
```
rustup target add --toolchain nightly thumbv7em-none-eabihf
```
## Generate the project
1. Use `cargo generate` to clone this template:
```
cargo generate --git https://github.com/flipperzero-rs/flipperzero-template.git --name my-project
```
1. Switch into the local directory:
```
cd my-project
```
## Build with `cargo build`
```
cargo build
```
## Copy the binary to your Flipper Zero
The resulting `.fap` binary can be found in [`target/thumbv7em-none-eabihf/debug`](target/thumbv7em-none-eabihf/debug).
# License
This template is licensed under the [MIT License](https://github.com/flipperzero-rs/flipperzero/blob/v0.7.2/LICENSE).

View File

@ -0,0 +1,3 @@
[toolchain]
channel = "nightly"
targets = [ "thumbv7em-none-eabihf" ]

30
flipper-zero/src/main.rs Normal file
View File

@ -0,0 +1,30 @@
//! Template project for Flipper Zero.
//! This app prints "Hello, Rust!" to the console then exits.
#![no_main]
#![no_std]
// Required for panic handler
extern crate flipperzero_rt;
use flipperzero::println;
use flipperzero_rt::{entry, manifest};
// Define the FAP Manifest for this application
manifest!(
name = "Flipper Zero Rust",
app_version = 1,
has_icon = true,
// See https://github.com/flipperzero-rs/flipperzero/blob/v0.7.2/docs/icons.md for icon format
icon = "rustacean-10x10.icon",
);
// Define the entry function
entry!(main);
// Entry point
fn main(_args: *mut u8) -> i32 {
println!("Hello, Rust!");
0
}

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 159 B

View File

@ -1,3 +1,3 @@
[toolchain] [toolchain]
channel = "1.71.1" channel = "1.71.1"
targets = [ "wasm32-unknown-unknown" ] targets = [ "wasm32-unknown-unknown", "thumbv7em-none-eabihf" ]