These are my codes:
.cargo/config.toml:
[build]
target = "thumbv6m-none-eabi"
[target.thumbv6m-none-eabi]
runner = "probe-rs run --chip STM32G070RBT6"
linker = "arm-none-eabi-ld"
rustflags = [
"-C", "link-arg=-Tlink.x",
"-C", "link-arg=-Tdefmt.x"
]
[profile.dev]
opt-level = "s"
[profile.release]
debug = 2
opt-level = "z" # Otimização de tamanho
lto = true # Link Time Optimization
build.rs:
fn main() {
println!("cargo:rustc-link-arg-bins=--nmagic");
println!("cargo:rustc-link-arg-bins=-Tlink.x");
println!("cargo:rustc-link-arg-bins=-Tdefmt.x");
}
Cargo.toml:
[package]
name = "testeLed"
version = "0.1.0"
edition = "2021"
license = "MIT OR Apache-2.0"
[dependencies]
cortex-m = { version = "0.7.7", features = ["inline-asm", "critical-section-single-core"] }
cortex-m-rt = "0.7.3" #em vez de 3 tava 1
lilos = "1.2.0"
panic-halt = "0.2.0"
embedded-hal = "1.0.0"
stm32g0 = { version = "0.15.1", default-features = false, features = ["rt", "stm32g070"] }
stm32g0xx-hal = { version = "0.2.0", features = ["rt", "stm32g070"] }
nb = "1.1.0"
panic-probe = { version = "0.3.2", features = ["print-defmt"] }
defmt = "0.3.8"
defmt-rtt = "0.4.1"
heapless = { version = "0.8.0", default-features = false }
embed.toml:
[default.probe]
protocol = "Swd"
[default.general]
chip = "STM32G070RBTx" # bluepill
#chip = "STM32F303VCTx" # discovery-stm32f303
[default.rtt]
enabled = false
[default.gdb]
enabled = false
memory.x:
/* Linker script para STM32G070RBT6 */
MEMORY {
/* NOTE K = KiBi = 1024 bytes */
FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 128K
RAM (rwx) : ORIGIN = 0x20000000, LENGTH = 36K
}
It's very confusing!