Move acid-firmware into its own subfolder of the cargo workspace, and
some other improvements
This commit is contained in:
parent
810f21827b
commit
16ed51b19e
|
|
@ -1,44 +0,0 @@
|
|||
[target.'cfg(all(any(target_arch = "riscv32", target_arch = "xtensa"), target_os = "none"))']
|
||||
runner = "espflash flash --monitor"
|
||||
# runner = "probe-rs run --chip esp32s3 --preverify"
|
||||
|
||||
[build]
|
||||
target = "xtensa-esp32s3-none-elf"
|
||||
rustflags = [
|
||||
# Required to obtain backtraces (e.g. when using the "esp-backtrace" crate.)
|
||||
# NOTE: May negatively impact performance of produced code
|
||||
"-C", "force-frame-pointers",
|
||||
]
|
||||
|
||||
|
||||
[env]
|
||||
LIBXKBCOMMON_BUILD_DIR = "libxkbcommon/build"
|
||||
SPECTRE_API_BUILD_DIR = "spectre-api/build"
|
||||
SPECTRE_API_SYS_CC = "xtensa-esp32s3-elf-cc.exe"
|
||||
ESP_LOG = "warn"
|
||||
ESP_BACKTRACE_CONFIG_BACKTRACE_FRAMES = "20"
|
||||
# This is overkill, but we can afford it.
|
||||
SLINT_FONT_SIZES = "8,11,10,12,13,14,15,16,18,20,22,24,32"
|
||||
|
||||
# Xtensa only:
|
||||
# Needed for nightly, until llvm upstream has support for Rust Xtensa.
|
||||
# TODO: RE-ENABLE WHEN acid-firmware IS MOVED TO ITS OWN SUBDIRECTORY.
|
||||
# For now, `-Zbuild-std="core,alloc"` can be used instead.
|
||||
[unstable]
|
||||
build-std = ["alloc", "core"]
|
||||
|
||||
[patch."https://github.com/Limeth/spectre-api-sys"]
|
||||
spectre-api-sys = { path = "../../../rust/spectre-api-sys" }
|
||||
|
||||
[patch.crates-io]
|
||||
rmk = { path = "../../../rust/rmk/rmk" }
|
||||
xkbcommon = { path = "../../../rust/xkbcommon-rs-ffi" }
|
||||
scrypt = { path = "../../../rust/password-hashes/scrypt" }
|
||||
# esp-backtrace = { path = "../../../rust/esp-hal/esp-backtrace" }
|
||||
# esp-hal = { path = "../../../rust/esp-hal/esp-hal" }
|
||||
# esp-storage = { path = "../../../rust/esp-hal/esp-storage" }
|
||||
# esp-alloc = { path = "../../../rust/esp-hal/esp-alloc" }
|
||||
# esp-println = { path = "../../../rust/esp-hal/esp-println" }
|
||||
# esp-radio = { path = "../../../rust/esp-hal/esp-radio" }
|
||||
# esp-rtos = { path = "../../../rust/esp-hal/esp-rtos" }
|
||||
# esp-bootloader-esp-idf = { path = "../../../rust/esp-hal/esp-bootloader-esp-idf" }
|
||||
1
firmware/.gitignore
vendored
Normal file
1
firmware/.gitignore
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
/.cargo
|
||||
4
firmware/Cargo.lock
generated
4
firmware/Cargo.lock
generated
|
|
@ -5688,9 +5688,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "proc-macro2"
|
||||
version = "1.0.105"
|
||||
version = "1.0.106"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "535d180e0ecab6268a3e718bb9fd44db66bbbc256257165fc699dadf70d16fe7"
|
||||
checksum = "8fd00f0bb2e90d81d1044c2b32617f68fcb9fa3bb7640c23e9c748e53fb30934"
|
||||
dependencies = [
|
||||
"unicode-ident",
|
||||
]
|
||||
|
|
|
|||
|
|
@ -1,123 +1,3 @@
|
|||
[workspace]
|
||||
resolver = "3"
|
||||
members = ["password-hash"]
|
||||
|
||||
[package]
|
||||
name = "acid-firmware"
|
||||
version = "0.1.0"
|
||||
authors = ['Jakub "Limeth" Hlusička']
|
||||
description = "Firmware for the ACID keyboard"
|
||||
homepage = "https://github.com/haobogu/rmk"
|
||||
repository = "https://github.com/haobogu/rmk"
|
||||
edition = "2024"
|
||||
|
||||
[features]
|
||||
default = ["usb-log", "limit-fps"]
|
||||
# Make RMK not to use USB
|
||||
no-usb = ["rmk/_no_usb"]
|
||||
# Let RMK use BLE
|
||||
ble = ["rmk/esp32s3_ble"]
|
||||
# Use alternative logging via GPIO5 as RX and GPIO12 as TX.
|
||||
# Disables default logging via USB.
|
||||
# Does not support esp-println's `println!`.
|
||||
alt-log = []
|
||||
# Standard logging implementation over USB.
|
||||
usb-log = ["esp-backtrace/panic-handler"]
|
||||
# RTT (+ logging) for probe-rs
|
||||
rtt-log = ["dep:rtt-target", "dep:panic-rtt-target"]
|
||||
# Block the main core while it is driving the LCD.
|
||||
# This prevents the main core from accessing PSRAM while the LCD is being driven,
|
||||
# which causes the LCD to glitch. To prevent the main core from spending all its
|
||||
# execution time on just driving the LCD, it will be limited.
|
||||
limit-fps = []
|
||||
# Development profiles
|
||||
develop = ["limit-fps", "alt-log"]
|
||||
develop-usb = ["limit-fps", "usb-log", "no-usb", "ble"]
|
||||
probe = ["limit-fps", "rtt-log", "no-usb", "ble"]
|
||||
|
||||
[dependencies]
|
||||
rmk = { version = "0.8.2", default-features = false, features = [
|
||||
"log",
|
||||
"storage",
|
||||
"vial",
|
||||
"controller",
|
||||
] }
|
||||
embassy-executor = { version = "0.9", features = ["log"] }
|
||||
embassy-time = { version = "0.5.0", features = ["log"] }
|
||||
embassy-embedded-hal = "0.5.0"
|
||||
embassy-sync = { version = "0.7.2", features = ["log"] }
|
||||
esp-backtrace = { version = "0.18", default-features = false, features = [
|
||||
"esp32s3",
|
||||
"println",
|
||||
] }
|
||||
esp-hal = { version = "1.0", features = ["esp32s3", "unstable", "psram", "log-04"] }
|
||||
esp-storage = { version = "0.8.0", features = ["esp32s3"] }
|
||||
esp-alloc = { version = "0.9.0", features = ["nightly"] }
|
||||
esp-println = { version = "0.16.0", features = ["esp32s3", "log-04"] }
|
||||
esp-radio = { version = "0.17", features = ["esp32s3", "unstable", "ble"] }
|
||||
esp-rtos = { version = "0.2", features = ["esp32s3", "esp-radio", "embassy"] }
|
||||
esp-bootloader-esp-idf = { version = "0.4", features = ["esp32s3", "log-04"] }
|
||||
bt-hci = { version = "0.6" }
|
||||
rand_core = { version = "0.6", default-features = false }
|
||||
static_cell = "2"
|
||||
lazy_static = { version = "1.5.0", features = ["spin_no_std"], default-features = false }
|
||||
log = "0.4.29"
|
||||
bitflags = "2.10.0"
|
||||
paste = "1.0.15"
|
||||
itertools = { version = "0.14.0", default-features = false }
|
||||
bytemuck = "1.24.0"
|
||||
slint = { version = "1.14.1", default-features = false, features = ["compat-1-2", "libm", "log", "unsafe-single-threaded", "renderer-software"]}
|
||||
i-slint-common = "1.14.1"
|
||||
critical-section = "1.2.0"
|
||||
cfg-if = "1.0.4"
|
||||
xkbcommon = { git = "https://github.com/Limeth/xkbcommon-rs", branch = "esp32s3", default-features = false, features = ["c-lib-wrap"] }
|
||||
rtt-target = { version = "0.6.2", features = ["log"], optional = true }
|
||||
panic-rtt-target = { version = "0.2.0", optional = true }
|
||||
enumset = "1.1.10"
|
||||
printf-compat = { version = "0.2.1", default-features = false }
|
||||
spectre-api-sys = { git = "https://github.com/Limeth/spectre-api-sys" }
|
||||
sha2 = { version = "0.10.9", default-features = false }
|
||||
password-hash = { path = "password-hash", default-features = false }
|
||||
hmac = "0.12.1"
|
||||
|
||||
# Crates for serial UART CLI
|
||||
embedded-cli = { version = "0.2.1", default-features = false, features = ["help", "macros"] }
|
||||
embedded-io = "0.6.1"
|
||||
mutually_exclusive_features = "0.1.0"
|
||||
|
||||
[build-dependencies]
|
||||
xz2 = "0.1.7"
|
||||
json = "0.12"
|
||||
const-gen = "1.6"
|
||||
embuild = "0.33"
|
||||
cc = "1.2.9"
|
||||
slint-build = "1.14.1"
|
||||
gix = { version = "0.76.0", default-features = false, features = ["max-performance", "status"] }
|
||||
indoc = "2.0.7"
|
||||
|
||||
[[bin]]
|
||||
name = "acid-firmware"
|
||||
test = false
|
||||
bench = false
|
||||
|
||||
[profile.release-with-debug]
|
||||
inherits = "release"
|
||||
debug = true
|
||||
|
||||
|
||||
[profile.dev.package.esp-storage]
|
||||
opt-level = 3
|
||||
|
||||
[profile.dev]
|
||||
# Rust debug is too slow.
|
||||
# For debug builds always builds with some optimization
|
||||
opt-level = "s"
|
||||
|
||||
[profile.release]
|
||||
codegen-units = 1 # LLVM can perform better optimizations using a single thread
|
||||
debug = 2
|
||||
debug-assertions = false
|
||||
incremental = false
|
||||
lto = 'thin'
|
||||
opt-level = 3
|
||||
overflow-checks = false
|
||||
members = ["acid-firmware", "password-hash"]
|
||||
|
|
|
|||
27
firmware/acid-firmware/.cargo/config.toml
Normal file
27
firmware/acid-firmware/.cargo/config.toml
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
[target.'cfg(all(any(target_arch = "riscv32", target_arch = "xtensa"), target_os = "none"))']
|
||||
runner = "espflash flash --monitor"
|
||||
# runner = "probe-rs run --chip esp32s3 --preverify"
|
||||
|
||||
[build]
|
||||
target = "xtensa-esp32s3-none-elf"
|
||||
rustflags = [
|
||||
# Required to obtain backtraces (e.g. when using the "esp-backtrace" crate.)
|
||||
# NOTE: May negatively impact performance of produced code
|
||||
"-C", "force-frame-pointers",
|
||||
]
|
||||
|
||||
|
||||
[env]
|
||||
LIBXKBCOMMON_BUILD_DIR = "../libxkbcommon/build"
|
||||
SPECTRE_API_BUILD_DIR = "../spectre-api-c/build-esp32s3"
|
||||
SPECTRE_API_SYS_CC = "xtensa-esp32s3-elf-cc.exe"
|
||||
ESP_LOG = "warn"
|
||||
ESP_BACKTRACE_CONFIG_BACKTRACE_FRAMES = "20"
|
||||
# This is overkill, but we can afford it.
|
||||
SLINT_FONT_SIZES = "8,11,10,12,13,14,15,16,18,20,22,24,32"
|
||||
|
||||
# Xtensa only:
|
||||
# Needed for nightly, until llvm upstream has support for Rust Xtensa.
|
||||
# This can be substituted with a `-Zbuild-std="core,alloc"` cargo flag.
|
||||
[unstable]
|
||||
build-std = ["alloc", "core"]
|
||||
8708
firmware/acid-firmware/Cargo.lock
generated
Normal file
8708
firmware/acid-firmware/Cargo.lock
generated
Normal file
File diff suppressed because it is too large
Load diff
119
firmware/acid-firmware/Cargo.toml
Normal file
119
firmware/acid-firmware/Cargo.toml
Normal file
|
|
@ -0,0 +1,119 @@
|
|||
[package]
|
||||
name = "acid-firmware"
|
||||
version = "0.1.0"
|
||||
authors = ['Jakub "Limeth" Hlusička']
|
||||
description = "Firmware for the ACID keyboard"
|
||||
homepage = "https://github.com/haobogu/rmk"
|
||||
repository = "https://github.com/haobogu/rmk"
|
||||
edition = "2024"
|
||||
|
||||
[features]
|
||||
default = ["usb-log", "limit-fps"]
|
||||
# Make RMK not to use USB
|
||||
no-usb = ["rmk/_no_usb"]
|
||||
# Let RMK use BLE
|
||||
ble = ["rmk/esp32s3_ble", "dep:esp-radio", "dep:bt-hci"]
|
||||
# Use alternative logging via GPIO5 as RX and GPIO12 as TX.
|
||||
# Disables default logging via USB.
|
||||
# Does not support esp-println's `println!`.
|
||||
alt-log = []
|
||||
# Standard logging implementation over USB.
|
||||
usb-log = ["esp-backtrace/panic-handler"]
|
||||
# RTT (+ logging) for probe-rs
|
||||
rtt-log = ["dep:rtt-target", "dep:panic-rtt-target"]
|
||||
# Block the main core while it is driving the LCD.
|
||||
# This prevents the main core from accessing PSRAM while the LCD is being driven,
|
||||
# which causes the LCD to glitch. To prevent the main core from spending all its
|
||||
# execution time on just driving the LCD, it will be limited.
|
||||
limit-fps = []
|
||||
# Development profiles
|
||||
develop = ["limit-fps", "alt-log"]
|
||||
develop-usb = ["limit-fps", "usb-log", "no-usb", "ble"]
|
||||
probe = ["limit-fps", "rtt-log", "no-usb", "ble"]
|
||||
|
||||
[dependencies]
|
||||
rmk = { version = "0.8.2", default-features = false, features = [
|
||||
"log",
|
||||
"storage",
|
||||
"vial",
|
||||
"controller",
|
||||
] }
|
||||
embassy-executor = { version = "0.9", features = ["log"] }
|
||||
embassy-time = { version = "0.5.0", features = ["log"] }
|
||||
embassy-embedded-hal = "0.5.0"
|
||||
embassy-sync = { version = "0.7.2", features = ["log"] }
|
||||
esp-backtrace = { version = "0.18", default-features = false, features = [
|
||||
"esp32s3",
|
||||
"println",
|
||||
] }
|
||||
esp-hal = { version = "1.0", features = ["esp32s3", "unstable", "psram", "log-04"] }
|
||||
esp-storage = { version = "0.8.0", features = ["esp32s3"] }
|
||||
esp-alloc = { version = "0.9.0", features = ["nightly"] }
|
||||
esp-println = { version = "0.16.0", features = ["esp32s3", "log-04"] }
|
||||
esp-radio = { version = "0.17", features = ["esp32s3", "unstable", "ble"], optional = true }
|
||||
esp-rtos = { version = "0.2", features = ["esp32s3", "esp-radio", "embassy"] }
|
||||
esp-bootloader-esp-idf = { version = "0.4", features = ["esp32s3", "log-04"] }
|
||||
bt-hci = { version = "0.6", optional = true }
|
||||
rand_core = { version = "0.6", default-features = false }
|
||||
static_cell = "2"
|
||||
lazy_static = { version = "1.5.0", features = ["spin_no_std"], default-features = false }
|
||||
log = "0.4.29"
|
||||
bitflags = "2.10.0"
|
||||
paste = "1.0.15"
|
||||
itertools = { version = "0.14.0", default-features = false }
|
||||
bytemuck = "1.24.0"
|
||||
slint = { version = "1.14.1", default-features = false, features = ["compat-1-2", "libm", "log", "unsafe-single-threaded", "renderer-software"]}
|
||||
i-slint-common = "1.14.1"
|
||||
critical-section = "1.2.0"
|
||||
cfg-if = "1.0.4"
|
||||
xkbcommon = { git = "https://github.com/Limeth/xkbcommon-rs", branch = "esp32s3", default-features = false, features = ["c-lib-wrap"] }
|
||||
rtt-target = { version = "0.6.2", features = ["log"], optional = true }
|
||||
panic-rtt-target = { version = "0.2.0", optional = true }
|
||||
enumset = "1.1.10"
|
||||
printf-compat = { version = "0.2.1", default-features = false }
|
||||
spectre-api-sys = { git = "https://github.com/Limeth/spectre-api-sys" }
|
||||
sha2 = { version = "0.10.9", default-features = false }
|
||||
password-hash = { path = "../password-hash", default-features = false }
|
||||
hmac = "0.12.1"
|
||||
|
||||
# Crates for serial UART CLI
|
||||
embedded-cli = { version = "0.2.1", default-features = false, features = ["help", "macros"] }
|
||||
embedded-io = "0.6.1"
|
||||
mutually_exclusive_features = "0.1.0"
|
||||
|
||||
[build-dependencies]
|
||||
xz2 = "0.1.7"
|
||||
json = "0.12"
|
||||
const-gen = "1.6"
|
||||
embuild = "0.33"
|
||||
cc = "1.2.9"
|
||||
slint-build = "1.14.1"
|
||||
gix = { version = "0.76.0", default-features = false, features = ["max-performance", "status"] }
|
||||
indoc = "2.0.7"
|
||||
|
||||
[[bin]]
|
||||
name = "acid-firmware"
|
||||
test = false
|
||||
bench = false
|
||||
|
||||
[profile.release-with-debug]
|
||||
inherits = "release"
|
||||
debug = true
|
||||
|
||||
|
||||
[profile.dev.package.esp-storage]
|
||||
opt-level = 3
|
||||
|
||||
[profile.dev]
|
||||
# Rust debug is too slow.
|
||||
# For debug builds always builds with some optimization
|
||||
opt-level = "s"
|
||||
|
||||
[profile.release]
|
||||
codegen-units = 1 # LLVM can perform better optimizations using a single thread
|
||||
debug = 2
|
||||
debug-assertions = false
|
||||
incremental = false
|
||||
lto = 'thin'
|
||||
opt-level = 3
|
||||
overflow-checks = false
|
||||
|
|
@ -34,30 +34,35 @@ fn main() {
|
|||
|
||||
// TODO: Make it a submodule and use relative paths.
|
||||
|
||||
// Link libxkbcommon.
|
||||
let libxkbcommon_build_dir = env::var("LIBXKBCOMMON_BUILD_DIR")
|
||||
.expect("The build directory of libxkbcommon must be specified using the `LIBXKBCOMMON_BUILD_DIR` environment variable.");
|
||||
let libxkbcommon_library_path = PathBuf::from(&libxkbcommon_build_dir).join("libxkbcommon.a");
|
||||
fn link_static_lib(env_var: &str, library: &str) {
|
||||
let lib_build_dir = env::var(env_var)
|
||||
.unwrap_or_else(|error| panic!("The build directory of lib{library} must be specified using the `{env_var}` environment variable: {error}"));
|
||||
let lib_build_dir = PathBuf::from(&lib_build_dir).canonicalize().unwrap();
|
||||
let lib_library_path = lib_build_dir
|
||||
.join(format!("lib{library}.a"))
|
||||
.canonicalize()
|
||||
.unwrap();
|
||||
let lib_build_dir = lib_build_dir.display();
|
||||
|
||||
if !libxkbcommon_library_path.is_file() {
|
||||
panic!(
|
||||
"{}",
|
||||
formatdoc! {"
|
||||
The compiled libxkbcommon library was not found at path {libxkbcommon_library_path:?}.
|
||||
Most likely, the library was not compiled. See the `README.md` for compilation instructions.
|
||||
If the `LIBXKBCOMMON_BUILD_DIR` environment variable is not set to the build directory you want to use, change it.
|
||||
Currently, `LIBXKBCOMMON_BUILD_DIR` is set to: {libxkbcommon_build_dir}
|
||||
"}
|
||||
);
|
||||
if !lib_library_path.is_file() {
|
||||
panic!(
|
||||
"{}",
|
||||
formatdoc! {"
|
||||
The compiled lib{library} library was not found at path {lib_library_path:?}.
|
||||
Most likely, the library was not compiled. See the `README.md` for compilation instructions.
|
||||
If the `{env_var}` environment variable is not set to the build directory you want to use, change it.
|
||||
Currently, `{env_var}` is set to: {lib_build_dir}
|
||||
"}
|
||||
);
|
||||
}
|
||||
|
||||
println!("cargo:rustc-link-search=native={lib_build_dir}");
|
||||
println!("cargo:rustc-link-lib=static={library}");
|
||||
println!("cargo:rerun-if-changed={lib_build_dir}/lib{library}.a");
|
||||
}
|
||||
|
||||
println!("cargo:rustc-link-search=native={libxkbcommon_build_dir}");
|
||||
println!("cargo:rustc-link-lib=static=xkbcommon");
|
||||
println!("cargo:rerun-if-changed={libxkbcommon_build_dir}/libxkbcommon.a");
|
||||
|
||||
println!("cargo:rustc-link-search=native=../../../c/spectre-cli-linux/api/build");
|
||||
println!("cargo:rustc-link-lib=static=spectre");
|
||||
println!("cargo:rerun-if-changed=../../../c/spectre-cli-linux/api/build/libspectre.a");
|
||||
link_static_lib("LIBXKBCOMMON_BUILD_DIR", "xkbcommon");
|
||||
link_static_lib("SPECTRE_API_BUILD_DIR", "spectre");
|
||||
|
||||
// Slint config and compilation
|
||||
{
|
||||
|
|
@ -22,3 +22,5 @@ argon2 = { version = "0.5.3", default-features = false, features = ["alloc"] }
|
|||
itertools = { version = "0.14.0", optional = true }
|
||||
scrypt = { version = "0.11.0", default-features = false, optional = true }
|
||||
spectre-api-sys = { git = "https://github.com/Limeth/spectre-api-sys", optional = true }
|
||||
# TODO: Why is this unable to provide the symbols for spectre-api-sys?
|
||||
# libsodium-sys-stable = { version = "1.23.2", optional = true }
|
||||
|
|
|
|||
|
|
@ -17,7 +17,8 @@ fn main() {
|
|||
);
|
||||
|
||||
if let Ok(libsodium_install_dir) = env::var("LIBSODIUM_INSTALL_DIR") {
|
||||
let libsodium_install_dir = PathBuf::from(libsodium_install_dir);
|
||||
let libsodium_install_dir =
|
||||
PathBuf::from(libsodium_install_dir).canonicalize().unwrap();
|
||||
println!(
|
||||
"cargo:rustc-link-search=native={}",
|
||||
libsodium_install_dir.join("lib").display()
|
||||
|
|
|
|||
Loading…
Reference in a new issue