From 20fe8552caadaf69a8944c1f43905f2f5d7f2108 Mon Sep 17 00:00:00 2001 From: Martin Milata Date: Wed, 19 May 2021 12:07:58 +0200 Subject: [PATCH] build(core/rust): use correct architecture for T1 TT is Cortex-M4 is Armv7E-M while T1 is Cortex-M3 is Armv7-M: https://community.arm.com/developer/ip-products/processors/b/processors-ip-blog/posts/armv6-m-vs-armv7-m---unpacking-the-microcontrollers --- core/SConscript.firmware | 2 +- core/embed/rust/build.rs | 11 +++++++---- 2 files changed, 8 insertions(+), 5 deletions(-) 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") +}