diff --git a/flake.nix b/flake.nix index 1043396..a45cc17 100644 --- a/flake.nix +++ b/flake.nix @@ -49,7 +49,8 @@ rustc --version arm-none-eabi-gcc --version | head -n1 echo "cargo build --release --target thumbv8m.main-none-eabihf" - echo "sudo probe-rs run --chip STM32U575ZI target/thumbv8m.main-none-eabihf/release/main" + echo "cargo flash --release --chip STM32U575ZI" + echo "probe-rs run --chip STM32U575ZITxQ target/thumbv8m.main-none-eabihf/release/main" ''; }; }; diff --git a/hal_adc/.cargo/config.toml b/hal_adc/.cargo/config.toml index 793e2c8..ac6a5dc 100644 --- a/hal_adc/.cargo/config.toml +++ b/hal_adc/.cargo/config.toml @@ -1,22 +1,15 @@ -[target.'cfg(all(target_arch = "arm", target_os = "none"))'] -runner = ["probe-rs", "run", "--chip", "STM32U575ZI", "--log-format=oneline"] +[build] +target = "thumbv8m.main-none-eabihf" + +[target.thumbv8m.main-none-eabihf] +runner = "probe-rs run --chip STM32U575ZITxQ" rustflags = [ - "-C", "linker=flip-link", + "-C", "linker=rust-lld", "-C", "link-arg=-Tlink.x", "-C", "link-arg=-Tdefmt.x", "-C", "link-arg=--nmagic", ] -[build] -target = "thumbv8m.main-none-eabihf" - -[target.thumbv8m.main-none-eabihf] -runner = "probe-rs run --chip STM32U575ZI" - -[alias] -rb = "run --bin" -rrb = "run --release --bin" - -[env] -DEFMT_LOG = "info" +[package.metadata.cargo-flash] +chip = "STM32U575ZIT" diff --git a/hal_adc/Cargo.lock b/hal_adc/Cargo.lock index 812182e..e01531c 100644 --- a/hal_adc/Cargo.lock +++ b/hal_adc/Cargo.lock @@ -178,15 +178,6 @@ dependencies = [ "syn 2.0.107", ] -[[package]] -name = "defmt" -version = "0.3.100" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f0963443817029b2024136fc4dd07a5107eb8f977eaf18fcd1fdeb11306b64ad" -dependencies = [ - "defmt 1.0.1", -] - [[package]] name = "defmt" version = "1.0.1" @@ -226,7 +217,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "93d5a25c99d89c40f5676bec8cefe0614f17f0f40e916f98e345dae941807f9e" dependencies = [ "critical-section", - "defmt 1.0.1", + "defmt", ] [[package]] @@ -244,7 +235,6 @@ version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "554e3e840696f54b4c9afcf28a0f24da431c927f4151040020416e7393d6d0d8" dependencies = [ - "defmt 1.0.1", "embassy-futures", "embassy-hal-internal", "embassy-sync", @@ -265,7 +255,6 @@ checksum = "06070468370195e0e86f241c8e5004356d696590a678d47d6676795b2e439c6b" dependencies = [ "cortex-m", "critical-section", - "defmt 1.0.1", "document-features", "embassy-executor-macros", "embassy-executor-timer-queue", @@ -303,7 +292,6 @@ checksum = "95285007a91b619dc9f26ea8f55452aa6c60f7115a4edc05085cd2bd3127cd7a" dependencies = [ "cortex-m", "critical-section", - "defmt 1.0.1", "num-traits", ] @@ -312,9 +300,6 @@ name = "embassy-net-driver" version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "524eb3c489760508f71360112bca70f6e53173e6fe48fc5f0efd0f5ab217751d" -dependencies = [ - "defmt 0.3.100", -] [[package]] name = "embassy-net-driver-channel" @@ -341,7 +326,6 @@ dependencies = [ "cortex-m", "cortex-m-rt", "critical-section", - "defmt 1.0.1", "document-features", "embassy-embedded-hal", "embassy-futures", @@ -376,28 +360,6 @@ dependencies = [ "volatile-register", ] -[[package]] -name = "embassy-stm32u575zi-examples" -version = "0.1.0" -dependencies = [ - "cortex-m", - "cortex-m-rt", - "defmt 1.0.1", - "defmt-rtt", - "embassy-executor", - "embassy-futures", - "embassy-stm32", - "embassy-sync", - "embassy-time", - "embassy-usb", - "embedded-graphics", - "embedded-hal 1.0.0", - "heapless", - "micromath", - "panic-probe", - "tinybmp", -] - [[package]] name = "embassy-sync" version = "0.7.2" @@ -406,11 +368,10 @@ checksum = "73974a3edbd0bd286759b3d483540f0ebef705919a5f56f4fc7709066f71689b" dependencies = [ "cfg-if", "critical-section", - "defmt 1.0.1", "embedded-io-async", "futures-core", "futures-sink", - "heapless", + "heapless 0.8.0", ] [[package]] @@ -421,7 +382,6 @@ checksum = "f4fa65b9284d974dad7a23bb72835c4ec85c0b540d86af7fc4098c88cff51d65" dependencies = [ "cfg-if", "critical-section", - "defmt 1.0.1", "document-features", "embassy-time-driver", "embedded-hal 0.2.7", @@ -446,7 +406,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "80e2ee86063bd028a420a5fb5898c18c87a8898026da1d4c852af2c443d0a454" dependencies = [ "embassy-executor-timer-queue", - "heapless", + "heapless 0.8.0", ] [[package]] @@ -455,13 +415,12 @@ version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dc4462e48b19a4f401a11901bdd981aab80c6a826608016a0bdc73cbbab31954" dependencies = [ - "defmt 1.0.1", "embassy-futures", "embassy-net-driver-channel", "embassy-sync", "embassy-usb-driver", "embedded-io-async", - "heapless", + "heapless 0.8.0", "ssmarshal", "usbd-hid", ] @@ -472,7 +431,6 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "17119855ccc2d1f7470a39756b12068454ae27a3eabb037d940b5c03d9c77b7a" dependencies = [ - "defmt 1.0.1", "embedded-io-async", ] @@ -483,7 +441,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "288751f8eaa44a5cf2613f13cee0ca8e06e6638cb96e897e6834702c79084b23" dependencies = [ "critical-section", - "defmt 1.0.1", "embassy-sync", "embassy-usb-driver", ] @@ -560,9 +517,6 @@ name = "embedded-io" version = "0.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "edd0f118536f44f5ccd48bcb8b111bdc3de888b58c74639dfb034a357d0f206d" -dependencies = [ - "defmt 0.3.100", -] [[package]] name = "embedded-io-async" @@ -570,7 +524,6 @@ version = "0.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3ff09972d4073aa8c299395be75161d582e7629cd663171d62af73c8d50dba3f" dependencies = [ - "defmt 0.3.100", "embedded-io", ] @@ -640,6 +593,29 @@ dependencies = [ "pin-utils", ] +[[package]] +name = "hal_adc" +version = "0.1.0" +dependencies = [ + "cortex-m", + "cortex-m-rt", + "defmt", + "defmt-rtt", + "embassy-executor", + "embassy-futures", + "embassy-stm32", + "embassy-sync", + "embassy-time", + "embassy-usb", + "embedded-graphics", + "embedded-hal 1.0.0", + "heapless 0.9.1", + "micromath", + "panic-halt", + "panic-probe", + "tinybmp", +] + [[package]] name = "hash32" version = "0.3.1" @@ -668,6 +644,16 @@ dependencies = [ "stable_deref_trait", ] +[[package]] +name = "heapless" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b1edcd5a338e64688fbdcb7531a846cfd3476a54784dcb918a0844682bc7ada5" +dependencies = [ + "hash32", + "stable_deref_trait", +] + [[package]] name = "ident_case" version = "1.0.1" @@ -722,6 +708,12 @@ version = "1.21.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "42f5e15c9953c5e4ccceeb2e7382a716482c34515315f7b03532b8b4e8393d2d" +[[package]] +name = "panic-halt" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a513e167849a384b7f9b746e517604398518590a9142f4846a32e3c2a4de7b11" + [[package]] name = "panic-probe" version = "1.0.0" @@ -729,7 +721,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fd402d00b0fb94c5aee000029204a46884b1262e0c443f166d86d2c0747e1a1a" dependencies = [ "cortex-m", - "defmt 1.0.1", + "defmt", ] [[package]] @@ -900,7 +892,6 @@ checksum = "6fd8ec3a292a0d9fc4798416a61b21da5ae50341b2e7b8d12e662bf305366097" dependencies = [ "cortex-m", "cortex-m-rt", - "defmt 0.3.100", ] [[package]] @@ -972,7 +963,7 @@ version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "98816b1accafbb09085168b90f27e93d790b4bfa19d883466b5e53315b5f06a6" dependencies = [ - "heapless", + "heapless 0.8.0", "portable-atomic", ] diff --git a/hal_adc/Cargo.toml b/hal_adc/Cargo.toml index 8360bd2..7792a68 100644 --- a/hal_adc/Cargo.toml +++ b/hal_adc/Cargo.toml @@ -1,57 +1,27 @@ [package] -edition = "2024" -name = "embassy-stm32u575zi-examples" -version = "0.1.0" -license = "MIT OR Apache-2.0" -publish = false authors = ["Priec "] +name = "hal_adc" +edition = "2024" +version = "0.1.0" + [dependencies] -# Embassy core crates from crates.io (no relative paths) -embassy-stm32 = { version = "0.4.0", features = [ - "defmt", - "stm32u575zi", - "time-driver-any", -] } -embassy-sync = { version = "0.7.2", features = ["defmt"] } -embassy-executor = { version = "0.9.1", features = [ - "arch-cortex-m", - "executor-thread", - "defmt", -] } -embassy-time = { version = "0.5.0", features = [ - "defmt", - "defmt-timestamp-uptime", - "tick-hz-32_768", -] } -embassy-usb = { version = "0.5.1", features = ["defmt"] } -embassy-futures = { version = "0.1.2" } +cortex-m = { version = "0.7.7", features = ["inline-asm", "critical-section-single-core"] } +cortex-m-rt = "0.7.5" +panic-halt = "1.0.0" -# Logging and panic behavior -defmt = "1.0.1" -defmt-rtt = "1.0.0" -panic-probe = { version = "1.0", features = ["print-defmt"] } +embassy-executor = { version = "0.9.1", features = ["arch-cortex-m", "executor-thread"] } +embassy-futures = "0.1.2" +embassy-stm32 = { version = "0.4.0", features = ["unstable-pac", "stm32u575zi", "time-driver-any", "memory-x"] } +embassy-sync = "0.7.2" +embassy-time = { version = "0.5.0", features = ["tick-hz-32_768"] } +embassy-usb = "0.5.1" -# MCU + HAL utilities -cortex-m = { version = "0.7", features = ["inline-asm", "critical-section-single-core"] } -cortex-m-rt = "0.7" embedded-hal = "1.0.0" -heapless = { version = "0.8", default-features = false } embedded-graphics = "0.8.1" +heapless = { version = "0.9.1", default-features = false } +micromath = "2.1.0" tinybmp = "0.6.0" -micromath = "2.0.0" - -[features] -## Allow building secure binaries if TrustZone is enabled -trustzone-secure = ["embassy-stm32/trustzone-secure"] - -[profile.release] -lto = "fat" -opt-level = "s" -debug = 2 -codegen-units = 1 - -[package.metadata.embassy] -build = [ - { target = "thumbv8m.main-none-eabihf", artifact-dir = "out/examples/stm32u5" } -] +panic-probe = { version = "1.0.0", features = ["defmt"] } +defmt-rtt = "1.1.0" +defmt = "1.0.1" diff --git a/hal_adc/memory.x b/hal_adc/memory.x deleted file mode 100644 index 89f96e1..0000000 --- a/hal_adc/memory.x +++ /dev/null @@ -1,13 +0,0 @@ -/* memory.x - STM32U575ZITxQ memory layout */ - -/* Flash: 2 MB starting at 0x08000000 */ -/* SRAM1 + SRAM2 + SRAM3 total 786 KB starting at 0x20000000 */ - -MEMORY -{ - FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 2048K - RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 786K -} - -/* provide stack start symbol (end of RAM) */ -_stack_start = ORIGIN(RAM) + LENGTH(RAM); diff --git a/hal_rng/.cargo/config.toml b/hal_rng/.cargo/config.toml index 793e2c8..ac6a5dc 100644 --- a/hal_rng/.cargo/config.toml +++ b/hal_rng/.cargo/config.toml @@ -1,22 +1,15 @@ -[target.'cfg(all(target_arch = "arm", target_os = "none"))'] -runner = ["probe-rs", "run", "--chip", "STM32U575ZI", "--log-format=oneline"] +[build] +target = "thumbv8m.main-none-eabihf" + +[target.thumbv8m.main-none-eabihf] +runner = "probe-rs run --chip STM32U575ZITxQ" rustflags = [ - "-C", "linker=flip-link", + "-C", "linker=rust-lld", "-C", "link-arg=-Tlink.x", "-C", "link-arg=-Tdefmt.x", "-C", "link-arg=--nmagic", ] -[build] -target = "thumbv8m.main-none-eabihf" - -[target.thumbv8m.main-none-eabihf] -runner = "probe-rs run --chip STM32U575ZI" - -[alias] -rb = "run --bin" -rrb = "run --release --bin" - -[env] -DEFMT_LOG = "info" +[package.metadata.cargo-flash] +chip = "STM32U575ZIT" diff --git a/hal_rng/Cargo.lock b/hal_rng/Cargo.lock index bbaebed..0da36eb 100644 --- a/hal_rng/Cargo.lock +++ b/hal_rng/Cargo.lock @@ -2,6 +2,18 @@ # It is not intended for manual editing. version = 4 +[[package]] +name = "ahash" +version = "0.8.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a15f179cd60c4584b8a8c596927aadc462e27f2ca70c04e0071964a73ba7a75" +dependencies = [ + "cfg-if", + "once_cell", + "version_check", + "zerocopy", +] + [[package]] name = "aligned" version = "0.4.2" @@ -26,6 +38,12 @@ version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c08606f8c3cbf4ce6ec8e28fb0014a2c086708fe954eaa885384a6165172e7e8" +[[package]] +name = "az" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7b7e4c2464d97fe331d41de9d5db0def0a96f4d823b8b32a2efd503578988973" + [[package]] name = "bare-metal" version = "0.2.5" @@ -47,6 +65,12 @@ version = "0.13.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "46afbd2983a5d5a7bd740ccb198caf5b82f45c40c09c0eed36052d91cb92e719" +[[package]] +name = "bitfield" +version = "0.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2d7e60934ceec538daadb9d8432424ed043a904d8e0243f3c6446bce549a46ac" + [[package]] name = "bitflags" version = "1.3.2" @@ -87,7 +111,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8ec610d8f49840a5b376c69663b6369e71f4b34484b9b2eb29fb918d92516cb9" dependencies = [ "bare-metal", - "bitfield", + "bitfield 0.13.2", "critical-section", "embedded-hal 0.2.7", "volatile-register", @@ -110,16 +134,7 @@ checksum = "e37549a379a9e0e6e576fd208ee60394ccb8be963889eebba3ffe0980364f472" dependencies = [ "proc-macro2", "quote", - "syn", -] - -[[package]] -name = "cortex-m-semihosting" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c23234600452033cc77e4b761e740e02d2c4168e11dbf36ab14a0f58973592b0" -dependencies = [ - "cortex-m", + "syn 2.0.107", ] [[package]] @@ -149,7 +164,7 @@ dependencies = [ "proc-macro2", "quote", "strsim", - "syn", + "syn 2.0.107", ] [[package]] @@ -160,16 +175,7 @@ checksum = "fc34b93ccb385b40dc71c6fceac4b2ad23662c7eeb248cf10d529b7e055b6ead" dependencies = [ "darling_core", "quote", - "syn", -] - -[[package]] -name = "defmt" -version = "0.3.100" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f0963443817029b2024136fc4dd07a5107eb8f977eaf18fcd1fdeb11306b64ad" -dependencies = [ - "defmt 1.0.1", + "syn 2.0.107", ] [[package]] @@ -192,7 +198,7 @@ dependencies = [ "proc-macro-error2", "proc-macro2", "quote", - "syn", + "syn 2.0.107", ] [[package]] @@ -211,30 +217,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "93d5a25c99d89c40f5676bec8cefe0614f17f0f40e916f98e345dae941807f9e" dependencies = [ "critical-section", - "defmt 1.0.1", -] - -[[package]] -name = "defmt-test" -version = "0.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1c1e67ff0e1c6b1a9540a1a3e04454658faacdd188c91987c444d56e469d7dea" -dependencies = [ - "cortex-m-rt", - "cortex-m-semihosting", - "defmt 0.3.100", - "defmt-test-macros", -] - -[[package]] -name = "defmt-test-macros" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fe5520fd36862f281c026abeaab153ebbc001717c29a9b8e5ba9704d8f3a879d" -dependencies = [ - "proc-macro2", - "quote", - "syn", + "defmt", ] [[package]] @@ -252,7 +235,6 @@ version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "554e3e840696f54b4c9afcf28a0f24da431c927f4151040020416e7393d6d0d8" dependencies = [ - "defmt 1.0.1", "embassy-futures", "embassy-hal-internal", "embassy-sync", @@ -287,7 +269,7 @@ dependencies = [ "darling", "proc-macro2", "quote", - "syn", + "syn 2.0.107", ] [[package]] @@ -310,7 +292,6 @@ checksum = "95285007a91b619dc9f26ea8f55452aa6c60f7115a4edc05085cd2bd3127cd7a" dependencies = [ "cortex-m", "critical-section", - "defmt 1.0.1", "num-traits", ] @@ -319,8 +300,16 @@ name = "embassy-net-driver" version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "524eb3c489760508f71360112bca70f6e53173e6fe48fc5f0efd0f5ab217751d" + +[[package]] +name = "embassy-net-driver-channel" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b7b2739fbcf6cd206ae08779c7d709087b16577d255f2ea4a45bc4bbbf305b3f" dependencies = [ - "defmt 0.3.100", + "embassy-futures", + "embassy-net-driver", + "embassy-sync", ] [[package]] @@ -337,10 +326,8 @@ dependencies = [ "cortex-m", "cortex-m-rt", "critical-section", - "defmt 1.0.1", "document-features", "embassy-embedded-hal", - "embassy-executor", "embassy-futures", "embassy-hal-internal", "embassy-net-driver", @@ -381,11 +368,10 @@ checksum = "73974a3edbd0bd286759b3d483540f0ebef705919a5f56f4fc7709066f71689b" dependencies = [ "cfg-if", "critical-section", - "defmt 1.0.1", "embedded-io-async", "futures-core", "futures-sink", - "heapless", + "heapless 0.8.0", ] [[package]] @@ -396,7 +382,6 @@ checksum = "f4fa65b9284d974dad7a23bb72835c4ec85c0b540d86af7fc4098c88cff51d65" dependencies = [ "cfg-if", "critical-section", - "defmt 1.0.1", "document-features", "embassy-time-driver", "embedded-hal 0.2.7", @@ -421,7 +406,23 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "80e2ee86063bd028a420a5fb5898c18c87a8898026da1d4c852af2c443d0a454" dependencies = [ "embassy-executor-timer-queue", - "heapless", + "heapless 0.8.0", +] + +[[package]] +name = "embassy-usb" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc4462e48b19a4f401a11901bdd981aab80c6a826608016a0bdc73cbbab31954" +dependencies = [ + "embassy-futures", + "embassy-net-driver-channel", + "embassy-sync", + "embassy-usb-driver", + "embedded-io-async", + "heapless 0.8.0", + "ssmarshal", + "usbd-hid", ] [[package]] @@ -430,7 +431,6 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "17119855ccc2d1f7470a39756b12068454ae27a3eabb037d940b5c03d9c77b7a" dependencies = [ - "defmt 1.0.1", "embedded-io-async", ] @@ -441,7 +441,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "288751f8eaa44a5cf2613f13cee0ca8e06e6638cb96e897e6834702c79084b23" dependencies = [ "critical-section", - "defmt 1.0.1", "embassy-sync", "embassy-usb-driver", ] @@ -455,6 +454,29 @@ dependencies = [ "nb 1.1.0", ] +[[package]] +name = "embedded-graphics" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0649998afacf6d575d126d83e68b78c0ab0e00ca2ac7e9b3db11b4cbe8274ef0" +dependencies = [ + "az", + "byteorder", + "embedded-graphics-core", + "float-cmp", + "micromath", +] + +[[package]] +name = "embedded-graphics-core" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba9ecd261f991856250d2207f6d8376946cd9f412a2165d3b75bc87a0bc7a044" +dependencies = [ + "az", + "byteorder", +] + [[package]] name = "embedded-hal" version = "0.2.7" @@ -495,9 +517,6 @@ name = "embedded-io" version = "0.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "edd0f118536f44f5ccd48bcb8b111bdc3de888b58c74639dfb034a357d0f206d" -dependencies = [ - "defmt 0.3.100", -] [[package]] name = "embedded-io-async" @@ -505,7 +524,6 @@ version = "0.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3ff09972d4073aa8c299395be75161d582e7629cd663171d62af73c8d50dba3f" dependencies = [ - "defmt 0.3.100", "embedded-io", ] @@ -524,6 +542,21 @@ dependencies = [ "embedded-storage", ] +[[package]] +name = "encode_unicode" +version = "0.3.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a357d28ed41a50f9c765dbfe56cbc04a64e53e5fc58ba79fbc34c10ef3df831f" + +[[package]] +name = "float-cmp" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "98de4bbd547a563b716d8dfa9aad1cb19bfab00f4fa09a6a4ed21dbcf44ce9c4" +dependencies = [ + "num-traits", +] + [[package]] name = "fnv" version = "1.0.7" @@ -560,6 +593,29 @@ dependencies = [ "pin-utils", ] +[[package]] +name = "hal_rng" +version = "0.1.0" +dependencies = [ + "cortex-m", + "cortex-m-rt", + "defmt", + "defmt-rtt", + "embassy-executor", + "embassy-futures", + "embassy-stm32", + "embassy-sync", + "embassy-time", + "embassy-usb", + "embedded-graphics", + "embedded-hal 1.0.0", + "heapless 0.9.1", + "micromath", + "panic-halt", + "panic-probe", + "tinybmp", +] + [[package]] name = "hash32" version = "0.3.1" @@ -569,6 +625,15 @@ dependencies = [ "byteorder", ] +[[package]] +name = "hashbrown" +version = "0.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "43a3c133739dddd0d2990f9a4bdf8eb4b21ef50e4851ca85ab661199821d510e" +dependencies = [ + "ahash", +] + [[package]] name = "heapless" version = "0.8.0" @@ -579,6 +644,16 @@ dependencies = [ "stable_deref_trait", ] +[[package]] +name = "heapless" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b1edcd5a338e64688fbdcb7531a846cfd3476a54784dcb918a0844682bc7ada5" +dependencies = [ + "hash32", + "stable_deref_trait", +] + [[package]] name = "ident_case" version = "1.0.1" @@ -591,6 +666,18 @@ version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f5e54036fe321fd421e10d732f155734c4e4afd610dd556d9a82833ab3ee0bed" +[[package]] +name = "log" +version = "0.4.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34080505efa8e45a4b816c349525ebe327ceaa8559756f0356cba97ef3bf7432" + +[[package]] +name = "micromath" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c3c8dda44ff03a2f238717214da50f65d5a53b45cd213a7370424ffdb6fae815" + [[package]] name = "nb" version = "0.1.3" @@ -615,6 +702,18 @@ dependencies = [ "autocfg", ] +[[package]] +name = "once_cell" +version = "1.21.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "42f5e15c9953c5e4ccceeb2e7382a716482c34515315f7b03532b8b4e8393d2d" + +[[package]] +name = "panic-halt" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a513e167849a384b7f9b746e517604398518590a9142f4846a32e3c2a4de7b11" + [[package]] name = "panic-probe" version = "1.0.0" @@ -622,7 +721,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fd402d00b0fb94c5aee000029204a46884b1262e0c443f166d86d2c0747e1a1a" dependencies = [ "cortex-m", - "defmt 1.0.1", + "defmt", ] [[package]] @@ -637,6 +736,12 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" +[[package]] +name = "portable-atomic" +version = "1.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f84267b20a16ea918e43c6a88433c2d54fa145c92a811b5b047ccbe153674483" + [[package]] name = "proc-macro-error-attr2" version = "2.0.0" @@ -656,7 +761,7 @@ dependencies = [ "proc-macro-error-attr2", "proc-macro2", "quote", - "syn", + "syn 2.0.107", ] [[package]] @@ -704,12 +809,6 @@ version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b328e2cb950eeccd55b7f55c3a963691455dcd044cfb5354f0c5e68d2c2d6ee2" -[[package]] -name = "semihosting" -version = "0.1.20" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3e1c7d2b77d80283c750a39c52f1ab4d17234e8f30bca43550f5b2375f41d5f" - [[package]] name = "semver" version = "0.9.0" @@ -725,6 +824,45 @@ version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" +[[package]] +name = "serde" +version = "1.0.228" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a8e94ea7f378bd32cbbd37198a4a91436180c5bb472411e48b5ec2e2124ae9e" +dependencies = [ + "serde_core", +] + +[[package]] +name = "serde_core" +version = "1.0.228" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "41d385c7d4ca58e59fc732af25c3983b67ac852c1a25000afe1175de458b67ad" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_derive" +version = "1.0.228" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d540f220d3187173da220f885ab66608367b6574e925011a9353e4badda91d79" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.107", +] + +[[package]] +name = "ssmarshal" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f3e6ad23b128192ed337dfa4f1b8099ced0c2bf30d61e551b65fda5916dbb850" +dependencies = [ + "encode_unicode", + "serde", +] + [[package]] name = "stable_deref_trait" version = "1.2.1" @@ -754,24 +892,6 @@ checksum = "6fd8ec3a292a0d9fc4798416a61b21da5ae50341b2e7b8d12e662bf305366097" dependencies = [ "cortex-m", "cortex-m-rt", - "defmt 0.3.100", -] - -[[package]] -name = "stm32u5-blinky" -version = "0.1.0" -dependencies = [ - "cortex-m", - "cortex-m-rt", - "defmt 1.0.1", - "defmt-rtt", - "defmt-test", - "embassy-executor", - "embassy-stm32", - "embassy-time", - "embedded-hal 1.0.0", - "panic-probe", - "semihosting", ] [[package]] @@ -780,6 +900,17 @@ version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" +[[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 = "syn" version = "2.0.107" @@ -808,7 +939,16 @@ checksum = "3ff15c8ecd7de3849db632e14d18d2571fa09dfc5ed93479bc4485c7a517c913" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.107", +] + +[[package]] +name = "tinybmp" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "df43af2cb7b369009aa14144959bb4f2720ab62034c9073242f2d3a186c2edb6" +dependencies = [ + "embedded-graphics", ] [[package]] @@ -817,12 +957,65 @@ version = "1.0.19" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f63a545481291138910575129486daeaf8ac54aee4387fe7906919f7830c7d9d" +[[package]] +name = "usb-device" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "98816b1accafbb09085168b90f27e93d790b4bfa19d883466b5e53315b5f06a6" +dependencies = [ + "heapless 0.8.0", + "portable-atomic", +] + +[[package]] +name = "usbd-hid" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6f291ab53d428685cc780f08a2eb9d5d6ff58622db2b36e239a4f715f1e184c" +dependencies = [ + "serde", + "ssmarshal", + "usb-device", + "usbd-hid-macros", +] + +[[package]] +name = "usbd-hid-descriptors" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0eee54712c5d778d2fb2da43b1ce5a7b5060886ef7b09891baeb4bf36910a3ed" +dependencies = [ + "bitfield 0.14.0", +] + +[[package]] +name = "usbd-hid-macros" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bb573c76e7884035ac5e1ab4a81234c187a82b6100140af0ab45757650ccda38" +dependencies = [ + "byteorder", + "hashbrown", + "log", + "proc-macro2", + "quote", + "serde", + "syn 1.0.109", + "usbd-hid-descriptors", +] + [[package]] name = "vcell" version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "77439c1b53d2303b20d9459b1ade71a83c716e3f9c34f3228c00e6f185d6c002" +[[package]] +name = "version_check" +version = "0.9.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a" + [[package]] name = "void" version = "1.0.2" @@ -837,3 +1030,23 @@ checksum = "de437e2a6208b014ab52972a27e59b33fa2920d3e00fe05026167a1c509d19cc" dependencies = [ "vcell", ] + +[[package]] +name = "zerocopy" +version = "0.8.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0894878a5fa3edfd6da3f88c4805f4c8558e2b996227a3d864f47fe11e38282c" +dependencies = [ + "zerocopy-derive", +] + +[[package]] +name = "zerocopy-derive" +version = "0.8.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "88d2b8d9c68ad2b9e4340d7832716a4d21a22a1154777ad56ea55c51a9cf3831" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.107", +] diff --git a/hal_rng/Cargo.toml b/hal_rng/Cargo.toml index 6e0cf00..9078052 100644 --- a/hal_rng/Cargo.toml +++ b/hal_rng/Cargo.toml @@ -1,43 +1,27 @@ [package] -# TODO(1) fix `authors` and `name` if you didn't use `cargo-generate` authors = ["Priec "] -name = "stm32u5-blinky" +name = "hal_rng" edition = "2024" version = "0.1.0" [dependencies] -cortex-m = { version = "0.7", features = ["critical-section-single-core"] } -cortex-m-rt = "0.7" -defmt = "1.0" -defmt-rtt = "1.0" -panic-probe = { version = "1.0", features = ["print-defmt"] } -embassy-stm32 = { version = "0.4.0", features = ["stm32u575zi", "time-driver-tim1", "defmt", "low-power", "memory-x"] } -embassy-time = "0.5.0" -semihosting = "0.1.20" -embedded-hal = "1.0.0" +cortex-m = { version = "0.7.7", features = ["inline-asm", "critical-section-single-core"] } +cortex-m-rt = "0.7.5" +panic-halt = "1.0.0" + embassy-executor = { version = "0.9.1", features = ["arch-cortex-m", "executor-thread"] } +embassy-futures = "0.1.2" +embassy-stm32 = { version = "0.4.0", features = ["unstable-pac", "stm32u575zi", "time-driver-any", "memory-x"] } +embassy-sync = "0.7.2" +embassy-time = { version = "0.5.0", features = ["tick-hz-32_768"] } +embassy-usb = "0.5.1" -[dev-dependencies] -defmt-test = "0.3" - -# cargo build/run -[profile.dev] -# default is opt-level = '0', but that makes very -# verbose machine code -opt-level = 's' -# trade compile speed for slightly better optimisations -codegen-units = 1 - -# cargo build/run --release -[profile.release] -# default is opt-level = '3', but that makes quite -# verbose machine code -opt-level = 's' -# trade compile speed for slightly better optimisations -codegen-units = 1 -# Use Link Time Optimisations to further inline things across -# crates -lto = 'fat' -# Leave the debug symbols in (default is no debug info) -debug = 2 +embedded-hal = "1.0.0" +embedded-graphics = "0.8.1" +heapless = { version = "0.9.1", default-features = false } +micromath = "2.1.0" +tinybmp = "0.6.0" +panic-probe = { version = "1.0.0", features = ["defmt"] } +defmt-rtt = "1.1.0" +defmt = "1.0.1" diff --git a/hal_rng/memory.x b/hal_rng/memory.x deleted file mode 100644 index 89f96e1..0000000 --- a/hal_rng/memory.x +++ /dev/null @@ -1,13 +0,0 @@ -/* memory.x - STM32U575ZITxQ memory layout */ - -/* Flash: 2 MB starting at 0x08000000 */ -/* SRAM1 + SRAM2 + SRAM3 total 786 KB starting at 0x20000000 */ - -MEMORY -{ - FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 2048K - RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 786K -} - -/* provide stack start symbol (end of RAM) */ -_stack_start = ORIGIN(RAM) + LENGTH(RAM); diff --git a/hal_rng/src/bin/main.rs b/hal_rng/src/bin/main.rs index df31b1d..f1baf52 100644 --- a/hal_rng/src/bin/main.rs +++ b/hal_rng/src/bin/main.rs @@ -3,11 +3,10 @@ #![no_std] #![no_main] -use defmt::*; use embassy_executor::Spawner; use embassy_stm32::rng::Rng; use embassy_stm32::{bind_interrupts, peripherals, rng}; -use {defmt_rtt as _, panic_probe as _}; +use panic_probe as _; bind_interrupts!(struct Irqs { RNG => rng::InterruptHandler; @@ -17,11 +16,7 @@ bind_interrupts!(struct Irqs { async fn main(_spawner: Spawner) { let p = embassy_stm32::init(Default::default()); - info!("Hello World!"); - let mut rng = Rng::new(p.RNG, Irqs); let mut buf = [0u8; 16]; - unwrap!(rng.async_fill_bytes(&mut buf).await); - info!("random bytes: {:02x}", buf); } diff --git a/hal_rng/src/lib.rs b/hal_rng/src/lib.rs deleted file mode 100644 index deac2a0..0000000 --- a/hal_rng/src/lib.rs +++ /dev/null @@ -1,46 +0,0 @@ -#![no_main] -#![no_std] - -use defmt_rtt as _; // global logger - -// TODO(5) adjust HAL import -// use some_hal as _; // memory layout - -use panic_probe as _; - -// same panicking *behavior* as `panic-probe` but doesn't print a panic message -// this prevents the panic message being printed *twice* when `defmt::panic` is invoked -#[defmt::panic_handler] -fn panic() -> ! { - cortex_m::asm::udf() -} - -/// Terminates the application and makes a semihosting-capable debug tool exit -/// with status code 0. -pub fn exit() -> ! { - semihosting::process::exit(0); -} - -/// Hardfault handler. -/// -/// Terminates the application and makes a semihosting-capable debug tool exit -/// with an error. This seems better than the default, which is to spin in a -/// loop. -#[cortex_m_rt::exception] -unsafe fn HardFault(_frame: &cortex_m_rt::ExceptionFrame) -> ! { - semihosting::process::exit(1); -} - -// defmt-test 0.3.0 has the limitation that this `#[tests]` attribute can only be used -// once within a crate. the module can be in any file but there can only be at most -// one `#[tests]` module in this library crate -#[cfg(test)] -#[defmt_test::tests] -mod unit_tests { - use defmt::assert; - - #[test] - fn it_works() { - assert!(true) - } -} diff --git a/hal_test/.cargo/config.toml b/hal_test/.cargo/config.toml index c5c1552..c069f33 100644 --- a/hal_test/.cargo/config.toml +++ b/hal_test/.cargo/config.toml @@ -6,6 +6,9 @@ runner = "probe-rs run --chip STM32U575ZITxQ" rustflags = [ "-C", "linker=rust-lld", - "-C", "link-arg=-Tlink.x", # provided by cortex-m-rt + "-C", "link-arg=-Tlink.x", "-C", "link-arg=--nmagic", ] + +[package.metadata.cargo-flash] +chip = "STM32U575ZIT"