init
This commit is contained in:
7
.cargo/config.toml
Normal file
7
.cargo/config.toml
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
[target.'cfg(all(target_arch = "arm", target_os = "none"))']
|
||||||
|
runner = "probe-rs run --chip RP2040"
|
||||||
|
[build]
|
||||||
|
target = "thumbv6m-none-eabi"
|
||||||
|
|
||||||
|
[env]
|
||||||
|
DEFMT_LOG = "info"
|
||||||
3
.gitignore
vendored
Normal file
3
.gitignore
vendored
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
# Cargo build artifacts
|
||||||
|
/target/
|
||||||
|
**/.idea
|
||||||
39
Cargo.toml
Normal file
39
Cargo.toml
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
[package]
|
||||||
|
edition = "2024"
|
||||||
|
name = "kb-firmware"
|
||||||
|
version = "0.1.0"
|
||||||
|
authors = ["Lukrecja <lusiaaa425@gmail.com>"]
|
||||||
|
resolver = "2"
|
||||||
|
|
||||||
|
[[bin]]
|
||||||
|
name = "kb-firmware"
|
||||||
|
test = false
|
||||||
|
bench = false
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
defmt = "0.3"
|
||||||
|
defmt-rtt = "0.4"
|
||||||
|
panic-probe = { version = "0.3", features = ["print-defmt"] }
|
||||||
|
|
||||||
|
embedded-hal = "1.0.0"
|
||||||
|
embedded-hal-async = "1.0.0"
|
||||||
|
embedded-io = "0.6.1"
|
||||||
|
embedded-io-async = "0.6.1"
|
||||||
|
embedded-storage = "0.3.1"
|
||||||
|
|
||||||
|
cortex-m-rt = "0.7.3"
|
||||||
|
|
||||||
|
embassy-executor = { version = "0.7", features = ["task-arena-size-1024", "arch-cortex-m", "executor-thread", "defmt", "executor-interrupt"] }
|
||||||
|
embassy-sync = { version = "0.6" }
|
||||||
|
embassy-time = { version = "0.4", features = ["defmt", "defmt-timestamp-uptime"] }
|
||||||
|
cortex-m = { version = "0.7.7" }
|
||||||
|
embassy-rp = { version = "0.4", features = ["defmt", "unstable-pac", "time-driver", "critical-section-impl", "rp2040"] }
|
||||||
|
[profile.release]
|
||||||
|
debug = 2
|
||||||
|
lto = true
|
||||||
|
opt-level = 'z'
|
||||||
|
|
||||||
|
[profile.dev]
|
||||||
|
debug = 2
|
||||||
|
lto = true
|
||||||
|
opt-level = "z"
|
||||||
36
build.rs
Normal file
36
build.rs
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
//! This build script copies the `memory.x` file from the crate root into
|
||||||
|
//! a directory where the linker can always find it at build time.
|
||||||
|
//! For many projects this is optional, as the linker always searches the
|
||||||
|
//! project root directory -- wherever `Cargo.toml` is. However, if you
|
||||||
|
//! are using a workspace or have a more complicated build setup, this
|
||||||
|
//! build script becomes required. Additionally, by requesting that
|
||||||
|
//! Cargo re-run the build script whenever `memory.x` is changed,
|
||||||
|
//! updating `memory.x` ensures a rebuild of the application with the
|
||||||
|
//! new memory settings.
|
||||||
|
|
||||||
|
use std::env;
|
||||||
|
use std::fs::File;
|
||||||
|
use std::io::Write;
|
||||||
|
use std::path::PathBuf;
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
// Put `memory.x` in our output directory and ensure it's
|
||||||
|
// on the linker search path.
|
||||||
|
let out = &PathBuf::from(env::var_os("OUT_DIR").unwrap());
|
||||||
|
File::create(out.join("memory.x"))
|
||||||
|
.unwrap()
|
||||||
|
.write_all(include_bytes!("memory.x"))
|
||||||
|
.unwrap();
|
||||||
|
println!("cargo:rustc-link-search={}", out.display());
|
||||||
|
|
||||||
|
// By default, Cargo will re-run a build script whenever
|
||||||
|
// any file in the project changes. By specifying `memory.x`
|
||||||
|
// here, we ensure the build script is only re-run when
|
||||||
|
// `memory.x` is changed.
|
||||||
|
println!("cargo:rerun-if-changed=memory.x");
|
||||||
|
|
||||||
|
println!("cargo:rustc-link-arg-bins=--nmagic");
|
||||||
|
println!("cargo:rustc-link-arg-bins=-Tlink.x");
|
||||||
|
println!("cargo:rustc-link-arg-bins=-Tdefmt.x");
|
||||||
|
println!("cargo:rustc-link-arg-bins=-Tlink-rp.x");
|
||||||
|
}
|
||||||
7
memory.x
Normal file
7
memory.x
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
MEMORY
|
||||||
|
{
|
||||||
|
BOOT2 : ORIGIN = 0x10000000, LENGTH = 0x100
|
||||||
|
FLASH : ORIGIN = 0x10000100, LENGTH = 2048K - 0x100
|
||||||
|
RAM : ORIGIN = 0x20000000, LENGTH = 264K
|
||||||
|
}
|
||||||
|
|
||||||
11
rust-toolchain.toml
Normal file
11
rust-toolchain.toml
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
# Before upgrading check that everything is available on all tier1 targets here:
|
||||||
|
# https://rust-lang.github.io/rustup-components-history
|
||||||
|
[toolchain]
|
||||||
|
channel = "stable"
|
||||||
|
components = [ "rustfmt" ]
|
||||||
|
targets = [
|
||||||
|
"thumbv6m-none-eabi",
|
||||||
|
"thumbv7em-none-eabihf",
|
||||||
|
"thumbv8m.main-none-eabihf",
|
||||||
|
"riscv32imac-unknown-none-elf",
|
||||||
|
]
|
||||||
15
src/main.rs
Normal file
15
src/main.rs
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
#![no_std]
|
||||||
|
#![no_main]
|
||||||
|
|
||||||
|
use embassy_executor::Spawner;
|
||||||
|
use embassy_time::{Duration, Timer};
|
||||||
|
use {defmt_rtt as _, panic_probe as _};
|
||||||
|
|
||||||
|
#[embassy_executor::main]
|
||||||
|
async fn main(_spawner: Spawner) -> ! {
|
||||||
|
let _p = embassy_rp::init(Default::default());
|
||||||
|
loop {
|
||||||
|
defmt::info!("Blink");
|
||||||
|
Timer::after(Duration::from_millis(100)).await;
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user