diff --git a/core/SConscript.firmware b/core/SConscript.firmware index 6c5ccecd5f..050ba9b06a 100644 --- a/core/SConscript.firmware +++ b/core/SConscript.firmware @@ -400,7 +400,7 @@ elif TREZOR_MODEL == '1': CPU_CCFLAGS = '-mthumb -mtune=cortex-m3 -mcpu=cortex-m3 -mfloat-abi=soft ' CPU_MODEL = 'STM32F405xx' LD_VARIANT = '' if EVERYTHING else '_min' - RUST_TARGET = 'thumbv7em-none-eabi' + RUST_TARGET = 'thumbv7m-none-eabi' else: raise ValueError('Unknown Trezor model') diff --git a/core/embed/rust/build.rs b/core/embed/rust/build.rs index c675e45927..b9ec24932c 100644 --- a/core/embed/rust/build.rs +++ b/core/embed/rust/build.rs @@ -8,7 +8,6 @@ fn main() { /// Generates Rust module that exports QSTR constants used in firmware. fn generate_qstr_bindings() { let out_path = env::var("OUT_DIR").unwrap(); - let target = env::var("TARGET").unwrap(); // Tell cargo to invalidate the built crate whenever the header changes. println!("cargo:rerun-if-changed=qstr.h"); @@ -20,7 +19,7 @@ fn generate_qstr_bindings() { // Pass in correct include paths. .clang_args(&[ "-I", - if target.starts_with("thumbv7em-none-eabi") { + if is_firmware() { "../../build/firmware" } else { "../../build/unix" @@ -41,7 +40,6 @@ fn generate_qstr_bindings() { fn generate_micropython_bindings() { let out_path = env::var("OUT_DIR").unwrap(); - let target = env::var("TARGET").unwrap(); // Tell cargo to invalidate the built crate whenever the header changes. println!("cargo:rerun-if-changed=micropython.h"); @@ -107,7 +105,7 @@ fn generate_micropython_bindings() { bindings = bindings.no_copy("_mp_map_t"); // Pass in correct include paths and defines. - if target.starts_with("thumbv7em-none-eabi") { + if is_firmware() { bindings = bindings.clang_args(&[ "-nostdinc", "-I../firmware", @@ -164,3 +162,8 @@ fn generate_micropython_bindings() { .write_to_file(PathBuf::from(out_path).join("micropython.rs")) .unwrap(); } + +fn is_firmware() -> bool { + let target = env::var("TARGET").unwrap(); + target.starts_with("thumbv7") +}