2021-11-24 02:18:30 +00:00
|
|
|
use std::error::Error;
|
|
|
|
use std::path::PathBuf;
|
|
|
|
use std::{env, fs};
|
|
|
|
|
|
|
|
fn main() -> Result<(), Box<dyn Error>> {
|
|
|
|
let out = PathBuf::from(env::var("OUT_DIR").unwrap());
|
2024-01-05 12:58:57 +00:00
|
|
|
fs::write(out.join("link_ram.x"), include_bytes!("../link_ram_cortex_m.x")).unwrap();
|
2021-11-24 02:18:30 +00:00
|
|
|
println!("cargo:rustc-link-search={}", out.display());
|
|
|
|
println!("cargo:rustc-link-arg-bins=--nmagic");
|
2023-04-11 11:37:10 +00:00
|
|
|
|
2023-05-27 20:05:50 +00:00
|
|
|
if cfg!(any(
|
2023-10-17 13:49:20 +00:00
|
|
|
// too little RAM to run from RAM.
|
2023-05-27 20:05:50 +00:00
|
|
|
feature = "stm32f103c8",
|
|
|
|
feature = "stm32c031c6",
|
2023-09-26 03:16:26 +00:00
|
|
|
feature = "stm32wb55rg",
|
|
|
|
feature = "stm32l073rz",
|
2023-10-17 13:49:20 +00:00
|
|
|
// wrong ram size in stm32-data
|
|
|
|
feature = "stm32wl55jc",
|
2024-02-23 00:33:37 +00:00
|
|
|
feature = "stm32u5a5zj",
|
2024-02-17 01:36:48 +00:00
|
|
|
// no VTOR, so interrupts can't work when running from RAM
|
|
|
|
feature = "stm32f091rc",
|
2023-05-27 20:05:50 +00:00
|
|
|
)) {
|
2023-05-02 00:52:37 +00:00
|
|
|
println!("cargo:rustc-link-arg-bins=-Tlink.x");
|
|
|
|
println!("cargo:rerun-if-changed=link.x");
|
|
|
|
} else {
|
|
|
|
println!("cargo:rustc-link-arg-bins=-Tlink_ram.x");
|
|
|
|
println!("cargo:rerun-if-changed=link_ram.x");
|
|
|
|
}
|
2023-04-11 11:37:10 +00:00
|
|
|
|
2023-05-27 20:05:50 +00:00
|
|
|
if cfg!(feature = "stm32wb55rg") {
|
|
|
|
println!("cargo:rustc-link-arg-bins=-Ttl_mbox.x");
|
|
|
|
}
|
|
|
|
|
2021-11-24 02:18:30 +00:00
|
|
|
println!("cargo:rustc-link-arg-bins=-Tdefmt.x");
|
2023-05-29 22:10:36 +00:00
|
|
|
println!("cargo:rustc-link-arg-bins=-Tteleprobe.x");
|
2021-11-24 02:18:30 +00:00
|
|
|
|
|
|
|
Ok(())
|
|
|
|
}
|