Get stuff running with SD

This commit is contained in:
Frederik Menke 2024-06-25 22:20:08 +02:00
parent 5a2bfb0d36
commit bccc1a2973
7 changed files with 142 additions and 57 deletions

View file

@ -2,7 +2,7 @@
target = "thumbv6m-none-eabi" target = "thumbv6m-none-eabi"
[target.thumbv6m-none-eabi] [target.thumbv6m-none-eabi]
runner = "probe-rs run" # "elf2uf2-rs -d" runner = "probe-rs run --chip RP2040" # "elf2uf2-rs -d"
rustflags = [ rustflags = [
"-C", "link-arg=--nmagic", "-C", "link-arg=--nmagic",
"-C", "link-arg=-Tlink.x", "-C", "link-arg=-Tlink.x",

92
Cargo.lock generated
View file

@ -53,7 +53,7 @@ version = "0.2.5"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5deb64efa5bd81e31fcd1938615a6d98c82eafcbcd787162b6f63b91d6bac5b3" checksum = "5deb64efa5bd81e31fcd1938615a6d98c82eafcbcd787162b6f63b91d6bac5b3"
dependencies = [ dependencies = [
"rustc_version", "rustc_version 0.2.3",
] ]
[[package]] [[package]]
@ -403,7 +403,10 @@ dependencies = [
"embassy-executor", "embassy-executor",
"embassy-rp", "embassy-rp",
"embassy-time", "embassy-time",
"embedded-hal-bus",
"embedded-sdmmc",
"panic-probe", "panic-probe",
"portable-atomic",
] ]
[[package]] [[package]]
@ -416,7 +419,7 @@ dependencies = [
"critical-section", "critical-section",
"embedded-io-async", "embedded-io-async",
"futures-util", "futures-util",
"heapless", "heapless 0.8.0",
] ]
[[package]] [[package]]
@ -435,7 +438,7 @@ dependencies = [
"embedded-hal 1.0.0", "embedded-hal 1.0.0",
"embedded-hal-async", "embedded-hal-async",
"futures-util", "futures-util",
"heapless", "heapless 0.8.0",
] ]
[[package]] [[package]]
@ -487,6 +490,18 @@ dependencies = [
"embedded-hal 1.0.0", "embedded-hal 1.0.0",
] ]
[[package]]
name = "embedded-hal-bus"
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0d3980bf28e8577db59fe2bdb3df868a419469d2cecb363644eea2b6f7797669"
dependencies = [
"critical-section",
"embedded-hal 1.0.0",
"embedded-hal-async",
"portable-atomic",
]
[[package]] [[package]]
name = "embedded-hal-nb" name = "embedded-hal-nb"
version = "1.0.0" version = "1.0.0"
@ -512,6 +527,18 @@ dependencies = [
"embedded-io", "embedded-io",
] ]
[[package]]
name = "embedded-sdmmc"
version = "0.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "da528dbf3f1c1f0b321552bc334d04799bb17c1936de55bccfb643a4f39300d8"
dependencies = [
"byteorder",
"embedded-hal 1.0.0",
"heapless 0.7.17",
"log",
]
[[package]] [[package]]
name = "embedded-storage" name = "embedded-storage"
version = "0.3.1" version = "0.3.1"
@ -660,6 +687,15 @@ dependencies = [
"crunchy", "crunchy",
] ]
[[package]]
name = "hash32"
version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b0c35f58762feb77d74ebe43bdbc3210f09be9fe6742234d573bacc26ed92b67"
dependencies = [
"byteorder",
]
[[package]] [[package]]
name = "hash32" name = "hash32"
version = "0.3.1" version = "0.3.1"
@ -675,13 +711,26 @@ version = "0.14.5"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1" checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1"
[[package]]
name = "heapless"
version = "0.7.17"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cdc6457c0eb62c71aac4bc17216026d8410337c4126773b9c5daba343f17964f"
dependencies = [
"atomic-polyfill",
"hash32 0.2.1",
"rustc_version 0.4.0",
"spin",
"stable_deref_trait",
]
[[package]] [[package]]
name = "heapless" name = "heapless"
version = "0.8.0" version = "0.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0bfb9eb618601c89945a70e254898da93b13be0388091d42117462b265bb3fad" checksum = "0bfb9eb618601c89945a70e254898da93b13be0388091d42117462b265bb3fad"
dependencies = [ dependencies = [
"hash32", "hash32 0.3.1",
"stable_deref_trait", "stable_deref_trait",
] ]
@ -968,6 +1017,15 @@ dependencies = [
"syn 1.0.100", "syn 1.0.100",
] ]
[[package]]
name = "portable-atomic"
version = "1.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7170ef9988bc169ba16dd36a7fa041e5c4cbeb6a35b76d4c03daded371eae7c0"
dependencies = [
"critical-section",
]
[[package]] [[package]]
name = "precomputed-hash" name = "precomputed-hash"
version = "0.1.1" version = "0.1.1"
@ -1084,7 +1142,16 @@ version = "0.2.3"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a" checksum = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a"
dependencies = [ dependencies = [
"semver", "semver 0.9.0",
]
[[package]]
name = "rustc_version"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bfa0f585226d2e68097d4f95d113b15b83a82e819ab25717ec0590d9584ef366"
dependencies = [
"semver 1.0.23",
] ]
[[package]] [[package]]
@ -1108,6 +1175,12 @@ dependencies = [
"semver-parser", "semver-parser",
] ]
[[package]]
name = "semver"
version = "1.0.23"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "61697e0a1c7e512e84a621326239844a24d8207b4669b41bc18b32ea5cbf988b"
[[package]] [[package]]
name = "semver-parser" name = "semver-parser"
version = "0.7.0" version = "0.7.0"
@ -1126,6 +1199,15 @@ version = "1.13.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67" checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67"
[[package]]
name = "spin"
version = "0.9.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6980e8d7511241f8acf4aebddbb1ff938df5eebe98691418c4468d0b72a96a67"
dependencies = [
"lock_api",
]
[[package]] [[package]]
name = "stable_deref_trait" name = "stable_deref_trait"
version = "1.2.0" version = "1.2.0"

View file

@ -36,13 +36,13 @@ panic-probe = { version = "0.3", features = ["print-defmt"] }
# embedded-hal-1 = { package = "embedded-hal", version = "1.0" } # embedded-hal-1 = { package = "embedded-hal", version = "1.0" }
# embedded-hal-async = "1.0" # embedded-hal-async = "1.0"
# embedded-hal-bus = { version = "0.2.0", features = ["async"] } embedded-hal-bus = { version = "0.2.0", features = ["async"] }
# embedded-io-async = { version = "0.6.1", features = ["defmt-03"] } # embedded-io-async = { version = "0.6.1", features = ["defmt-03"] }
# embedded-storage = { version = "0.3" } # embedded-storage = { version = "0.3" }
# static_cell = "2" # static_cell = "2"
# portable-atomic = { version = "1.5", features = ["critical-section"] } portable-atomic = { version = "1.5", features = ["critical-section"] }
# log = "0.4" # log = "0.4"
# pio-proc = "0.2" # pio-proc = "0.2"
# pio = "0.2.1" # pio = "0.2.1"
# rand = { version = "0.8.5", default-features = false } # rand = { version = "0.8.5", default-features = false }
# embedded-sdmmc = "0.7.0" embedded-sdmmc = "0.7.0"

View file

@ -18,31 +18,13 @@
"type": "github" "type": "github"
} }
}, },
"flake-utils_2": {
"inputs": {
"systems": "systems_2"
},
"locked": {
"lastModified": 1705309234,
"narHash": "sha256-uNRRNRKmJyCRC/8y1RqBkqWBLM034y4qN7EprSdmgyA=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "1ef2e671c3b0c19053962c07dbda38332dcebf26",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"nixpkgs": { "nixpkgs": {
"locked": { "locked": {
"lastModified": 1715787315, "lastModified": 1719254875,
"narHash": "sha256-cYApT0NXJfqBkKcci7D9Kr4CBYZKOQKDYA23q8XNuWg=", "narHash": "sha256-ECni+IkwXjusHsm9Sexdtq8weAq/yUyt1TWIemXt3Ko=",
"owner": "NixOS", "owner": "NixOS",
"repo": "nixpkgs", "repo": "nixpkgs",
"rev": "33d1e753c82ffc557b4a585c77de43d4c922ebb5", "rev": "2893f56de08021cffd9b6b6dfc70fd9ccd51eb60",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -54,11 +36,11 @@
}, },
"nixpkgs_2": { "nixpkgs_2": {
"locked": { "locked": {
"lastModified": 1706487304, "lastModified": 1718428119,
"narHash": "sha256-LE8lVX28MV2jWJsidW13D2qrHU/RUUONendL2Q/WlJg=", "narHash": "sha256-WdWDpNaq6u1IPtxtYHHWpl5BmabtpmLnMAx0RdJ/vo8=",
"owner": "NixOS", "owner": "NixOS",
"repo": "nixpkgs", "repo": "nixpkgs",
"rev": "90f456026d284c22b3e3497be980b2e47d0b28ac", "rev": "e6cea36f83499eb4e9cd184c8a8e823296b50ad5",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -77,15 +59,14 @@
}, },
"rust-overlay": { "rust-overlay": {
"inputs": { "inputs": {
"flake-utils": "flake-utils_2",
"nixpkgs": "nixpkgs_2" "nixpkgs": "nixpkgs_2"
}, },
"locked": { "locked": {
"lastModified": 1715825775, "lastModified": 1719281921,
"narHash": "sha256-7np2/EEr5Xm8IuKWQ43q8AA1Lb6Us2BW6rYMxGrInIg=", "narHash": "sha256-LIBMfhM9pMOlEvBI757GOK5l0R58SRi6YpwfYMbf4yc=",
"owner": "oxalica", "owner": "oxalica",
"repo": "rust-overlay", "repo": "rust-overlay",
"rev": "55f468b3d49c5d3321e85f2f9b1158476a2a90fb", "rev": "b6032d3a404d8a52ecfc8571ff0c26dfbe221d07",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -108,21 +89,6 @@
"repo": "default", "repo": "default",
"type": "github" "type": "github"
} }
},
"systems_2": {
"locked": {
"lastModified": 1681028828,
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
"owner": "nix-systems",
"repo": "default",
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
"type": "github"
},
"original": {
"owner": "nix-systems",
"repo": "default",
"type": "github"
}
} }
}, },
"root": "root", "root": "root",

View file

@ -0,0 +1,12 @@
[toolchain]
channel = "nightly-2024-06-18"
components = [ "rust-src", "rustfmt", "llvm-tools", "miri" ]
targets = [
"thumbv7em-none-eabi",
"thumbv7m-none-eabi",
"thumbv6m-none-eabi",
"thumbv7em-none-eabihf",
"thumbv8m.main-none-eabihf",
"riscv32imac-unknown-none-elf",
"wasm32-unknown-unknown",
]

View file

@ -1,4 +1,12 @@
[toolchain] [toolchain]
channel = "stable" channel = "1.79"
components = [ "rust-src", "rustfmt" ] components = [ "rust-src", "rustfmt", "llvm-tools"]
targets = [ "thumbv6m-none-eabi" ] targets = [
"thumbv7em-none-eabi",
"thumbv7m-none-eabi",
"thumbv6m-none-eabi",
"thumbv7em-none-eabihf",
"thumbv8m.main-none-eabihf",
"riscv32imac-unknown-none-elf",
"wasm32-unknown-unknown",
]

View file

@ -7,11 +7,28 @@
use defmt::*; use defmt::*;
use embassy_executor::Spawner; use embassy_executor::Spawner;
use embassy_rp::gpio; use embassy_rp::{gpio, spi};
use embassy_time::Timer; use embassy_time::Timer;
use embedded_hal_bus::spi::ExclusiveDevice;
use embedded_sdmmc::sdcard::{DummyCsPin, SdCard};
use gpio::{Level, Output}; use gpio::{Level, Output};
use {defmt_rtt as _, panic_probe as _}; use {defmt_rtt as _, panic_probe as _};
struct DummyTimesource();
impl embedded_sdmmc::TimeSource for DummyTimesource {
fn get_timestamp(&self) -> embedded_sdmmc::Timestamp {
embedded_sdmmc::Timestamp {
year_since_1970: 0,
zero_indexed_month: 0,
zero_indexed_day: 0,
hours: 0,
minutes: 0,
seconds: 0,
}
}
}
#[embassy_executor::main] #[embassy_executor::main]
async fn main(_spawner: Spawner) { async fn main(_spawner: Spawner) {
let p = embassy_rp::init(Default::default()); let p = embassy_rp::init(Default::default());