Init xiao project
This commit is contained in:
parent
574d4d08bc
commit
4ae4b466fa
11 changed files with 2125 additions and 0 deletions
20
xiao-esp32c6/.cargo/config.toml
Normal file
20
xiao-esp32c6/.cargo/config.toml
Normal file
|
|
@ -0,0 +1,20 @@
|
||||||
|
[target.riscv32imac-unknown-none-elf]
|
||||||
|
runner = "espflash flash --monitor --chip esp32c6"
|
||||||
|
|
||||||
|
[env]
|
||||||
|
ESP_LOG = "info"
|
||||||
|
|
||||||
|
[build]
|
||||||
|
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",
|
||||||
|
"-Z",
|
||||||
|
"stack-protector=all",
|
||||||
|
]
|
||||||
|
|
||||||
|
target = "riscv32imac-unknown-none-elf"
|
||||||
|
|
||||||
|
[unstable]
|
||||||
|
build-std = ["alloc", "core"]
|
||||||
18
xiao-esp32c6/.gitignore
vendored
Normal file
18
xiao-esp32c6/.gitignore
vendored
Normal file
|
|
@ -0,0 +1,18 @@
|
||||||
|
# Generated by Cargo
|
||||||
|
# will have compiled files and executables
|
||||||
|
debug/
|
||||||
|
target/
|
||||||
|
.vscode/
|
||||||
|
|
||||||
|
# These are backup files generated by rustfmt
|
||||||
|
**/*.rs.bk
|
||||||
|
|
||||||
|
# MSVC Windows builds of rustc generate these, which store debugging information
|
||||||
|
*.pdb
|
||||||
|
|
||||||
|
# RustRover
|
||||||
|
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
|
||||||
|
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
|
||||||
|
# and can be added to the global gitignore or merged into this file. For a more nuclear
|
||||||
|
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
|
||||||
|
#.idea/
|
||||||
7
xiao-esp32c6/.sops.yaml
Normal file
7
xiao-esp32c6/.sops.yaml
Normal file
|
|
@ -0,0 +1,7 @@
|
||||||
|
keys:
|
||||||
|
- ¯onova age1sy52xwldc7puckze2kcax7csc2nrg049y9nt2qd0ltvghckms5nq2d25ra
|
||||||
|
creation_rules:
|
||||||
|
- path_regex: secrets.yaml$
|
||||||
|
key_groups:
|
||||||
|
- age:
|
||||||
|
- *macronova
|
||||||
1828
xiao-esp32c6/Cargo.lock
generated
Normal file
1828
xiao-esp32c6/Cargo.lock
generated
Normal file
File diff suppressed because it is too large
Load diff
84
xiao-esp32c6/Cargo.toml
Normal file
84
xiao-esp32c6/Cargo.toml
Normal file
|
|
@ -0,0 +1,84 @@
|
||||||
|
[package]
|
||||||
|
edition = "2021"
|
||||||
|
name = "xiao-esp32c6"
|
||||||
|
version = "0.1.0"
|
||||||
|
|
||||||
|
[[bin]]
|
||||||
|
name = "xiao-esp32c6"
|
||||||
|
path = "./src/bin/main.rs"
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
esp-bootloader-esp-idf = "0.1.0"
|
||||||
|
esp-hal = { version = "=1.0.0-beta.1", features = [
|
||||||
|
"esp32c6",
|
||||||
|
"log-04",
|
||||||
|
"unstable",
|
||||||
|
] }
|
||||||
|
log = "0.4.27"
|
||||||
|
|
||||||
|
embassy-net = { version = "0.7.0", features = [
|
||||||
|
"dhcpv4",
|
||||||
|
"log",
|
||||||
|
"medium-ethernet",
|
||||||
|
"tcp",
|
||||||
|
"udp",
|
||||||
|
] }
|
||||||
|
embedded-io = "0.6.1"
|
||||||
|
embedded-io-async = "0.6.1"
|
||||||
|
esp-alloc = "0.8.0"
|
||||||
|
esp-backtrace = { version = "0.16.0", features = [
|
||||||
|
"esp32c6",
|
||||||
|
"exception-handler",
|
||||||
|
"panic-handler",
|
||||||
|
"println",
|
||||||
|
] }
|
||||||
|
esp-println = { version = "0.14.0", features = ["esp32c6", "log-04"] }
|
||||||
|
# for more networking protocol support see https://crates.io/crates/edge-net
|
||||||
|
bt-hci = { version = "0.2.1", features = [] }
|
||||||
|
critical-section = "1.2.0"
|
||||||
|
embassy-executor = { version = "0.7.0", features = [
|
||||||
|
"log",
|
||||||
|
"task-arena-size-20480",
|
||||||
|
] }
|
||||||
|
embassy-time = { version = "0.4.0", features = ["log"] }
|
||||||
|
esp-hal-embassy = { version = "0.8.1", features = ["esp32c6", "log-04"] }
|
||||||
|
esp-wifi = { version = "0.14.1", features = [
|
||||||
|
"ble",
|
||||||
|
"builtin-scheduler",
|
||||||
|
"coex",
|
||||||
|
"esp-alloc",
|
||||||
|
"esp32c6",
|
||||||
|
"log-04",
|
||||||
|
"smoltcp",
|
||||||
|
"wifi",
|
||||||
|
] }
|
||||||
|
smoltcp = { version = "0.12.0", default-features = false, features = [
|
||||||
|
"log",
|
||||||
|
"medium-ethernet",
|
||||||
|
"multicast",
|
||||||
|
"proto-dhcpv4",
|
||||||
|
"proto-dns",
|
||||||
|
"proto-ipv4",
|
||||||
|
"socket-dns",
|
||||||
|
"socket-icmp",
|
||||||
|
"socket-raw",
|
||||||
|
"socket-tcp",
|
||||||
|
"socket-udp",
|
||||||
|
] }
|
||||||
|
static_cell = { version = "2.1.0", features = ["nightly"] }
|
||||||
|
trouble-host = { version = "0.1.0", features = ["gatt"] }
|
||||||
|
|
||||||
|
|
||||||
|
[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 = 'fat'
|
||||||
|
opt-level = 's'
|
||||||
|
overflow-checks = false
|
||||||
52
xiao-esp32c6/build.rs
Normal file
52
xiao-esp32c6/build.rs
Normal file
|
|
@ -0,0 +1,52 @@
|
||||||
|
fn main() {
|
||||||
|
linker_be_nice();
|
||||||
|
// make sure linkall.x is the last linker script (otherwise might cause problems with flip-link)
|
||||||
|
println!("cargo:rustc-link-arg=-Tlinkall.x");
|
||||||
|
}
|
||||||
|
|
||||||
|
fn linker_be_nice() {
|
||||||
|
let args: Vec<String> = std::env::args().collect();
|
||||||
|
if args.len() > 1 {
|
||||||
|
let kind = &args[1];
|
||||||
|
let what = &args[2];
|
||||||
|
|
||||||
|
match kind.as_str() {
|
||||||
|
"undefined-symbol" => match what.as_str() {
|
||||||
|
"_defmt_timestamp" => {
|
||||||
|
eprintln!();
|
||||||
|
eprintln!("💡 `defmt` not found - make sure `defmt.x` is added as a linker script and you have included `use defmt_rtt as _;`");
|
||||||
|
eprintln!();
|
||||||
|
}
|
||||||
|
"_stack_start" => {
|
||||||
|
eprintln!();
|
||||||
|
eprintln!("💡 Is the linker script `linkall.x` missing?");
|
||||||
|
eprintln!();
|
||||||
|
}
|
||||||
|
"esp_wifi_preempt_enable"
|
||||||
|
| "esp_wifi_preempt_yield_task"
|
||||||
|
| "esp_wifi_preempt_task_create" => {
|
||||||
|
eprintln!();
|
||||||
|
eprintln!("💡 `esp-wifi` has no scheduler enabled. Make sure you have the `builtin-scheduler` feature enabled, or that you provide an external scheduler.");
|
||||||
|
eprintln!();
|
||||||
|
}
|
||||||
|
"embedded_test_linker_file_not_added_to_rustflags" => {
|
||||||
|
eprintln!();
|
||||||
|
eprintln!("💡 `embedded-test` not found - make sure `embedded-test.x` is added as a linker script for tests");
|
||||||
|
eprintln!();
|
||||||
|
}
|
||||||
|
_ => (),
|
||||||
|
},
|
||||||
|
// we don't have anything helpful for "missing-lib" yet
|
||||||
|
_ => {
|
||||||
|
std::process::exit(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
std::process::exit(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
println!(
|
||||||
|
"cargo:rustc-link-arg=--error-handling-script={}",
|
||||||
|
std::env::current_exe().unwrap().display()
|
||||||
|
);
|
||||||
|
}
|
||||||
4
xiao-esp32c6/rust-toolchain.toml
Normal file
4
xiao-esp32c6/rust-toolchain.toml
Normal file
|
|
@ -0,0 +1,4 @@
|
||||||
|
[toolchain]
|
||||||
|
channel = "nightly"
|
||||||
|
components = ["rust-src"]
|
||||||
|
targets = ["riscv32imac-unknown-none-elf"]
|
||||||
23
xiao-esp32c6/secrets.yaml
Normal file
23
xiao-esp32c6/secrets.yaml
Normal file
|
|
@ -0,0 +1,23 @@
|
||||||
|
wireless_credentials:
|
||||||
|
telescope: ENC[AES256_GCM,data:gEzvqWC95+bjrg==,iv:iP2XBs9GC1mPIAdVQiyng/Lthm3kCH7EWmdSmOy+h4c=,tag:Xr264zlPYP6dqPp7rBAywQ==,type:str]
|
||||||
|
chroma: ENC[AES256_GCM,data:tpG8VPdXN506dg==,iv:rzZAb7Vge8UouBHYVl3UkAs6JqaoOEEBgw7xkxTuIdI=,tag:Pr0KbwoVXk4hsrPKt84wVA==,type:str]
|
||||||
|
sops:
|
||||||
|
kms: []
|
||||||
|
gcp_kms: []
|
||||||
|
azure_kv: []
|
||||||
|
hc_vault: []
|
||||||
|
age:
|
||||||
|
- recipient: age1sy52xwldc7puckze2kcax7csc2nrg049y9nt2qd0ltvghckms5nq2d25ra
|
||||||
|
enc: |
|
||||||
|
-----BEGIN AGE ENCRYPTED FILE-----
|
||||||
|
YWdlLWVuY3J5cHRpb24ub3JnL3YxCi0+IFgyNTUxOSBVcmZScFFhWVJhakJEQWZp
|
||||||
|
cTFWNzlIVm9xeXFMZXFSdk1UWndFbE1tRm5vCmNMc0FMQVdyMkZKYzJnTlora0Zy
|
||||||
|
Tmp1enZHMUpnbnRYM1pTenpNTEw4RWcKLS0tIDFEVitVbldhNWdkb29QVGJWa1Rk
|
||||||
|
YVZUZFZyNmJmRk5tQVNJMkk2S0p2UVkKx2i/QAo3c0IGS3sgeYyafm8zezQu50WT
|
||||||
|
VVaHxHfCVIvlrPV7eniofG3CF3R9vgcOLVMA/2I5p6RUttWSqlwnYg==
|
||||||
|
-----END AGE ENCRYPTED FILE-----
|
||||||
|
lastmodified: "2024-10-13T07:05:11Z"
|
||||||
|
mac: ENC[AES256_GCM,data:1ZVeiENo2l7ldHodx1j52CtNw0dpJD1Kz9GkvXpXsAxV4PunwIv8iDpzq20cHClXWZJjsY0HEwBcHwup9qgvCaFs9HDpMBV8Ps67uP2m+OAV2RKMf86xXj5D6DbsmwHLn2xQd+voHurn36FPAxlLT1HUUSwCbtRsEG72xS3wgq0=,iv:TLN1jr0ONuLcrRrx6H4VdCLunfAl4tqUil+YgjXyyhg=,tag:S41L3A3CwW+bBeJL/DnqFw==,type:str]
|
||||||
|
pgp: []
|
||||||
|
unencrypted_suffix: _unencrypted
|
||||||
|
version: 3.9.1
|
||||||
62
xiao-esp32c6/src/bin/main.rs
Normal file
62
xiao-esp32c6/src/bin/main.rs
Normal file
|
|
@ -0,0 +1,62 @@
|
||||||
|
#![no_std]
|
||||||
|
#![no_main]
|
||||||
|
#![deny(
|
||||||
|
clippy::mem_forget,
|
||||||
|
reason = "mem::forget is generally not safe to do with esp_hal types, especially those \
|
||||||
|
holding buffers for the duration of a data transfer."
|
||||||
|
)]
|
||||||
|
|
||||||
|
use bt_hci::controller::ExternalController;
|
||||||
|
use embassy_executor::Spawner;
|
||||||
|
use embassy_time::{Duration, Timer};
|
||||||
|
use esp_backtrace as _;
|
||||||
|
use esp_hal::clock::CpuClock;
|
||||||
|
use esp_hal::timer::systimer::SystemTimer;
|
||||||
|
use esp_hal::timer::timg::TimerGroup;
|
||||||
|
use esp_wifi::ble::controller::BleConnector;
|
||||||
|
use log::info;
|
||||||
|
|
||||||
|
extern crate alloc;
|
||||||
|
|
||||||
|
// This creates a default app-descriptor required by the esp-idf bootloader.
|
||||||
|
// For more information see: <https://docs.espressif.com/projects/esp-idf/en/stable/esp32/api-reference/system/app_image_format.html#application-description>
|
||||||
|
esp_bootloader_esp_idf::esp_app_desc!();
|
||||||
|
|
||||||
|
#[esp_hal_embassy::main]
|
||||||
|
async fn main(spawner: Spawner) {
|
||||||
|
// generator version: 0.4.0
|
||||||
|
|
||||||
|
esp_println::logger::init_logger_from_env();
|
||||||
|
|
||||||
|
let config = esp_hal::Config::default().with_cpu_clock(CpuClock::max());
|
||||||
|
let peripherals = esp_hal::init(config);
|
||||||
|
|
||||||
|
esp_alloc::heap_allocator!(size: 64 * 1024);
|
||||||
|
// COEX needs more RAM - so we've added some more
|
||||||
|
esp_alloc::heap_allocator!(#[unsafe(link_section = ".dram2_uninit")] size: 64 * 1024);
|
||||||
|
|
||||||
|
let timer0 = SystemTimer::new(peripherals.SYSTIMER);
|
||||||
|
esp_hal_embassy::init(timer0.alarm0);
|
||||||
|
|
||||||
|
info!("Embassy initialized!");
|
||||||
|
|
||||||
|
let rng = esp_hal::rng::Rng::new(peripherals.RNG);
|
||||||
|
let timer1 = TimerGroup::new(peripherals.TIMG0);
|
||||||
|
let wifi_init = esp_wifi::init(timer1.timer0, rng, peripherals.RADIO_CLK)
|
||||||
|
.expect("Failed to initialize WIFI/BLE controller");
|
||||||
|
let (mut _wifi_controller, _interfaces) = esp_wifi::wifi::new(&wifi_init, peripherals.WIFI)
|
||||||
|
.expect("Failed to initialize WIFI controller");
|
||||||
|
// find more examples https://github.com/embassy-rs/trouble/tree/main/examples/esp32
|
||||||
|
let transport = BleConnector::new(&wifi_init, peripherals.BT);
|
||||||
|
let _ble_controller = ExternalController::<_, 20>::new(transport);
|
||||||
|
|
||||||
|
// TODO: Spawn some tasks
|
||||||
|
let _ = spawner;
|
||||||
|
|
||||||
|
loop {
|
||||||
|
info!("Hello world!");
|
||||||
|
Timer::after(Duration::from_secs(1)).await;
|
||||||
|
}
|
||||||
|
|
||||||
|
// for inspiration have a look at the examples at https://github.com/esp-rs/esp-hal/tree/esp-hal-v1.0.0-beta.1/examples/src/bin
|
||||||
|
}
|
||||||
1
xiao-esp32c6/src/lib.rs
Normal file
1
xiao-esp32c6/src/lib.rs
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
#![no_std]
|
||||||
26
xiao-esp32c6/tests/hello_test.rs
Normal file
26
xiao-esp32c6/tests/hello_test.rs
Normal file
|
|
@ -0,0 +1,26 @@
|
||||||
|
//! Demo test suite using embedded-test
|
||||||
|
//!
|
||||||
|
//! You can run this using `cargo test` as usual.
|
||||||
|
|
||||||
|
#![no_std]
|
||||||
|
#![no_main]
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
#[embedded_test::tests(executor = esp_hal_embassy::Executor::new())]
|
||||||
|
mod tests {
|
||||||
|
use esp_hal::timer::systimer::SystemTimer;
|
||||||
|
|
||||||
|
#[init]
|
||||||
|
fn init() {
|
||||||
|
let peripherals = esp_hal::init(esp_hal::Config::default());
|
||||||
|
|
||||||
|
let timer0 = SystemTimer::new(peripherals.SYSTIMER);
|
||||||
|
esp_hal_embassy::init(timer0.alarm0);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
async fn hello_test() {
|
||||||
|
embassy_time::Timer::after(embassy_time::Duration::from_millis(100)).await;
|
||||||
|
assert_eq!(1 + 1, 2);
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue