From 861ad3819154d4a919809f6683171c052770da3b Mon Sep 17 00:00:00 2001 From: cscherr Date: Thu, 17 Apr 2025 16:41:03 +0200 Subject: [PATCH] feat: add linker stuff properly but it does not work --- Cargo.toml | 2 ++ build.rs | 17 +++++++++++++++++ 2 files changed, 19 insertions(+) create mode 100755 build.rs diff --git a/Cargo.toml b/Cargo.toml index 0813353..d003b88 100755 --- a/Cargo.toml +++ b/Cargo.toml @@ -14,7 +14,9 @@ hal = { package = "stm32l0xx-hal", version = "0.10.0", features = [ "stm32l0x3", "flash-192", "ram-20", + "io-STM32L051", # "mcu-STM32L053R8", # does not exist in that crate + "disable-linker-script", ] } [[bin]] diff --git a/build.rs b/build.rs new file mode 100755 index 0000000..88f7fef --- /dev/null +++ b/build.rs @@ -0,0 +1,17 @@ +use std::env; +use std::fs::File; +use std::io::Write; +use std::path::PathBuf; + +fn main() { + // Put the linker script somewhere the linker can find it + 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()); + + println!("cargo:rerun-if-changed=build.rs"); + println!("cargo:rerun-if-changed=memory.x"); +}