1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-12-18 04:18:10 +00:00

chore(style): apply black and isort style lints for site_scons python files

[no changelog]
This commit is contained in:
grdddj 2023-07-17 16:07:31 +02:00 committed by Jiří Musil
parent 8beaf653b9
commit 7df3219a7a
10 changed files with 231 additions and 177 deletions

View File

@ -3,12 +3,13 @@ from __future__ import annotations
from . import get_hw_model_as_number from . import get_hw_model_as_number
from .stm32f4_common import stm32f4_common_files from .stm32f4_common import stm32f4_common_files
def configure( def configure(
env: dict, env: dict,
features_wanted: list[str], features_wanted: list[str],
defines: list[str | tuple[str, str]], defines: list[str | tuple[str, str]],
sources: list[str], sources: list[str],
paths: list[str], paths: list[str],
) -> list[str]: ) -> list[str]:
features_available: list[str] = [] features_available: list[str] = []
board = "stm32f429i-disc1.h" board = "stm32f429i-disc1.h"
@ -20,9 +21,13 @@ def configure(
stm32f4_common_files(env, defines, sources, paths) 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")[
env.get("ENV")['CPU_CCFLAGS'] = '-mthumb -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16 -mtune=cortex-m4 ' "CPU_ASFLAGS"
env.get("ENV")['RUST_TARGET'] = 'thumbv7em-none-eabihf' ] = "-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 += [mcu]
defines += [f'TREZOR_BOARD=\\"boards/{board}\\"'] defines += [f'TREZOR_BOARD=\\"boards/{board}\\"']
@ -45,12 +50,12 @@ def configure(
if "usb" in features_wanted: if "usb" in features_wanted:
sources += [ sources += [
'embed/trezorhal/stm32f4/usb.c', "embed/trezorhal/stm32f4/usb.c",
'embed/trezorhal/stm32f4/usbd_conf.c', "embed/trezorhal/stm32f4/usbd_conf.c",
'embed/trezorhal/stm32f4/usbd_core.c', "embed/trezorhal/stm32f4/usbd_core.c",
'embed/trezorhal/stm32f4/usbd_ctlreq.c', "embed/trezorhal/stm32f4/usbd_ctlreq.c",
'embed/trezorhal/stm32f4/usbd_ioreq.c', "embed/trezorhal/stm32f4/usbd_ioreq.c",
'vendor/micropython/lib/stm32lib/STM32F4xx_HAL_Driver/Src/stm32f4xx_ll_usb.c', "vendor/micropython/lib/stm32lib/STM32F4xx_HAL_Driver/Src/stm32f4xx_ll_usb.c",
] ]
features_available.append("usb") features_available.append("usb")

View File

@ -3,58 +3,56 @@ from __future__ import annotations
def stm32f4_common_files(env, defines, sources, paths): def stm32f4_common_files(env, defines, sources, paths):
defines += [ defines += [
('STM32_HAL_H', '"<stm32f4xx.h>"'), ("STM32_HAL_H", '"<stm32f4xx.h>"'),
] ]
paths += [ paths += [
'embed/trezorhal/stm32f4', "embed/trezorhal/stm32f4",
'vendor/micropython/lib/stm32lib/STM32F4xx_HAL_Driver/Inc', "vendor/micropython/lib/stm32lib/STM32F4xx_HAL_Driver/Inc",
'vendor/micropython/lib/stm32lib/CMSIS/STM32F4xx/Include', "vendor/micropython/lib/stm32lib/CMSIS/STM32F4xx/Include",
] ]
sources += [ sources += [
'vendor/micropython/lib/stm32lib/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal.c', "vendor/micropython/lib/stm32lib/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal.c",
'vendor/micropython/lib/stm32lib/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_cortex.c', "vendor/micropython/lib/stm32lib/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_cortex.c",
'vendor/micropython/lib/stm32lib/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_flash.c', "vendor/micropython/lib/stm32lib/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_flash.c",
'vendor/micropython/lib/stm32lib/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_flash_ex.c', "vendor/micropython/lib/stm32lib/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_flash_ex.c",
'vendor/micropython/lib/stm32lib/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_gpio.c', "vendor/micropython/lib/stm32lib/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_gpio.c",
'vendor/micropython/lib/stm32lib/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_i2c.c', "vendor/micropython/lib/stm32lib/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_i2c.c",
'vendor/micropython/lib/stm32lib/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_ltdc.c', "vendor/micropython/lib/stm32lib/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_ltdc.c",
'vendor/micropython/lib/stm32lib/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_pcd.c', "vendor/micropython/lib/stm32lib/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_pcd.c",
'vendor/micropython/lib/stm32lib/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_pcd_ex.c', "vendor/micropython/lib/stm32lib/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_pcd_ex.c",
'vendor/micropython/lib/stm32lib/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_pwr.c', "vendor/micropython/lib/stm32lib/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_pwr.c",
'vendor/micropython/lib/stm32lib/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_rcc.c', "vendor/micropython/lib/stm32lib/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_rcc.c",
'vendor/micropython/lib/stm32lib/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_rcc_ex.c', "vendor/micropython/lib/stm32lib/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_rcc_ex.c",
'vendor/micropython/lib/stm32lib/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_sd.c', "vendor/micropython/lib/stm32lib/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_sd.c",
'vendor/micropython/lib/stm32lib/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_spi.c', "vendor/micropython/lib/stm32lib/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_spi.c",
'vendor/micropython/lib/stm32lib/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_sram.c', "vendor/micropython/lib/stm32lib/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_sram.c",
'vendor/micropython/lib/stm32lib/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_sdram.c', "vendor/micropython/lib/stm32lib/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_sdram.c",
'vendor/micropython/lib/stm32lib/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_tim.c', "vendor/micropython/lib/stm32lib/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_tim.c",
'vendor/micropython/lib/stm32lib/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_tim_ex.c', "vendor/micropython/lib/stm32lib/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_tim_ex.c",
'vendor/micropython/lib/stm32lib/STM32F4xx_HAL_Driver/Src/stm32f4xx_ll_fmc.c', "vendor/micropython/lib/stm32lib/STM32F4xx_HAL_Driver/Src/stm32f4xx_ll_fmc.c",
'vendor/micropython/lib/stm32lib/STM32F4xx_HAL_Driver/Src/stm32f4xx_ll_sdmmc.c', "vendor/micropython/lib/stm32lib/STM32F4xx_HAL_Driver/Src/stm32f4xx_ll_sdmmc.c",
] ]
sources += [ sources += [
'embed/trezorhal/stm32f4/board_capabilities.c', "embed/trezorhal/stm32f4/board_capabilities.c",
'embed/trezorhal/stm32f4/common.c', "embed/trezorhal/stm32f4/common.c",
'embed/trezorhal/stm32f4/image.c', "embed/trezorhal/stm32f4/image.c",
'embed/trezorhal/stm32f4/flash.c', "embed/trezorhal/stm32f4/flash.c",
'embed/trezorhal/stm32f4/lowlevel.c', "embed/trezorhal/stm32f4/lowlevel.c",
'embed/trezorhal/stm32f4/mpu.c', "embed/trezorhal/stm32f4/mpu.c",
'embed/trezorhal/stm32f4/platform.c', "embed/trezorhal/stm32f4/platform.c",
'embed/trezorhal/stm32f4/systick.c', "embed/trezorhal/stm32f4/systick.c",
'embed/trezorhal/stm32f4/random_delays.c', "embed/trezorhal/stm32f4/random_delays.c",
'embed/trezorhal/stm32f4/rng.c', "embed/trezorhal/stm32f4/rng.c",
'embed/trezorhal/stm32f4/util.s', "embed/trezorhal/stm32f4/util.s",
'embed/trezorhal/stm32f4/vectortable.s', "embed/trezorhal/stm32f4/vectortable.s",
] ]
env.get("ENV")["RUST_INCLUDES"] = \ env.get("ENV")["RUST_INCLUDES"] = (
"-I../trezorhal/stm32f4;" \ "-I../trezorhal/stm32f4;"
"-I../../vendor/micropython/lib/stm32lib/STM32F4xx_HAL_Driver/Inc;"\ "-I../../vendor/micropython/lib/stm32lib/STM32F4xx_HAL_Driver/Inc;"
"-I../../vendor/micropython/lib/stm32lib/CMSIS/STM32F4xx/Include;"\ "-I../../vendor/micropython/lib/stm32lib/CMSIS/STM32F4xx/Include;"
"-DSTM32_HAL_H=<stm32f4xx.h>" "-DSTM32_HAL_H=<stm32f4xx.h>"
)

View File

@ -5,11 +5,11 @@ from .stm32f4_common import stm32f4_common_files
def configure( def configure(
env: dict, env: dict,
features_wanted: list[str], features_wanted: list[str],
defines: list[str | tuple[str, str]], defines: list[str | tuple[str, str]],
sources: list[str], sources: list[str],
paths: list[str], paths: list[str],
) -> list[str]: ) -> list[str]:
features_available: list[str] = [] features_available: list[str] = []
board = "trezor_1.h" board = "trezor_1.h"
@ -21,9 +21,11 @@ def configure(
stm32f4_common_files(env, defines, sources, paths) 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")[
env.get("ENV")['RUST_TARGET'] = 'thumbv7m-none-eabi' "CPU_CCFLAGS"
] = "-mthumb -mtune=cortex-m3 -mcpu=cortex-m3 -mfloat-abi=soft "
env.get("ENV")["RUST_TARGET"] = "thumbv7m-none-eabi"
defines += [mcu] defines += [mcu]
defines += [f'TREZOR_BOARD=\\"boards/{board}\\"'] defines += [f'TREZOR_BOARD=\\"boards/{board}\\"']
@ -37,12 +39,12 @@ def configure(
if "usb" in features_wanted: if "usb" in features_wanted:
sources += [ sources += [
'embed/trezorhal/stm32f4/usb.c', "embed/trezorhal/stm32f4/usb.c",
'embed/trezorhal/stm32f4/usbd_conf.c', "embed/trezorhal/stm32f4/usbd_conf.c",
'embed/trezorhal/stm32f4/usbd_core.c', "embed/trezorhal/stm32f4/usbd_core.c",
'embed/trezorhal/stm32f4/usbd_ctlreq.c', "embed/trezorhal/stm32f4/usbd_ctlreq.c",
'embed/trezorhal/stm32f4/usbd_ioreq.c', "embed/trezorhal/stm32f4/usbd_ioreq.c",
'vendor/micropython/lib/stm32lib/STM32F4xx_HAL_Driver/Src/stm32f4xx_ll_usb.c', "vendor/micropython/lib/stm32lib/STM32F4xx_HAL_Driver/Src/stm32f4xx_ll_usb.c",
] ]
features_available.append("usb") features_available.append("usb")

View File

@ -5,11 +5,11 @@ from .stm32f4_common import stm32f4_common_files
def configure( def configure(
env: dict, env: dict,
features_wanted: list[str], features_wanted: list[str],
defines: list[str | tuple[str, str]], defines: list[str | tuple[str, str]],
sources: list[str], sources: list[str],
paths: list[str], paths: list[str],
) -> list[str]: ) -> list[str]:
features_available: list[str] = [] features_available: list[str] = []
hw_model = get_hw_model_as_number("T2B1") hw_model = get_hw_model_as_number("T2B1")
@ -21,9 +21,13 @@ def configure(
stm32f4_common_files(env, defines, sources, paths) 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")[
env.get("ENV")['CPU_CCFLAGS'] = '-mthumb -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16 -mtune=cortex-m4 ' "CPU_ASFLAGS"
env.get("ENV")['RUST_TARGET'] = 'thumbv7em-none-eabihf' ] = "-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 += [mcu]
defines += [f'TREZOR_BOARD=\\"boards/{board}\\"'] defines += [f'TREZOR_BOARD=\\"boards/{board}\\"']
@ -43,17 +47,19 @@ def configure(
if "consumption_mask" in features_wanted: if "consumption_mask" in features_wanted:
sources += ["embed/trezorhal/stm32f4/consumption_mask.c"] sources += ["embed/trezorhal/stm32f4/consumption_mask.c"]
sources += ["vendor/micropython/lib/stm32lib/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_dma.c"] sources += [
"vendor/micropython/lib/stm32lib/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_dma.c"
]
sources += ["embed/trezorhal/stm32f4/dma.c"] sources += ["embed/trezorhal/stm32f4/dma.c"]
if "usb" in features_wanted: if "usb" in features_wanted:
sources += [ sources += [
'embed/trezorhal/stm32f4/usb.c', "embed/trezorhal/stm32f4/usb.c",
'embed/trezorhal/stm32f4/usbd_conf.c', "embed/trezorhal/stm32f4/usbd_conf.c",
'embed/trezorhal/stm32f4/usbd_core.c', "embed/trezorhal/stm32f4/usbd_core.c",
'embed/trezorhal/stm32f4/usbd_ctlreq.c', "embed/trezorhal/stm32f4/usbd_ctlreq.c",
'embed/trezorhal/stm32f4/usbd_ioreq.c', "embed/trezorhal/stm32f4/usbd_ioreq.c",
'vendor/micropython/lib/stm32lib/STM32F4xx_HAL_Driver/Src/stm32f4xx_ll_usb.c', "vendor/micropython/lib/stm32lib/STM32F4xx_HAL_Driver/Src/stm32f4xx_ll_usb.c",
] ]
features_available.append("usb") features_available.append("usb")

View File

@ -5,11 +5,11 @@ from .stm32f4_common import stm32f4_common_files
def configure( def configure(
env: dict, env: dict,
features_wanted: list[str], features_wanted: list[str],
defines: list[str | tuple[str, str]], defines: list[str | tuple[str, str]],
sources: list[str], sources: list[str],
paths: list[str], paths: list[str],
) -> list[str]: ) -> list[str]:
features_available: list[str] = [] features_available: list[str] = []
hw_model = get_hw_model_as_number("T2B1") hw_model = get_hw_model_as_number("T2B1")
@ -21,9 +21,13 @@ def configure(
stm32f4_common_files(env, defines, sources, paths) 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")[
env.get("ENV")['CPU_CCFLAGS'] = '-mthumb -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16 -mtune=cortex-m4 ' "CPU_ASFLAGS"
env.get("ENV")['RUST_TARGET'] = 'thumbv7em-none-eabihf' ] = "-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 += [mcu]
defines += [f'TREZOR_BOARD=\\"boards/{board}\\"'] defines += [f'TREZOR_BOARD=\\"boards/{board}\\"']
@ -45,12 +49,12 @@ def configure(
if "usb" in features_wanted: if "usb" in features_wanted:
sources += [ sources += [
'embed/trezorhal/stm32f4/usb.c', "embed/trezorhal/stm32f4/usb.c",
'embed/trezorhal/stm32f4/usbd_conf.c', "embed/trezorhal/stm32f4/usbd_conf.c",
'embed/trezorhal/stm32f4/usbd_core.c', "embed/trezorhal/stm32f4/usbd_core.c",
'embed/trezorhal/stm32f4/usbd_ctlreq.c', "embed/trezorhal/stm32f4/usbd_ctlreq.c",
'embed/trezorhal/stm32f4/usbd_ioreq.c', "embed/trezorhal/stm32f4/usbd_ioreq.c",
'vendor/micropython/lib/stm32lib/STM32F4xx_HAL_Driver/Src/stm32f4xx_ll_usb.c', "vendor/micropython/lib/stm32lib/STM32F4xx_HAL_Driver/Src/stm32f4xx_ll_usb.c",
] ]
features_available.append("usb") features_available.append("usb")

View File

@ -5,11 +5,11 @@ from .stm32f4_common import stm32f4_common_files
def configure( def configure(
env: dict, env: dict,
features_wanted: list[str], features_wanted: list[str],
defines: list[str | tuple[str, str]], defines: list[str | tuple[str, str]],
sources: list[str], sources: list[str],
paths: list[str], paths: list[str],
) -> list[str]: ) -> list[str]:
features_available: list[str] = [] features_available: list[str] = []
hw_model = get_hw_model_as_number("T2B1") hw_model = get_hw_model_as_number("T2B1")
@ -21,9 +21,13 @@ def configure(
stm32f4_common_files(env, defines, sources, paths) 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")[
env.get("ENV")['CPU_CCFLAGS'] = '-mthumb -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16 -mtune=cortex-m4 ' "CPU_ASFLAGS"
env.get("ENV")['RUST_TARGET'] = 'thumbv7em-none-eabihf' ] = "-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 += [mcu]
defines += [f'TREZOR_BOARD=\\"boards/{board}\\"'] defines += [f'TREZOR_BOARD=\\"boards/{board}\\"']
@ -41,12 +45,12 @@ def configure(
if "usb" in features_wanted: if "usb" in features_wanted:
sources += [ sources += [
'embed/trezorhal/stm32f4/usb.c', "embed/trezorhal/stm32f4/usb.c",
'embed/trezorhal/stm32f4/usbd_conf.c', "embed/trezorhal/stm32f4/usbd_conf.c",
'embed/trezorhal/stm32f4/usbd_core.c', "embed/trezorhal/stm32f4/usbd_core.c",
'embed/trezorhal/stm32f4/usbd_ctlreq.c', "embed/trezorhal/stm32f4/usbd_ctlreq.c",
'embed/trezorhal/stm32f4/usbd_ioreq.c', "embed/trezorhal/stm32f4/usbd_ioreq.c",
'vendor/micropython/lib/stm32lib/STM32F4xx_HAL_Driver/Src/stm32f4xx_ll_usb.c', "vendor/micropython/lib/stm32lib/STM32F4xx_HAL_Driver/Src/stm32f4xx_ll_usb.c",
] ]
features_available.append("usb") features_available.append("usb")

View File

@ -5,11 +5,11 @@ from .stm32f4_common import stm32f4_common_files
def configure( def configure(
env: dict, env: dict,
features_wanted: list[str], features_wanted: list[str],
defines: list[str | tuple[str, str]], defines: list[str | tuple[str, str]],
sources: list[str], sources: list[str],
paths: list[str], paths: list[str],
) -> list[str]: ) -> list[str]:
features_available: list[str] = [] features_available: list[str] = []
hw_model = get_hw_model_as_number("T2B1") hw_model = get_hw_model_as_number("T2B1")
@ -21,9 +21,13 @@ def configure(
stm32f4_common_files(env, defines, sources, paths) 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")[
env.get("ENV")['CPU_CCFLAGS'] = '-mthumb -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16 -mtune=cortex-m4 ' "CPU_ASFLAGS"
env.get("ENV")['RUST_TARGET'] = 'thumbv7em-none-eabihf' ] = "-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 += [mcu]
defines += [f'TREZOR_BOARD=\\"boards/{board}\\"'] defines += [f'TREZOR_BOARD=\\"boards/{board}\\"']
@ -41,12 +45,12 @@ def configure(
if "usb" in features_wanted: if "usb" in features_wanted:
sources += [ sources += [
'embed/trezorhal/stm32f4/usb.c', "embed/trezorhal/stm32f4/usb.c",
'embed/trezorhal/stm32f4/usbd_conf.c', "embed/trezorhal/stm32f4/usbd_conf.c",
'embed/trezorhal/stm32f4/usbd_core.c', "embed/trezorhal/stm32f4/usbd_core.c",
'embed/trezorhal/stm32f4/usbd_ctlreq.c', "embed/trezorhal/stm32f4/usbd_ctlreq.c",
'embed/trezorhal/stm32f4/usbd_ioreq.c', "embed/trezorhal/stm32f4/usbd_ioreq.c",
'vendor/micropython/lib/stm32lib/STM32F4xx_HAL_Driver/Src/stm32f4xx_ll_usb.c', "vendor/micropython/lib/stm32lib/STM32F4xx_HAL_Driver/Src/stm32f4xx_ll_usb.c",
] ]
features_available.append("usb") features_available.append("usb")

View File

@ -22,9 +22,13 @@ def configure(
stm32f4_common_files(env, defines, sources, paths) 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")[
env.get("ENV")['CPU_CCFLAGS'] = '-mthumb -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16 -mtune=cortex-m4 ' "CPU_ASFLAGS"
env.get("ENV")['RUST_TARGET'] = 'thumbv7em-none-eabihf' ] = "-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 += [mcu]
defines += [f'TREZOR_BOARD=\\"boards/{board}\\"'] defines += [f'TREZOR_BOARD=\\"boards/{board}\\"']
@ -32,10 +36,18 @@ def configure(
defines += [f"HW_REVISION={hw_revision}"] defines += [f"HW_REVISION={hw_revision}"]
sources += [f"embed/trezorhal/stm32f4/displays/{display}"] sources += [f"embed/trezorhal/stm32f4/displays/{display}"]
sources += [f"embed/trezorhal/stm32f4/backlight_pwm.c"] sources += [f"embed/trezorhal/stm32f4/backlight_pwm.c"]
sources += [f'embed/trezorhal/stm32f4/displays/panels/tf15411a.c', ] sources += [
sources += [f'embed/trezorhal/stm32f4/displays/panels/154a.c', ] f"embed/trezorhal/stm32f4/displays/panels/tf15411a.c",
sources += [f'embed/trezorhal/stm32f4/displays/panels/lx154a2411.c', ] ]
sources += [f'embed/trezorhal/stm32f4/displays/panels/lx154a2422.c', ] sources += [
f"embed/trezorhal/stm32f4/displays/panels/154a.c",
]
sources += [
f"embed/trezorhal/stm32f4/displays/panels/lx154a2411.c",
]
sources += [
f"embed/trezorhal/stm32f4/displays/panels/lx154a2422.c",
]
features_available.append("backlight") features_available.append("backlight")
@ -49,7 +61,9 @@ def configure(
sources += ["embed/trezorhal/stm32f4/sdcard.c"] sources += ["embed/trezorhal/stm32f4/sdcard.c"]
sources += ["embed/extmod/modtrezorio/ff.c"] sources += ["embed/extmod/modtrezorio/ff.c"]
sources += ["embed/extmod/modtrezorio/ffunicode.c"] sources += ["embed/extmod/modtrezorio/ffunicode.c"]
sources += ["vendor/micropython/lib/stm32lib/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_dma.c"] sources += [
"vendor/micropython/lib/stm32lib/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_dma.c"
]
sources += ["embed/trezorhal/stm32f4/dma.c"] sources += ["embed/trezorhal/stm32f4/dma.c"]
features_available.append("sd_card") features_available.append("sd_card")
@ -59,12 +73,12 @@ def configure(
if "usb" in features_wanted: if "usb" in features_wanted:
sources += [ sources += [
'embed/trezorhal/stm32f4/usb.c', "embed/trezorhal/stm32f4/usb.c",
'embed/trezorhal/stm32f4/usbd_conf.c', "embed/trezorhal/stm32f4/usbd_conf.c",
'embed/trezorhal/stm32f4/usbd_core.c', "embed/trezorhal/stm32f4/usbd_core.c",
'embed/trezorhal/stm32f4/usbd_ctlreq.c', "embed/trezorhal/stm32f4/usbd_ctlreq.c",
'embed/trezorhal/stm32f4/usbd_ioreq.c', "embed/trezorhal/stm32f4/usbd_ioreq.c",
'vendor/micropython/lib/stm32lib/STM32F4xx_HAL_Driver/Src/stm32f4xx_ll_usb.c', "vendor/micropython/lib/stm32lib/STM32F4xx_HAL_Driver/Src/stm32f4xx_ll_usb.c",
] ]
features_available.append("usb") features_available.append("usb")

View File

@ -4,52 +4,61 @@ import SCons.Builder
def generate(env): def generate(env):
env.SetDefault( env.SetDefault(
QSTRCOL='site_scons/site_tools/micropython/qstrdefs.py', QSTRCOL="site_scons/site_tools/micropython/qstrdefs.py",
MODULECOL='site_scons/site_tools/micropython/moduledefs.py', ) MODULECOL="site_scons/site_tools/micropython/moduledefs.py",
)
env['BUILDERS']['CollectQstr'] = SCons.Builder.Builder( env["BUILDERS"]["CollectQstr"] = SCons.Builder.Builder(
action='$CC -E $CCFLAGS_QSTR $CFLAGS $CCFLAGS $_CCCOMCOM $SOURCES' action="$CC -E $CCFLAGS_QSTR $CFLAGS $CCFLAGS $_CCCOMCOM $SOURCES"
' | $PYTHON $QSTRCOL > $TARGET') " | $PYTHON $QSTRCOL > $TARGET"
)
env['BUILDERS']['PreprocessQstr'] = SCons.Builder.Builder( env["BUILDERS"]["PreprocessQstr"] = SCons.Builder.Builder(
action="cat $SOURCES" action="cat $SOURCES"
" | $SED 's/^Q(.*)/\"&\"/'" " | $SED 's/^Q(.*)/\"&\"/'"
" | $CC -E $CFLAGS $CCFLAGS $_CCCOMCOM -" " | $CC -E $CFLAGS $CCFLAGS $_CCCOMCOM -"
" | $SED 's/^\"\\(Q(.*)\\)\"/\\1/' > $TARGET", ) " | $SED 's/^\"\\(Q(.*)\\)\"/\\1/' > $TARGET",
)
env['BUILDERS']['GenerateQstrDefs'] = SCons.Builder.Builder( env["BUILDERS"]["GenerateQstrDefs"] = SCons.Builder.Builder(
action='$MAKEQSTRDATA $SOURCE > $TARGET', ) action="$MAKEQSTRDATA $SOURCE > $TARGET",
)
env['BUILDERS']['CollectModules'] = SCons.Builder.Builder( env["BUILDERS"]["CollectModules"] = SCons.Builder.Builder(
action='$CC -E $CCFLAGS_QSTR $CFLAGS $CCFLAGS $_CCCOMCOM $SOURCES' action="$CC -E $CCFLAGS_QSTR $CFLAGS $CCFLAGS $_CCCOMCOM $SOURCES"
' | $PYTHON $MODULECOL > $TARGET') " | $PYTHON $MODULECOL > $TARGET"
)
def generate_frozen_module(source, target, env, for_signature): def generate_frozen_module(source, target, env, for_signature):
target = str(target[0]) target = str(target[0])
source = str(source[0]) source = str(source[0])
source_name = source.replace(env['source_dir'], '') source_name = source.replace(env["source_dir"], "")
# replace "utils.BITCOIN_ONLY" with literal constant (True/False) # replace "utils.BITCOIN_ONLY" with literal constant (True/False)
# so the compiler can optimize out the things we don't want # so the compiler can optimize out the things we don't want
btc_only = env['bitcoin_only'] == '1' btc_only = env["bitcoin_only"] == "1"
backlight = env['backlight'] backlight = env["backlight"]
interim = f"{target[:-4]}.i" # replace .mpy with .i interim = f"{target[:-4]}.i" # replace .mpy with .i
sed_scripts = " ".join([ sed_scripts = " ".join(
rf"-e 's/utils\.BITCOIN_ONLY/{btc_only}/g'", [
rf"-e 's/utils\.USE_BACKLIGHT/{backlight}/g'", rf"-e 's/utils\.BITCOIN_ONLY/{btc_only}/g'",
r"-e 's/if TYPE_CHECKING/if False/'", rf"-e 's/utils\.USE_BACKLIGHT/{backlight}/g'",
r"-e 's/import typing/# \0/'", r"-e 's/if TYPE_CHECKING/if False/'",
r"-e '/from typing import (/,/^\s*)/ {s/^/# /}'", r"-e 's/import typing/# \0/'",
r"-e 's/from typing import/# \0/'" r"-e '/from typing import (/,/^\s*)/ {s/^/# /}'",
]) r"-e 's/from typing import/# \0/'",
return f'$SED {sed_scripts} {source} > {interim} && $MPY_CROSS -o {target} -s {source_name} {interim}' ]
)
return f"$SED {sed_scripts} {source} > {interim} && $MPY_CROSS -o {target} -s {source_name} {interim}"
env['BUILDERS']['FrozenModule'] = SCons.Builder.Builder( env["BUILDERS"]["FrozenModule"] = SCons.Builder.Builder(
generator=generate_frozen_module, generator=generate_frozen_module,
suffix='.mpy', suffix=".mpy",
single_source=True, ) single_source=True,
)
env['BUILDERS']['FrozenCFile'] = SCons.Builder.Builder( env["BUILDERS"]["FrozenCFile"] = SCons.Builder.Builder(
action='$MPY_TOOL -f -q $qstr_header $SOURCES > $TARGET', ) action="$MPY_TOOL -f -q $qstr_header $SOURCES > $TARGET",
)
def exists(env): def exists(env):

View File

@ -1,9 +1,17 @@
from __future__ import annotations from __future__ import annotations
import subprocess
from pathlib import Path from pathlib import Path
import subprocess from boards import (
from boards import trezor_1, trezor_r_v3, trezor_r_v4, trezor_t, trezor_r_v6, trezor_r_v10, discovery discovery,
trezor_1,
trezor_r_v3,
trezor_r_v4,
trezor_r_v6,
trezor_r_v10,
trezor_t,
)
HERE = Path(__file__).parent.resolve() HERE = Path(__file__).parent.resolve()
@ -43,11 +51,11 @@ def configure_board(
return trezor_r_v3.configure(env, features_wanted, defines, sources, paths) return trezor_r_v3.configure(env, features_wanted, defines, sources, paths)
elif model_r_version == 4: elif model_r_version == 4:
return trezor_r_v4.configure(env, features_wanted, defines, sources, paths) return trezor_r_v4.configure(env, features_wanted, defines, sources, paths)
elif model_r_version == 6: elif model_r_version == 6:
return trezor_r_v6.configure(env, features_wanted, defines, sources, paths) return trezor_r_v6.configure(env, features_wanted, defines, sources, paths)
elif model_r_version == 10: elif model_r_version == 10:
return trezor_r_v10.configure(env, features_wanted, defines, sources, paths) return trezor_r_v10.configure(env, features_wanted, defines, sources, paths)
elif model in ('DISC1',): elif model in ("DISC1",):
return discovery.configure(env, features_wanted, defines, sources, paths) return discovery.configure(env, features_wanted, defines, sources, paths)
else: else:
raise Exception("Unknown model") raise Exception("Unknown model")
@ -60,7 +68,7 @@ def get_model_identifier(model: str) -> str:
return "T2T1" return "T2T1"
elif model == "R": elif model == "R":
return "T2B1" return "T2B1"
elif model == 'DISC1': elif model == "DISC1":
return "D001" return "D001"
else: else:
raise Exception("Unknown model") raise Exception("Unknown model")