from __future__ import annotations from . import get_hw_model_as_number from .stm32f4_common import stm32f4_common_files def configure( env: dict, features_wanted: list[str], defines: list[str | tuple[str, str]], sources: list[str], paths: list[str], ) -> list[str]: features_available: list[str] = [] hw_model = get_hw_model_as_number("T2B1") hw_revision = 10 board = "trezor_r_v10.h" display = "vg-2864ksweg01.c" if "new_rendering" in features_wanted: defines += ["XFRAMEBUFFER"] features_available.append("xframebuffer") features_available.append("display_mono") 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_CCFLAGS" ] = "-mthumb -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16 -mtune=cortex-m4 " env.get("ENV")["RUST_TARGET"] = "thumbv7em-none-eabihf" defines += [mcu] defines += [f'TREZOR_BOARD=\\"boards/{board}\\"'] defines += [f"HW_MODEL={hw_model}"] defines += [f"HW_REVISION={hw_revision}"] sources += [ "embed/models/model_T2B1_layout.c", ] if "new_rendering" in features_wanted: sources += ["embed/trezorhal/xdisplay_legacy.c"] sources += ["embed/trezorhal/stm32f4/display/vg-2864/display_driver.c"] else: sources += [f"embed/trezorhal/stm32f4/displays/{display}"] sources += ["embed/trezorhal/stm32f4/i2c.c"] if "input" in features_wanted: sources += ["embed/trezorhal/stm32f4/button.c"] features_available.append("button") if "sbu" in features_wanted: sources += ["embed/trezorhal/stm32f4/sbu.c"] features_available.append("sbu") if "consumption_mask" in features_wanted: sources += ["embed/trezorhal/stm32f4/consumption_mask.c"] sources += [ "vendor/micropython/lib/stm32lib/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_dma.c" ] if "usb" in features_wanted: sources += [ "embed/trezorhal/stm32f4/usb.c", "embed/trezorhal/stm32f4/usbd_conf.c", "embed/trezorhal/stm32f4/usbd_core.c", "embed/trezorhal/stm32f4/usbd_ctlreq.c", "embed/trezorhal/stm32f4/usbd_ioreq.c", "vendor/micropython/lib/stm32lib/STM32F4xx_HAL_Driver/Src/stm32f4xx_ll_usb.c", ] features_available.append("usb") if "optiga" in features_wanted: defines += ["USE_OPTIGA=1"] sources += ["embed/trezorhal/stm32f4/optiga_hal.c"] sources += ["embed/trezorhal/optiga/optiga.c"] sources += ["embed/trezorhal/optiga/optiga_commands.c"] sources += ["embed/trezorhal/optiga/optiga_transport.c"] sources += ["embed/trezorhal/stm32f4/secret.c"] sources += ["vendor/trezor-crypto/hash_to_curve.c"] features_available.append("optiga") env.get("ENV")["TREZOR_BOARD"] = board env.get("ENV")["MCU_TYPE"] = mcu if "new_rendering" in features_wanted: rust_defs = env.get("ENV")["RUST_INCLUDES"] rust_defs += "-DXFRAMEBUFFER;" env.get("ENV")["RUST_INCLUDES"] = rust_defs return features_available