mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-11-21 23:18:13 +00:00
refactor(core): rust bindgen mcu-type related arguments are taken from board definition
[no changelog]
This commit is contained in:
parent
6dbeba9730
commit
eca1fc381b
@ -185,6 +185,7 @@ env.Replace(
|
|||||||
'HW_REVISION=' + ('6' if TREZOR_MODEL in ('R',) else '0'),
|
'HW_REVISION=' + ('6' if TREZOR_MODEL in ('R',) else '0'),
|
||||||
'TREZOR_MODEL_'+TREZOR_MODEL,
|
'TREZOR_MODEL_'+TREZOR_MODEL,
|
||||||
'TREZOR_BOARD=\\"boards/board-unix.h\\"',
|
'TREZOR_BOARD=\\"boards/board-unix.h\\"',
|
||||||
|
'MCU_TYPE='+CPU_MODEL,
|
||||||
'PB_FIELD_16BIT',
|
'PB_FIELD_16BIT',
|
||||||
'PB_ENCODE_ARRAYS_UNPACKED',
|
'PB_ENCODE_ARRAYS_UNPACKED',
|
||||||
'PB_VALIDATE_UTF8',
|
'PB_VALIDATE_UTF8',
|
||||||
|
@ -481,6 +481,7 @@ env.Replace(
|
|||||||
'TREZOR_EMULATOR',
|
'TREZOR_EMULATOR',
|
||||||
'TREZOR_MODEL_'+TREZOR_MODEL,
|
'TREZOR_MODEL_'+TREZOR_MODEL,
|
||||||
'TREZOR_BOARD=\\"boards/board-unix.h\\"',
|
'TREZOR_BOARD=\\"boards/board-unix.h\\"',
|
||||||
|
'MCU_TYPE='+CPU_MODEL,
|
||||||
('MP_CONFIGFILE', '\\"embed/unix/mpconfigport.h\\"'),
|
('MP_CONFIGFILE', '\\"embed/unix/mpconfigport.h\\"'),
|
||||||
] + CPPDEFINES_MOD,
|
] + CPPDEFINES_MOD,
|
||||||
ASPPFLAGS='$CFLAGS $CCFLAGS', )
|
ASPPFLAGS='$CFLAGS $CCFLAGS', )
|
||||||
|
@ -12,6 +12,13 @@ fn main() {
|
|||||||
link_core_objects();
|
link_core_objects();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn mcu_type() -> String {
|
||||||
|
match env::var("MCU_TYPE") {
|
||||||
|
Ok(mcu) => mcu,
|
||||||
|
Err(_) => String::from("STM32F427xx"),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fn model() -> String {
|
fn model() -> String {
|
||||||
match env::var("TREZOR_MODEL") {
|
match env::var("TREZOR_MODEL") {
|
||||||
Ok(model) => model,
|
Ok(model) => model,
|
||||||
@ -77,24 +84,28 @@ fn prepare_bindings() -> bindgen::Builder {
|
|||||||
"-I../../vendor/micropython/lib/uzlib",
|
"-I../../vendor/micropython/lib/uzlib",
|
||||||
"-I../lib",
|
"-I../lib",
|
||||||
"-I../trezorhal",
|
"-I../trezorhal",
|
||||||
"-DSTM32F427xx",
|
format!("-D{}", mcu_type()).as_str(),
|
||||||
format!("-DTREZOR_MODEL_{}", model()).as_str(),
|
format!("-DTREZOR_MODEL_{}", model()).as_str(),
|
||||||
format!("-DTREZOR_BOARD=\"{}\"", board()).as_str(),
|
format!("-DTREZOR_BOARD=\"{}\"", board()).as_str(),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
// Pass in correct include paths and defines.
|
// Pass in correct include paths and defines.
|
||||||
if is_firmware() {
|
if is_firmware() {
|
||||||
bindings = bindings.clang_args(&[
|
let mut clang_args: Vec<&str> = Vec::new();
|
||||||
"-nostdinc",
|
|
||||||
"-I../firmware",
|
let includes = env::var("RUST_INCLUDES").unwrap();
|
||||||
"-I../trezorhal/stm32f4",
|
let args = includes.split(";");
|
||||||
"-I../../build/firmware",
|
|
||||||
"-I../../vendor/micropython/lib/stm32lib/STM32F4xx_HAL_Driver/Inc",
|
for arg in args {
|
||||||
"-I../../vendor/micropython/lib/stm32lib/CMSIS/STM32F4xx/Include",
|
clang_args.push(arg);
|
||||||
"-I../../vendor/micropython/lib/cmsis/inc",
|
}
|
||||||
"-DUSE_HAL_DRIVER",
|
clang_args.push("-nostdinc");
|
||||||
"-DSTM32_HAL_H=<stm32f4xx.h>",
|
clang_args.push("-I../firmware");
|
||||||
]);
|
clang_args.push("-I../../build/firmware");
|
||||||
|
clang_args.push("-I../../vendor/micropython/lib/cmsis/inc");
|
||||||
|
clang_args.push("-DUSE_HAL_DRIVER");
|
||||||
|
bindings = bindings.clang_args(&clang_args);
|
||||||
|
|
||||||
// Append gcc-arm-none-eabi's include paths.
|
// Append gcc-arm-none-eabi's include paths.
|
||||||
let cc_output = Command::new("arm-none-eabi-gcc")
|
let cc_output = Command::new("arm-none-eabi-gcc")
|
||||||
.arg("-E")
|
.arg("-E")
|
||||||
|
@ -16,13 +16,15 @@ def configure(
|
|||||||
hw_model = get_hw_model_as_number("D001")
|
hw_model = get_hw_model_as_number("D001")
|
||||||
hw_revision = 0
|
hw_revision = 0
|
||||||
|
|
||||||
stm32f4_common_files(defines, sources, paths)
|
mcu = "STM32F429xx"
|
||||||
|
|
||||||
|
stm32f4_common_files(env, defines, sources, paths)
|
||||||
|
|
||||||
env.get("ENV")['CPU_ASFLAGS'] = '-mthumb -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16'
|
env.get("ENV")['CPU_ASFLAGS'] = '-mthumb -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16'
|
||||||
env.get("ENV")['CPU_CCFLAGS'] = '-mthumb -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16 -mtune=cortex-m4 '
|
env.get("ENV")['CPU_CCFLAGS'] = '-mthumb -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16 -mtune=cortex-m4 '
|
||||||
env.get("ENV")['RUST_TARGET'] = 'thumbv7em-none-eabihf'
|
env.get("ENV")['RUST_TARGET'] = 'thumbv7em-none-eabihf'
|
||||||
|
|
||||||
defines += ["STM32F429xx"]
|
defines += [mcu]
|
||||||
defines += [f'TREZOR_BOARD=\\"boards/{board}\\"']
|
defines += [f'TREZOR_BOARD=\\"boards/{board}\\"']
|
||||||
defines += [f"HW_MODEL={hw_model}"]
|
defines += [f"HW_MODEL={hw_model}"]
|
||||||
defines += [f"HW_REVISION={hw_revision}"]
|
defines += [f"HW_REVISION={hw_revision}"]
|
||||||
@ -53,5 +55,6 @@ def configure(
|
|||||||
features_available.append("usb")
|
features_available.append("usb")
|
||||||
|
|
||||||
env.get("ENV")["TREZOR_BOARD"] = board
|
env.get("ENV")["TREZOR_BOARD"] = board
|
||||||
|
env.get("ENV")["MCU_TYPE"] = mcu
|
||||||
|
|
||||||
return features_available
|
return features_available
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
|
|
||||||
def stm32f4_common_files(defines, sources, paths):
|
def stm32f4_common_files(env, defines, sources, paths):
|
||||||
defines += [
|
defines += [
|
||||||
('STM32_HAL_H', '"<stm32f4xx.h>"'),
|
('STM32_HAL_H', '"<stm32f4xx.h>"'),
|
||||||
]
|
]
|
||||||
@ -50,3 +50,11 @@ def stm32f4_common_files(defines, sources, paths):
|
|||||||
'embed/trezorhal/stm32f4/vectortable.s',
|
'embed/trezorhal/stm32f4/vectortable.s',
|
||||||
]
|
]
|
||||||
|
|
||||||
|
env.get("ENV")["RUST_INCLUDES"] = \
|
||||||
|
"-I../trezorhal/stm32f4;" \
|
||||||
|
"-I../../vendor/micropython/lib/stm32lib/STM32F4xx_HAL_Driver/Inc;"\
|
||||||
|
"-I../../vendor/micropython/lib/stm32lib/CMSIS/STM32F4xx/Include;"\
|
||||||
|
"-DSTM32_HAL_H=<stm32f4xx.h>"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -17,13 +17,15 @@ def configure(
|
|||||||
hw_model = get_hw_model_as_number("T1B1")
|
hw_model = get_hw_model_as_number("T1B1")
|
||||||
hw_revision = 0
|
hw_revision = 0
|
||||||
|
|
||||||
stm32f4_common_files(defines, sources, paths)
|
mcu = "STM32F405xx"
|
||||||
|
|
||||||
|
stm32f4_common_files(env, defines, sources, paths)
|
||||||
|
|
||||||
env.get("ENV")['CPU_ASFLAGS'] = '-mthumb -mcpu=cortex-m3 -mfloat-abi=soft'
|
env.get("ENV")['CPU_ASFLAGS'] = '-mthumb -mcpu=cortex-m3 -mfloat-abi=soft'
|
||||||
env.get("ENV")['CPU_CCFLAGS'] = '-mthumb -mtune=cortex-m3 -mcpu=cortex-m3 -mfloat-abi=soft '
|
env.get("ENV")['CPU_CCFLAGS'] = '-mthumb -mtune=cortex-m3 -mcpu=cortex-m3 -mfloat-abi=soft '
|
||||||
env.get("ENV")['RUST_TARGET'] = 'thumbv7m-none-eabi'
|
env.get("ENV")['RUST_TARGET'] = 'thumbv7m-none-eabi'
|
||||||
|
|
||||||
defines += ["STM32F405xx"]
|
defines += [mcu]
|
||||||
defines += [f'TREZOR_BOARD=\\"boards/{board}\\"']
|
defines += [f'TREZOR_BOARD=\\"boards/{board}\\"']
|
||||||
defines += [f"HW_MODEL={hw_model}"]
|
defines += [f"HW_MODEL={hw_model}"]
|
||||||
defines += [f"HW_REVISION={hw_revision}"]
|
defines += [f"HW_REVISION={hw_revision}"]
|
||||||
@ -45,5 +47,6 @@ def configure(
|
|||||||
features_available.append("usb")
|
features_available.append("usb")
|
||||||
|
|
||||||
env.get("ENV")["TREZOR_BOARD"] = board
|
env.get("ENV")["TREZOR_BOARD"] = board
|
||||||
|
env.get("ENV")["MCU_TYPE"] = mcu
|
||||||
|
|
||||||
return features_available
|
return features_available
|
||||||
|
@ -17,13 +17,15 @@ def configure(
|
|||||||
board = "trezor_r_v10.h"
|
board = "trezor_r_v10.h"
|
||||||
display = "vg-2864ksweg01.c"
|
display = "vg-2864ksweg01.c"
|
||||||
|
|
||||||
stm32f4_common_files(defines, sources, paths)
|
mcu = "STM32F427xx"
|
||||||
|
|
||||||
|
stm32f4_common_files(env, defines, sources, paths)
|
||||||
|
|
||||||
env.get("ENV")['CPU_ASFLAGS'] = '-mthumb -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16'
|
env.get("ENV")['CPU_ASFLAGS'] = '-mthumb -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16'
|
||||||
env.get("ENV")['CPU_CCFLAGS'] = '-mthumb -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16 -mtune=cortex-m4 '
|
env.get("ENV")['CPU_CCFLAGS'] = '-mthumb -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16 -mtune=cortex-m4 '
|
||||||
env.get("ENV")['RUST_TARGET'] = 'thumbv7em-none-eabihf'
|
env.get("ENV")['RUST_TARGET'] = 'thumbv7em-none-eabihf'
|
||||||
|
|
||||||
defines += ["STM32F427xx"]
|
defines += [mcu]
|
||||||
defines += [f'TREZOR_BOARD=\\"boards/{board}\\"']
|
defines += [f'TREZOR_BOARD=\\"boards/{board}\\"']
|
||||||
defines += [f"HW_MODEL={hw_model}"]
|
defines += [f"HW_MODEL={hw_model}"]
|
||||||
defines += [f"HW_REVISION={hw_revision}"]
|
defines += [f"HW_REVISION={hw_revision}"]
|
||||||
@ -56,5 +58,6 @@ def configure(
|
|||||||
features_available.append("usb")
|
features_available.append("usb")
|
||||||
|
|
||||||
env.get("ENV")["TREZOR_BOARD"] = board
|
env.get("ENV")["TREZOR_BOARD"] = board
|
||||||
|
env.get("ENV")["MCU_TYPE"] = mcu
|
||||||
|
|
||||||
return features_available
|
return features_available
|
||||||
|
@ -17,13 +17,15 @@ def configure(
|
|||||||
board = "trezor_r_v3.h"
|
board = "trezor_r_v3.h"
|
||||||
display = "ug-2828tswig01.c"
|
display = "ug-2828tswig01.c"
|
||||||
|
|
||||||
stm32f4_common_files(defines, sources, paths)
|
mcu = "STM32F427xx"
|
||||||
|
|
||||||
|
stm32f4_common_files(env, defines, sources, paths)
|
||||||
|
|
||||||
env.get("ENV")['CPU_ASFLAGS'] = '-mthumb -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16'
|
env.get("ENV")['CPU_ASFLAGS'] = '-mthumb -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16'
|
||||||
env.get("ENV")['CPU_CCFLAGS'] = '-mthumb -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16 -mtune=cortex-m4 '
|
env.get("ENV")['CPU_CCFLAGS'] = '-mthumb -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16 -mtune=cortex-m4 '
|
||||||
env.get("ENV")['RUST_TARGET'] = 'thumbv7em-none-eabihf'
|
env.get("ENV")['RUST_TARGET'] = 'thumbv7em-none-eabihf'
|
||||||
|
|
||||||
defines += ["STM32F427xx"]
|
defines += [mcu]
|
||||||
defines += [f'TREZOR_BOARD=\\"boards/{board}\\"']
|
defines += [f'TREZOR_BOARD=\\"boards/{board}\\"']
|
||||||
defines += [f"HW_MODEL={hw_model}"]
|
defines += [f"HW_MODEL={hw_model}"]
|
||||||
defines += [f"HW_REVISION={hw_revision}"]
|
defines += [f"HW_REVISION={hw_revision}"]
|
||||||
@ -53,5 +55,6 @@ def configure(
|
|||||||
features_available.append("usb")
|
features_available.append("usb")
|
||||||
|
|
||||||
env.get("ENV")["TREZOR_BOARD"] = board
|
env.get("ENV")["TREZOR_BOARD"] = board
|
||||||
|
env.get("ENV")["MCU_TYPE"] = mcu
|
||||||
|
|
||||||
return features_available
|
return features_available
|
||||||
|
@ -17,13 +17,15 @@ def configure(
|
|||||||
board = "trezor_r_v4.h"
|
board = "trezor_r_v4.h"
|
||||||
display = "vg-2864ksweg01.c"
|
display = "vg-2864ksweg01.c"
|
||||||
|
|
||||||
stm32f4_common_files(defines, sources, paths)
|
mcu = "STM32F427xx"
|
||||||
|
|
||||||
|
stm32f4_common_files(env, defines, sources, paths)
|
||||||
|
|
||||||
env.get("ENV")['CPU_ASFLAGS'] = '-mthumb -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16'
|
env.get("ENV")['CPU_ASFLAGS'] = '-mthumb -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16'
|
||||||
env.get("ENV")['CPU_CCFLAGS'] = '-mthumb -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16 -mtune=cortex-m4 '
|
env.get("ENV")['CPU_CCFLAGS'] = '-mthumb -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16 -mtune=cortex-m4 '
|
||||||
env.get("ENV")['RUST_TARGET'] = 'thumbv7em-none-eabihf'
|
env.get("ENV")['RUST_TARGET'] = 'thumbv7em-none-eabihf'
|
||||||
|
|
||||||
defines += ["STM32F427xx"]
|
defines += [mcu]
|
||||||
defines += [f'TREZOR_BOARD=\\"boards/{board}\\"']
|
defines += [f'TREZOR_BOARD=\\"boards/{board}\\"']
|
||||||
defines += [f"HW_MODEL={hw_model}"]
|
defines += [f"HW_MODEL={hw_model}"]
|
||||||
defines += [f"HW_REVISION={hw_revision}"]
|
defines += [f"HW_REVISION={hw_revision}"]
|
||||||
@ -49,5 +51,6 @@ def configure(
|
|||||||
features_available.append("usb")
|
features_available.append("usb")
|
||||||
|
|
||||||
env.get("ENV")["TREZOR_BOARD"] = board
|
env.get("ENV")["TREZOR_BOARD"] = board
|
||||||
|
env.get("ENV")["MCU_TYPE"] = mcu
|
||||||
|
|
||||||
return features_available
|
return features_available
|
||||||
|
@ -17,13 +17,15 @@ def configure(
|
|||||||
board = "trezor_r_v6.h"
|
board = "trezor_r_v6.h"
|
||||||
display = "vg-2864ksweg01.c"
|
display = "vg-2864ksweg01.c"
|
||||||
|
|
||||||
stm32f4_common_files(defines, sources, paths)
|
mcu = "STM32F427xx"
|
||||||
|
|
||||||
|
stm32f4_common_files(env, defines, sources, paths)
|
||||||
|
|
||||||
env.get("ENV")['CPU_ASFLAGS'] = '-mthumb -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16'
|
env.get("ENV")['CPU_ASFLAGS'] = '-mthumb -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16'
|
||||||
env.get("ENV")['CPU_CCFLAGS'] = '-mthumb -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16 -mtune=cortex-m4 '
|
env.get("ENV")['CPU_CCFLAGS'] = '-mthumb -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16 -mtune=cortex-m4 '
|
||||||
env.get("ENV")['RUST_TARGET'] = 'thumbv7em-none-eabihf'
|
env.get("ENV")['RUST_TARGET'] = 'thumbv7em-none-eabihf'
|
||||||
|
|
||||||
defines += ["STM32F427xx"]
|
defines += [mcu]
|
||||||
defines += [f'TREZOR_BOARD=\\"boards/{board}\\"']
|
defines += [f'TREZOR_BOARD=\\"boards/{board}\\"']
|
||||||
defines += [f"HW_MODEL={hw_model}"]
|
defines += [f"HW_MODEL={hw_model}"]
|
||||||
defines += [f"HW_REVISION={hw_revision}"]
|
defines += [f"HW_REVISION={hw_revision}"]
|
||||||
@ -49,5 +51,6 @@ def configure(
|
|||||||
features_available.append("usb")
|
features_available.append("usb")
|
||||||
|
|
||||||
env.get("ENV")["TREZOR_BOARD"] = board
|
env.get("ENV")["TREZOR_BOARD"] = board
|
||||||
|
env.get("ENV")["MCU_TYPE"] = mcu
|
||||||
|
|
||||||
return features_available
|
return features_available
|
||||||
|
@ -18,13 +18,15 @@ def configure(
|
|||||||
hw_revision = 0
|
hw_revision = 0
|
||||||
features_available.append("disp_i8080_8bit_dw")
|
features_available.append("disp_i8080_8bit_dw")
|
||||||
|
|
||||||
stm32f4_common_files(defines, sources, paths)
|
mcu = "STM32F427xx"
|
||||||
|
|
||||||
|
stm32f4_common_files(env, defines, sources, paths)
|
||||||
|
|
||||||
env.get("ENV")['CPU_ASFLAGS'] = '-mthumb -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16'
|
env.get("ENV")['CPU_ASFLAGS'] = '-mthumb -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16'
|
||||||
env.get("ENV")['CPU_CCFLAGS'] = '-mthumb -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16 -mtune=cortex-m4 '
|
env.get("ENV")['CPU_CCFLAGS'] = '-mthumb -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16 -mtune=cortex-m4 '
|
||||||
env.get("ENV")['RUST_TARGET'] = 'thumbv7em-none-eabihf'
|
env.get("ENV")['RUST_TARGET'] = 'thumbv7em-none-eabihf'
|
||||||
|
|
||||||
defines += ["STM32F427xx"]
|
defines += [mcu]
|
||||||
defines += [f'TREZOR_BOARD=\\"boards/{board}\\"']
|
defines += [f'TREZOR_BOARD=\\"boards/{board}\\"']
|
||||||
defines += [f"HW_MODEL={hw_model}"]
|
defines += [f"HW_MODEL={hw_model}"]
|
||||||
defines += [f"HW_REVISION={hw_revision}"]
|
defines += [f"HW_REVISION={hw_revision}"]
|
||||||
@ -75,5 +77,6 @@ def configure(
|
|||||||
features_available.append("dma2d")
|
features_available.append("dma2d")
|
||||||
|
|
||||||
env.get("ENV")["TREZOR_BOARD"] = board
|
env.get("ENV")["TREZOR_BOARD"] = board
|
||||||
|
env.get("ENV")["MCU_TYPE"] = mcu
|
||||||
|
|
||||||
return features_available
|
return features_available
|
||||||
|
Loading…
Reference in New Issue
Block a user