1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-12-24 23:38:09 +00:00

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
This commit is contained in:
Martin Milata 2021-05-19 12:07:58 +02:00
parent 6fd4739c5c
commit 20fe8552ca
2 changed files with 8 additions and 5 deletions

View File

@ -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')

View File

@ -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")
}