okay rust-embedded tooling has improved a lot
This commit is contained in:
parent
b49acb8f5e
commit
142b87357f
26
rust-embedded/stm32f4-test/.cargo/config.toml
Normal file
26
rust-embedded/stm32f4-test/.cargo/config.toml
Normal file
|
@ -0,0 +1,26 @@
|
|||
[target.'cfg(all(target_arch = "arm", target_os = "none"))']
|
||||
runner = "probe-rs run --chip STM32F407VGTx"
|
||||
|
||||
rustflags = [
|
||||
# LLD (shipped with the Rust toolchain) is used as the default linker
|
||||
"-C", "link-arg=-Tlink.x",
|
||||
# "-C", "link-arg=-Tdefmt.x",
|
||||
# "-C", "link-arg=-Tstlog.x",
|
||||
|
||||
# if you run into problems with LLD switch to the GNU linker by commenting out
|
||||
# this line
|
||||
# "-C", "linker=arm-none-eabi-ld",
|
||||
|
||||
# if you need to link to pre-compiled C libraries provided by a C toolchain
|
||||
# use GCC as the linker by commenting out both lines above and then
|
||||
# uncommenting the three lines below
|
||||
# "-C", "linker=arm-none-eabi-gcc",
|
||||
# "-C", "link-arg=-Wl,-Tlink.x",
|
||||
# "-C", "link-arg=-nostartfiles",
|
||||
]
|
||||
|
||||
[build]
|
||||
target = "thumbv7em-none-eabihf"
|
||||
|
||||
[env]
|
||||
# DEFMT_LOG = "info"
|
1
rust-embedded/stm32f4-test/.gitignore
vendored
Normal file
1
rust-embedded/stm32f4-test/.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
/target
|
375
rust-embedded/stm32f4-test/Cargo.lock
generated
Normal file
375
rust-embedded/stm32f4-test/Cargo.lock
generated
Normal file
|
@ -0,0 +1,375 @@
|
|||
# This file is automatically @generated by Cargo.
|
||||
# It is not intended for manual editing.
|
||||
version = 3
|
||||
|
||||
[[package]]
|
||||
name = "bare-metal"
|
||||
version = "0.2.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5deb64efa5bd81e31fcd1938615a6d98c82eafcbcd787162b6f63b91d6bac5b3"
|
||||
dependencies = [
|
||||
"rustc_version",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "bare-metal"
|
||||
version = "1.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f8fe8f5a8a398345e52358e18ff07cc17a568fbca5c6f73873d3a62056309603"
|
||||
|
||||
[[package]]
|
||||
name = "bitfield"
|
||||
version = "0.13.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "46afbd2983a5d5a7bd740ccb198caf5b82f45c40c09c0eed36052d91cb92e719"
|
||||
|
||||
[[package]]
|
||||
name = "cortex-m"
|
||||
version = "0.7.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8ec610d8f49840a5b376c69663b6369e71f4b34484b9b2eb29fb918d92516cb9"
|
||||
dependencies = [
|
||||
"bare-metal 0.2.5",
|
||||
"bitfield",
|
||||
"critical-section",
|
||||
"embedded-hal 0.2.7",
|
||||
"volatile-register",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "cortex-m-rt"
|
||||
version = "0.7.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ee84e813d593101b1723e13ec38b6ab6abbdbaaa4546553f5395ed274079ddb1"
|
||||
dependencies = [
|
||||
"cortex-m-rt-macros",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "cortex-m-rt-macros"
|
||||
version = "0.7.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f0f6f3e36f203cfedbc78b357fb28730aa2c6dc1ab060ee5c2405e843988d3c7"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 1.0.109",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "critical-section"
|
||||
version = "1.1.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7059fff8937831a9ae6f0fe4d658ffabf58f2ca96aa9dec1c889f936f705f216"
|
||||
|
||||
[[package]]
|
||||
name = "deranged"
|
||||
version = "0.3.11"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b42b6fa04a440b495c8b04d0e71b707c585f83cb9cb28cf8cd0d976c315e31b4"
|
||||
dependencies = [
|
||||
"powerfmt",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "document-features"
|
||||
version = "0.2.8"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ef5282ad69563b5fc40319526ba27e0e7363d552a896f0297d54f767717f9b95"
|
||||
dependencies = [
|
||||
"litrs",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "embedded-dma"
|
||||
version = "0.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "994f7e5b5cb23521c22304927195f236813053eb9c065dd2226a32ba64695446"
|
||||
dependencies = [
|
||||
"stable_deref_trait",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "embedded-hal"
|
||||
version = "0.2.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "35949884794ad573cf46071e41c9b60efb0cb311e3ca01f7af807af1debc66ff"
|
||||
dependencies = [
|
||||
"nb 0.1.3",
|
||||
"void",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "embedded-hal"
|
||||
version = "1.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "361a90feb7004eca4019fb28352a9465666b24f840f5c3cddf0ff13920590b89"
|
||||
|
||||
[[package]]
|
||||
name = "embedded-hal-nb"
|
||||
version = "1.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "fba4268c14288c828995299e59b12babdbe170f6c6d73731af1b4648142e8605"
|
||||
dependencies = [
|
||||
"embedded-hal 1.0.0",
|
||||
"nb 1.1.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "embedded-storage"
|
||||
version = "0.3.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a21dea9854beb860f3062d10228ce9b976da520a73474aed3171ec276bc0c032"
|
||||
|
||||
[[package]]
|
||||
name = "enumflags2"
|
||||
version = "0.7.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3278c9d5fb675e0a51dabcf4c0d355f692b064171535ba72361be1528a9d8e8d"
|
||||
dependencies = [
|
||||
"enumflags2_derive",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "enumflags2_derive"
|
||||
version = "0.7.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5c785274071b1b420972453b306eeca06acf4633829db4223b58a2a8c5953bc4"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.55",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "fugit"
|
||||
version = "0.3.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "17186ad64927d5ac8f02c1e77ccefa08ccd9eaa314d5a4772278aa204a22f7e7"
|
||||
dependencies = [
|
||||
"gcd",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "fugit-timer"
|
||||
version = "0.1.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d9607bfc4c388f9d629704f56ede4a007546cad417b3bcd6fc7c87dc7edce04a"
|
||||
dependencies = [
|
||||
"fugit",
|
||||
"nb 1.1.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "gcd"
|
||||
version = "2.3.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1d758ba1b47b00caf47f24925c0074ecb20d6dfcffe7f6d53395c0465674841a"
|
||||
|
||||
[[package]]
|
||||
name = "litrs"
|
||||
version = "0.4.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b4ce301924b7887e9d637144fdade93f9dfff9b60981d4ac161db09720d39aa5"
|
||||
|
||||
[[package]]
|
||||
name = "nb"
|
||||
version = "0.1.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "801d31da0513b6ec5214e9bf433a77966320625a37860f910be265be6e18d06f"
|
||||
dependencies = [
|
||||
"nb 1.1.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "nb"
|
||||
version = "1.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8d5439c4ad607c3c23abf66de8c8bf57ba8adcd1f129e699851a6e43935d339d"
|
||||
|
||||
[[package]]
|
||||
name = "num-conv"
|
||||
version = "0.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "51d515d32fb182ee37cda2ccdcb92950d6a3c2893aa280e540671c2cd0f3b1d9"
|
||||
|
||||
[[package]]
|
||||
name = "panic-halt"
|
||||
version = "0.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "de96540e0ebde571dc55c73d60ef407c653844e6f9a1e2fdbd40c07b9252d812"
|
||||
|
||||
[[package]]
|
||||
name = "powerfmt"
|
||||
version = "0.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "439ee305def115ba05938db6eb1644ff94165c5ab5e9420d1c1bcedbba909391"
|
||||
|
||||
[[package]]
|
||||
name = "proc-macro2"
|
||||
version = "1.0.79"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e835ff2298f5721608eb1a980ecaee1aef2c132bf95ecc026a11b7bf3c01c02e"
|
||||
dependencies = [
|
||||
"unicode-ident",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "quote"
|
||||
version = "1.0.35"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "291ec9ab5efd934aaf503a6466c5d5251535d108ee747472c3977cc5acc868ef"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rand_core"
|
||||
version = "0.6.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c"
|
||||
|
||||
[[package]]
|
||||
name = "rustc_version"
|
||||
version = "0.2.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a"
|
||||
dependencies = [
|
||||
"semver",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "semver"
|
||||
version = "0.9.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403"
|
||||
dependencies = [
|
||||
"semver-parser",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "semver-parser"
|
||||
version = "0.7.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3"
|
||||
|
||||
[[package]]
|
||||
name = "stable_deref_trait"
|
||||
version = "1.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3"
|
||||
|
||||
[[package]]
|
||||
name = "stm32f4"
|
||||
version = "0.15.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "fb94729242cd1aebe6dab42a2ca0131985ae93bc3ab2751b680df724bb35528d"
|
||||
dependencies = [
|
||||
"bare-metal 1.0.0",
|
||||
"cortex-m",
|
||||
"cortex-m-rt",
|
||||
"vcell",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "stm32f4-test"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"cortex-m",
|
||||
"cortex-m-rt",
|
||||
"panic-halt",
|
||||
"stm32f4xx-hal",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "stm32f4xx-hal"
|
||||
version = "0.20.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "10c41454f262c0be0c35b8cfc0d971e598281f7a9be32e894dc97a0b21deadfe"
|
||||
dependencies = [
|
||||
"bare-metal 1.0.0",
|
||||
"cortex-m",
|
||||
"cortex-m-rt",
|
||||
"document-features",
|
||||
"embedded-dma",
|
||||
"embedded-hal 0.2.7",
|
||||
"embedded-hal 1.0.0",
|
||||
"embedded-hal-nb",
|
||||
"embedded-storage",
|
||||
"enumflags2",
|
||||
"fugit",
|
||||
"fugit-timer",
|
||||
"nb 1.1.0",
|
||||
"rand_core",
|
||||
"stm32f4",
|
||||
"time",
|
||||
"vcell",
|
||||
"void",
|
||||
]
|
||||
|
||||
[[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.55"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "002a1b3dbf967edfafc32655d0f377ab0bb7b994aa1d32c8cc7e9b8bf3ebb8f0"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"unicode-ident",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "time"
|
||||
version = "0.3.34"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c8248b6521bb14bc45b4067159b9b6ad792e2d6d754d6c41fb50e29fefe38749"
|
||||
dependencies = [
|
||||
"deranged",
|
||||
"num-conv",
|
||||
"powerfmt",
|
||||
"time-core",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "time-core"
|
||||
version = "0.1.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ef927ca75afb808a4d64dd374f00a2adf8d0fcff8e7b184af886c3c87ec4a3f3"
|
||||
|
||||
[[package]]
|
||||
name = "unicode-ident"
|
||||
version = "1.0.12"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b"
|
||||
|
||||
[[package]]
|
||||
name = "vcell"
|
||||
version = "0.1.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "77439c1b53d2303b20d9459b1ade71a83c716e3f9c34f3228c00e6f185d6c002"
|
||||
|
||||
[[package]]
|
||||
name = "void"
|
||||
version = "1.0.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6a02e4885ed3bc0f2de90ea6dd45ebcbb66dacffe03547fadbb0eeae2770887d"
|
||||
|
||||
[[package]]
|
||||
name = "volatile-register"
|
||||
version = "0.2.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "de437e2a6208b014ab52972a27e59b33fa2920d3e00fe05026167a1c509d19cc"
|
||||
dependencies = [
|
||||
"vcell",
|
||||
]
|
26
rust-embedded/stm32f4-test/Cargo.toml
Normal file
26
rust-embedded/stm32f4-test/Cargo.toml
Normal file
|
@ -0,0 +1,26 @@
|
|||
[package]
|
||||
name = "stm32f4-test"
|
||||
version = "0.1.0"
|
||||
authors = ["Artemis Tosini <me@artem.ist>"]
|
||||
edition = "2021"
|
||||
|
||||
[dependencies]
|
||||
cortex-m = "0.7"
|
||||
cortex-m-rt = "0.7"
|
||||
panic-halt = "0.2.0"
|
||||
|
||||
|
||||
[dependencies.stm32f4xx-hal]
|
||||
version = "0.20.0"
|
||||
features = ["stm32f407", ]
|
||||
|
||||
# Set the default for dependencies.
|
||||
[profile.dev.package."*"]
|
||||
opt-level = "s"
|
||||
|
||||
[profile.release]
|
||||
codegen-units = 1
|
||||
incremental = false
|
||||
debug = true
|
||||
lto = true
|
||||
opt-level = "s"
|
82
rust-embedded/stm32f4-test/Embed.toml
Normal file
82
rust-embedded/stm32f4-test/Embed.toml
Normal file
|
@ -0,0 +1,82 @@
|
|||
[default.probe]
|
||||
# USB vendor ID
|
||||
# usb_vid = "1337"
|
||||
# USB product ID
|
||||
# usb_pid = "1337"
|
||||
# Serial number
|
||||
# serial = "12345678"
|
||||
# The protocol to be used for communicating with the target.
|
||||
protocol = "Swd"
|
||||
# The speed in kHz of the data link to the target.
|
||||
# speed = 1337
|
||||
|
||||
[default.flashing]
|
||||
# Whether or not the target should be flashed.
|
||||
enabled = true
|
||||
# Whether or not the target should be halted after reset.
|
||||
# DEPRECATED, moved to reset section
|
||||
halt_afterwards = false
|
||||
# Whether or not bytes erased but not rewritten with data from the ELF
|
||||
# should be restored with their contents before erasing.
|
||||
restore_unwritten_bytes = false
|
||||
# The path where an SVG of the assembled flash layout should be written to.
|
||||
# flash_layout_output_path = "out.svg"
|
||||
# Triggers a full chip erase instead of a page by page erase.
|
||||
do_chip_erase = false
|
||||
|
||||
[default.reset]
|
||||
# Whether or not the target should be reset.
|
||||
# When flashing is enabled as well, the target will be reset after flashing.
|
||||
enabled = true
|
||||
# Whether or not the target should be halted after reset.
|
||||
halt_afterwards = false
|
||||
|
||||
[default.general]
|
||||
# The chip name of the chip to be debugged.
|
||||
chip = "STM32F407VGTx"
|
||||
# A list of chip descriptions to be loaded during runtime.
|
||||
chip_descriptions = []
|
||||
# The default log level to be used. Possible values are one of:
|
||||
# "OFF", "ERROR", "WARN", "INFO", "DEBUG", "TRACE"
|
||||
log_level = "WARN"
|
||||
# Use this flag to assert the nreset & ntrst pins during attaching the probe to the chip.
|
||||
connect_under_reset = false
|
||||
|
||||
[default.rtt]
|
||||
# Whether or not an RTTUI should be opened after flashing.
|
||||
enabled = false
|
||||
# How the target handles RTT outputs that won't fit in the buffer. This can be
|
||||
# overridden per-channel. If left unset, the firmware will determine the default
|
||||
# for each RTT up channel.
|
||||
# NoBlockSkip - Skip writing the data completely if it doesn't fit in its
|
||||
# entirety.
|
||||
# NoBlockTrim - Write as much as possible of the data and ignore the rest.
|
||||
# BlockIfFull - Spin until the host reads data. Can result in app freezing.
|
||||
#
|
||||
# up_mode = "BlockIfFull"
|
||||
|
||||
# A list of channel associations to be displayed. If left empty, all channels are displayed.
|
||||
# up, down (Optional) - RTT channel numbers
|
||||
# name (Optional) - String to be displayed in the RTTUI tab
|
||||
# up_mode (Optional) - RTT channel specific as described above
|
||||
# format (Required) - How to interpret data from target firmware. One of:
|
||||
# String - Directly show output from the target
|
||||
# Defmt - Format output on the host, see https://defmt.ferrous-systems.com/
|
||||
# BinaryLE - Display as raw hex
|
||||
channels = [
|
||||
# { up = 0, down = 0, name = "name", up_mode = "BlockIfFull", format = "Defmt" },
|
||||
]
|
||||
# The duration in ms for which the logger should retry to attach to RTT.
|
||||
timeout = 3000
|
||||
# Whether timestamps in the RTTUI are enabled
|
||||
show_timestamps = true
|
||||
# Whether to save rtt history buffer on exit.
|
||||
log_enabled = false
|
||||
# Where to save rtt history buffer relative to manifest path.
|
||||
log_path = "./logs"
|
||||
|
||||
[default.gdb]
|
||||
# Whether or not a GDB server should be opened after flashing.
|
||||
enabled = false
|
||||
# The connection string in host:port format wher the GDB server will open a socket.
|
||||
gdb_connection_string = "127.0.0.1:1337"
|
65
rust-embedded/stm32f4-test/README.md
Normal file
65
rust-embedded/stm32f4-test/README.md
Normal file
|
@ -0,0 +1,65 @@
|
|||
# `stm32-template`
|
||||
|
||||
> A template for building applications for STM32 microcontrollers
|
||||
|
||||
## Dependencies
|
||||
|
||||
To build embedded programs using this template you'll need:
|
||||
|
||||
- The `cargo generate` subcommand. [Installation
|
||||
instructions](https://github.com/cargo-generate/cargo-generate#installation).
|
||||
``` console
|
||||
$ cargo install cargo-generate
|
||||
```
|
||||
|
||||
- Flash and run/debug tools:
|
||||
``` console
|
||||
$ cargo install probe-rs --features cli
|
||||
```
|
||||
|
||||
- `rust-std` components (pre-compiled `core` crate) for the ARM Cortex-M
|
||||
targets. Run:
|
||||
|
||||
``` console
|
||||
$ rustup target add thumbv6m-none-eabi thumbv7m-none-eabi thumbv7em-none-eabi thumbv7em-none-eabihf
|
||||
```
|
||||
|
||||
## Instantiate the template.
|
||||
|
||||
1. Run and enter project name
|
||||
``` console
|
||||
$ cargo generate --git https://github.com/burrbull/stm32-template/
|
||||
Project Name: app
|
||||
```
|
||||
|
||||
2. Specify **chip product name** and answer on several other guide questions.
|
||||
|
||||
3. Your program is ready to compile:
|
||||
``` console
|
||||
$ cargo build --release
|
||||
```
|
||||
|
||||
## Flash and run/debug
|
||||
|
||||
You can flash your firmware using one of those tools:
|
||||
|
||||
- `cargo flash --release` — just flash
|
||||
- `cargo run --release` — flash and run using `probe-rs run` runner or `probe-run` runner (deprecated) which you can set in `.cargo/config.toml`
|
||||
- `cargo embed --release` — multifunctional tool for flash and debug
|
||||
|
||||
You also can debug your firmware on device from VS Code with [probe-rs](https://probe.rs/docs/tools/vscode/) extention or with `probe-rs gdb` command.
|
||||
You will need SVD specification for your chip for this. You can load patched SVD files [here](https://stm32-rs.github.io/stm32-rs/).
|
||||
|
||||
## Contribution
|
||||
|
||||
Unless you explicitly state otherwise, any contribution intentionally submitted
|
||||
for inclusion in the work by you, as defined in the Apache-2.0 license, shall be
|
||||
dual licensed as above, without any additional terms or conditions.
|
||||
|
||||
## Code of Conduct
|
||||
|
||||
Contribution to this crate is organized under the terms of the [Rust Code of
|
||||
Conduct][CoC], the maintainer of this crate, promises
|
||||
to intervene to uphold that code of conduct.
|
||||
|
||||
[CoC]: https://www.rust-lang.org/policies/code-of-conduct
|
15
rust-embedded/stm32f4-test/memory.x
Normal file
15
rust-embedded/stm32f4-test/memory.x
Normal file
|
@ -0,0 +1,15 @@
|
|||
MEMORY
|
||||
{
|
||||
/* NOTE K = KiBi = 1024 bytes */
|
||||
FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 1024K
|
||||
CCMRAM (rwx) : ORIGIN = 0x10000000, LENGTH = 64K
|
||||
RAM (rwx) : ORIGIN = 0x20000000, LENGTH = 128K
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/* This is where the call stack will be allocated. */
|
||||
/* The stack is of the full descending type. */
|
||||
/* NOTE Do NOT modify `_stack_start` unless you know what you are doing */
|
||||
_stack_start = ORIGIN(RAM) + LENGTH(RAM);
|
45
rust-embedded/stm32f4-test/src/main.rs
Normal file
45
rust-embedded/stm32f4-test/src/main.rs
Normal file
|
@ -0,0 +1,45 @@
|
|||
#![deny(unsafe_code)]
|
||||
#![no_main]
|
||||
#![no_std]
|
||||
|
||||
// Halt on panic
|
||||
use panic_halt as _;
|
||||
|
||||
use cortex_m_rt::entry;
|
||||
use stm32f4xx_hal::{gpio::PinState, pac, prelude::*};
|
||||
|
||||
#[entry]
|
||||
fn main() -> ! {
|
||||
let p = pac::Peripherals::take().unwrap();
|
||||
let cp = cortex_m::Peripherals::take().unwrap();
|
||||
|
||||
let gpiod = p.GPIOD.split();
|
||||
let mut leds = [
|
||||
gpiod
|
||||
.pd12
|
||||
.into_push_pull_output_in_state(PinState::Low)
|
||||
.erase(),
|
||||
gpiod
|
||||
.pd13
|
||||
.into_push_pull_output_in_state(PinState::Low)
|
||||
.erase(),
|
||||
gpiod
|
||||
.pd14
|
||||
.into_push_pull_output_in_state(PinState::Low)
|
||||
.erase(),
|
||||
gpiod
|
||||
.pd15
|
||||
.into_push_pull_output_in_state(PinState::Low)
|
||||
.erase(),
|
||||
];
|
||||
let rcc = p.RCC.constrain();
|
||||
let clocks = rcc.cfgr.sysclk(48.MHz()).freeze();
|
||||
let mut delay = cp.SYST.delay(&clocks);
|
||||
|
||||
loop {
|
||||
for led in leds.iter_mut() {
|
||||
led.toggle();
|
||||
delay.delay_ms(250);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue