79799959

Date: 2025-10-26 09:53:28
Score: 1
Natty:
Report link

Funny that the answer really is this stupid easy,

after defining build.rs in our project directory:

use std::{env, path::PathBuf};


fn main() {
    // Use cortex-m-rt's linker script
    println!("cargo:rustc-link-arg=-Tlink.x");

    // Make the *containing directory* of memory.x visible to the linker
    let manifest_dir = PathBuf::from(env::var("CARGO_MANIFEST_DIR").unwrap());
    println!("cargo:rustc-link-search={}", manifest_dir.display());

    // Rebuild if memory.x changes
    println!(
        "cargo:rerun-if-changed={}",
        manifest_dir.join("memory.x").display()
    );
}

we got this error showing the root of problem once the memory.x script was finally being used:

memory.x:5: redefinition of memory region 'FLASH' 
\>\>\> REGION_ALIAS(FLASH, FLASH); \>\>\> 
^ error: could not compile stm32_firmware (bin "stm32_firmware") due to 1 previous error  

so quite literally just needed to remove the REGION_ALIAS(FLASH, FLASH); line and the binary is looking scrumptious now

@thebusybee thanks to him for letting me know verbose still exists lol. using the verbose appendage I confirmed the linker flags are being appended to the build commands defined in the .config file ruling that out, revealing the memory.x wasn't being used in the first place

Reasons:
  • Blacklisted phrase (0.5): thanks
  • Long answer (-1):
  • Has code block (-0.5):
  • User mentioned (1): @thebusybee
  • Self-answer (0.5):
  • Low reputation (0.5):
Posted by: gauss