From 82bc0ef18648990cd6e8ec21ba9f765f13da94c7 Mon Sep 17 00:00:00 2001 From: cepetr Date: Fri, 15 Nov 2024 10:07:00 +0100 Subject: [PATCH] refactor(core): define USE_xxx consistently with feature flags [no changelog] --- core/embed/trezorhal/stm32f4/unit_properties.c | 2 -- core/embed/trezorhal/unix/unit_properties.c | 2 -- core/site_scons/models/D001/discovery.py | 4 ++-- core/site_scons/models/D002/discovery2.py | 4 ++-- core/site_scons/models/T2B1/emulator.py | 6 +++--- core/site_scons/models/T2B1/trezor_r_v10.py | 10 +++++----- core/site_scons/models/T2T1/emulator.py | 6 +++--- core/site_scons/models/T2T1/trezor_t.py | 8 ++++---- core/site_scons/models/T3B1/emulator.py | 6 +++--- core/site_scons/models/T3B1/trezor_t3b1_revB.py | 10 +++++----- core/site_scons/models/T3T1/emulator.py | 8 ++++---- core/site_scons/models/T3T1/trezor_t3t1_revE.py | 12 ++++++------ core/site_scons/models/T3W1/emulator.py | 6 +++--- core/site_scons/models/T3W1/trezor_t3w1_revA.py | 10 +++++----- 14 files changed, 45 insertions(+), 49 deletions(-) diff --git a/core/embed/trezorhal/stm32f4/unit_properties.c b/core/embed/trezorhal/stm32f4/unit_properties.c index 78f319c447..940c26a8e7 100644 --- a/core/embed/trezorhal/stm32f4/unit_properties.c +++ b/core/embed/trezorhal/stm32f4/unit_properties.c @@ -119,7 +119,6 @@ static bool detect_properties(unit_properties_t* props) { break; } -#ifdef USE_SD_CARD props->sd_hotswap_enabled = true; #ifdef TREZOR_MODEL_T // Early produced TTs have a HW bug that prevents hotswapping of the SD card, @@ -129,7 +128,6 @@ static bool detect_properties(unit_properties_t* props) { if (production_year <= 18) { props->sd_hotswap_enabled = false; } -#endif #endif return true; diff --git a/core/embed/trezorhal/unix/unit_properties.c b/core/embed/trezorhal/unix/unit_properties.c index 5fd1881f69..a90291ff9d 100644 --- a/core/embed/trezorhal/unix/unit_properties.c +++ b/core/embed/trezorhal/unix/unit_properties.c @@ -46,11 +46,9 @@ bool unit_properties_init(void) { memset(drv, 0, sizeof(unit_properties_driver_t)); -#ifdef USE_SD_CARD drv->cache.sd_hotswap_enabled = true; #ifdef TREZOR_MODEL_T drv->cache.sd_hotswap_enabled = false; -#endif #endif // Properties detection is not fully implemented for emulator. diff --git a/core/site_scons/models/D001/discovery.py b/core/site_scons/models/D001/discovery.py index f4b119ec19..97ef8a53b2 100644 --- a/core/site_scons/models/D001/discovery.py +++ b/core/site_scons/models/D001/discovery.py @@ -63,8 +63,8 @@ def configure( sources += ["embed/trezorhal/stm32f4/i2c_bus.c"] sources += ["embed/trezorhal/stm32f4/touch/stmpe811.c"] features_available.append("touch") - defines += ["USE_TOUCH=1"] - defines += ["USE_I2C=1"] + defines += ["USE_TOUCH=1"] + defines += ["USE_I2C=1"] if "usb" in features_wanted: sources += [ diff --git a/core/site_scons/models/D002/discovery2.py b/core/site_scons/models/D002/discovery2.py index 0ad5625d6a..30465e406a 100644 --- a/core/site_scons/models/D002/discovery2.py +++ b/core/site_scons/models/D002/discovery2.py @@ -50,8 +50,8 @@ def configure( sources += ["embed/trezorhal/stm32u5/i2c_bus.c"] sources += ["embed/trezorhal/stm32u5/touch/sitronix.c"] features_available.append("touch") - defines += ["USE_TOUCH=1"] - defines += ["USE_I2C=1"] + defines += ["USE_TOUCH=1"] + defines += ["USE_I2C=1"] if "usb" in features_wanted: sources += [ diff --git a/core/site_scons/models/T2B1/emulator.py b/core/site_scons/models/T2B1/emulator.py index 757d7eb787..ec32ce2ccb 100644 --- a/core/site_scons/models/T2B1/emulator.py +++ b/core/site_scons/models/T2B1/emulator.py @@ -31,18 +31,18 @@ def configure( if "sbu" in features_wanted: sources += ["embed/trezorhal/unix/sbu.c"] - defines += ["USE_SBU=1"] + defines += ["USE_SBU=1"] if "optiga" in features_wanted: sources += ["embed/trezorhal/unix/optiga_hal.c"] sources += ["embed/trezorhal/unix/optiga.c"] features_available.append("optiga") - defines += ["USE_OPTIGA=1"] + defines += ["USE_OPTIGA=1"] if "input" in features_wanted: sources += ["embed/trezorhal/unix/button.c"] features_available.append("button") - defines += ["USE_BUTTON=1"] + defines += ["USE_BUTTON=1"] sources += ["embed/trezorhal/stm32f4/layout.c"] diff --git a/core/site_scons/models/T2B1/trezor_r_v10.py b/core/site_scons/models/T2B1/trezor_r_v10.py index 57130e621d..18db28c2d3 100644 --- a/core/site_scons/models/T2B1/trezor_r_v10.py +++ b/core/site_scons/models/T2B1/trezor_r_v10.py @@ -42,19 +42,19 @@ def configure( if "input" in features_wanted: sources += ["embed/trezorhal/stm32f4/button.c"] features_available.append("button") - defines += ["USE_BUTTON=1"] + defines += ["USE_BUTTON=1"] if "sbu" in features_wanted: sources += ["embed/trezorhal/stm32f4/sbu.c"] features_available.append("sbu") - defines += ["USE_SBU=1"] + defines += ["USE_SBU=1"] 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" ] - defines += ["USE_CONSUMPTION_MASK=1"] + defines += ["USE_CONSUMPTION_MASK=1"] if "usb" in features_wanted: sources += [ @@ -78,8 +78,8 @@ def configure( sources += ["embed/trezorhal/optiga/optiga_transport.c"] sources += ["vendor/trezor-crypto/hash_to_curve.c"] features_available.append("optiga") - defines += ["USE_OPTIGA=1"] - defines += ["USE_I2C=1"] + defines += ["USE_OPTIGA=1"] + defines += ["USE_I2C=1"] defines += ["USE_PVD=1"] diff --git a/core/site_scons/models/T2T1/emulator.py b/core/site_scons/models/T2T1/emulator.py index cb64af6228..d00a631dea 100644 --- a/core/site_scons/models/T2T1/emulator.py +++ b/core/site_scons/models/T2T1/emulator.py @@ -43,16 +43,16 @@ def configure( "embed/extmod/modtrezorio/ff.c", "embed/extmod/modtrezorio/ffunicode.c", ] - defines += ["USE_SD_CARD=1"] + defines += ["USE_SD_CARD=1"] if "sbu" in features_wanted: sources += ["embed/trezorhal/unix/sbu.c"] - defines += ["USE_SBU=1"] + defines += ["USE_SBU=1"] if "input" in features_wanted: sources += ["embed/trezorhal/unix/touch.c"] features_available.append("touch") - defines += ["USE_TOUCH=1"] + defines += ["USE_TOUCH=1"] features_available.append("backlight") defines += ["USE_BACKLIGHT=1"] diff --git a/core/site_scons/models/T2T1/trezor_t.py b/core/site_scons/models/T2T1/trezor_t.py index 926edad4ca..5d8f2c46a3 100644 --- a/core/site_scons/models/T2T1/trezor_t.py +++ b/core/site_scons/models/T2T1/trezor_t.py @@ -55,8 +55,8 @@ def configure( sources += ["embed/trezorhal/stm32f4/i2c_bus.c"] sources += ["embed/trezorhal/stm32f4/touch/ft6x36.c"] features_available.append("touch") - defines += ["USE_TOUCH=1"] - defines += ["USE_I2C=1"] + defines += ["USE_TOUCH=1"] + defines += ["USE_I2C=1"] if "sd_card" in features_wanted: sources += ["embed/trezorhal/stm32f4/sdcard.c"] @@ -66,12 +66,12 @@ def configure( "vendor/micropython/lib/stm32lib/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_dma.c" ] features_available.append("sd_card") - defines += ["USE_SD_CARD=1"] + defines += ["USE_SD_CARD=1"] if "sbu" in features_wanted: sources += ["embed/trezorhal/stm32f4/sbu.c"] features_available.append("sbu") - defines += ["USE_SBU=1"] + defines += ["USE_SBU=1"] if "usb" in features_wanted: sources += [ diff --git a/core/site_scons/models/T3B1/emulator.py b/core/site_scons/models/T3B1/emulator.py index 5abdb8dd97..ae2132c6ee 100644 --- a/core/site_scons/models/T3B1/emulator.py +++ b/core/site_scons/models/T3B1/emulator.py @@ -31,18 +31,18 @@ def configure( if "sbu" in features_wanted: sources += ["embed/trezorhal/unix/sbu.c"] - defines += ["USE_SBU=1"] + defines += ["USE_SBU=1"] if "optiga" in features_wanted: sources += ["embed/trezorhal/unix/optiga_hal.c"] sources += ["embed/trezorhal/unix/optiga.c"] features_available.append("optiga") - defines += ["USE_OPTIGA=1"] + defines += ["USE_OPTIGA=1"] if "input" in features_wanted: sources += ["embed/trezorhal/unix/button.c"] features_available.append("button") - defines += ["USE_BUTTON=1"] + defines += ["USE_BUTTON=1"] sources += ["embed/trezorhal/stm32u5/layout.c"] diff --git a/core/site_scons/models/T3B1/trezor_t3b1_revB.py b/core/site_scons/models/T3B1/trezor_t3b1_revB.py index 442f203d1f..d0c46ec6e2 100644 --- a/core/site_scons/models/T3B1/trezor_t3b1_revB.py +++ b/core/site_scons/models/T3B1/trezor_t3b1_revB.py @@ -43,12 +43,12 @@ def configure( if "input" in features_wanted: sources += ["embed/trezorhal/stm32u5/button.c"] features_available.append("button") - defines += ["USE_BUTTON=1"] + defines += ["USE_BUTTON=1"] if "sbu" in features_wanted: sources += ["embed/trezorhal/stm32u5/sbu.c"] features_available.append("sbu") - defines += ["USE_SBU=1"] + defines += ["USE_SBU=1"] if "usb" in features_wanted: sources += [ @@ -72,13 +72,13 @@ def configure( sources += ["embed/trezorhal/optiga/optiga_transport.c"] sources += ["vendor/trezor-crypto/hash_to_curve.c"] features_available.append("optiga") - defines += ["USE_OPTIGA=1"] - defines += ["USE_I2C=1"] + defines += ["USE_OPTIGA=1"] + defines += ["USE_I2C=1"] if "consumption_mask" in features_wanted: sources += ["embed/trezorhal/stm32u5/consumption_mask.c"] sources += ["vendor/stm32u5xx_hal_driver/Src/stm32u5xx_hal_tim.c"] - defines += ["USE_CONSUMPTION_MASK=1"] + defines += ["USE_CONSUMPTION_MASK=1"] defines += [ "USE_HASH_PROCESSOR=1", diff --git a/core/site_scons/models/T3T1/emulator.py b/core/site_scons/models/T3T1/emulator.py index 6a6412a38d..79f6dcdb70 100644 --- a/core/site_scons/models/T3T1/emulator.py +++ b/core/site_scons/models/T3T1/emulator.py @@ -45,22 +45,22 @@ def configure( "embed/extmod/modtrezorio/ff.c", "embed/extmod/modtrezorio/ffunicode.c", ] - defines += ["USE_SD_CARD=1"] + defines += ["USE_SD_CARD=1"] if "sbu" in features_wanted: sources += ["embed/trezorhal/unix/sbu.c"] - defines += ["USE_SBU=1"] + defines += ["USE_SBU=1"] if "optiga" in features_wanted: sources += ["embed/trezorhal/unix/optiga_hal.c"] sources += ["embed/trezorhal/unix/optiga.c"] features_available.append("optiga") - defines += ["USE_OPTIGA=1"] + defines += ["USE_OPTIGA=1"] if "input" in features_wanted: sources += ["embed/trezorhal/unix/touch.c"] features_available.append("touch") - defines += ["USE_TOUCH=1"] + defines += ["USE_TOUCH=1"] features_available.append("backlight") defines += ["USE_BACKLIGHT=1"] diff --git a/core/site_scons/models/T3T1/trezor_t3t1_revE.py b/core/site_scons/models/T3T1/trezor_t3t1_revE.py index 9e62fd254a..84c0a3b54c 100644 --- a/core/site_scons/models/T3T1/trezor_t3t1_revE.py +++ b/core/site_scons/models/T3T1/trezor_t3t1_revE.py @@ -61,8 +61,8 @@ def configure( sources += ["embed/trezorhal/stm32u5/touch/ft6x36.c"] sources += ["embed/trezorhal/stm32u5/touch/panels/lx154a2422cpt23.c"] features_available.append("touch") - defines += ["USE_TOUCH=1"] - defines += ["USE_I2C=1"] + defines += ["USE_TOUCH=1"] + defines += ["USE_I2C=1"] if "haptic" in features_wanted: sources += [ @@ -73,7 +73,7 @@ def configure( "vendor/stm32u5xx_hal_driver/Src/stm32u5xx_hal_tim_ex.c", ] features_available.append("haptic") - defines += ["USE_HAPTIC=1"] + defines += ["USE_HAPTIC=1"] if "sd_card" in features_wanted: sources += ["embed/trezorhal/stm32u5/sdcard.c"] @@ -82,12 +82,12 @@ def configure( sources += ["vendor/stm32u5xx_hal_driver/Src/stm32u5xx_hal_sd.c"] sources += ["vendor/stm32u5xx_hal_driver/Src/stm32u5xx_ll_sdmmc.c"] features_available.append("sd_card") - defines += ["USE_SD_CARD=1"] + defines += ["USE_SD_CARD=1"] if "sbu" in features_wanted: sources += ["embed/trezorhal/stm32u5/sbu.c"] features_available.append("sbu") - defines += ["USE_SBU=1"] + defines += ["USE_SBU=1"] if "usb" in features_wanted: sources += [ @@ -115,7 +115,7 @@ def configure( sources += ["embed/trezorhal/optiga/optiga_transport.c"] sources += ["vendor/trezor-crypto/hash_to_curve.c"] features_available.append("optiga") - defines += ["USE_OPTIGA=1"] + defines += ["USE_OPTIGA=1"] defines += [ "USE_HASH_PROCESSOR=1", diff --git a/core/site_scons/models/T3W1/emulator.py b/core/site_scons/models/T3W1/emulator.py index bd350aee51..5edbe1a623 100644 --- a/core/site_scons/models/T3W1/emulator.py +++ b/core/site_scons/models/T3W1/emulator.py @@ -41,18 +41,18 @@ def configure( if "sbu" in features_wanted: sources += ["embed/trezorhal/unix/sbu.c"] - defines += ["USE_SBU=1"] + defines += ["USE_SBU=1"] if "optiga" in features_wanted: sources += ["embed/trezorhal/unix/optiga_hal.c"] sources += ["embed/trezorhal/unix/optiga.c"] features_available.append("optiga") - defines += ["USE_OPTIGA=1"] + defines += ["USE_OPTIGA=1"] if "input" in features_wanted: sources += ["embed/trezorhal/unix/touch.c"] features_available.append("touch") - defines += ["USE_TOUCH=1"] + defines += ["USE_TOUCH=1"] features_available.append("backlight") defines += ["USE_BACKLIGHT=1"] diff --git a/core/site_scons/models/T3W1/trezor_t3w1_revA.py b/core/site_scons/models/T3W1/trezor_t3w1_revA.py index a3e6da43e3..fce173b7a9 100644 --- a/core/site_scons/models/T3W1/trezor_t3w1_revA.py +++ b/core/site_scons/models/T3W1/trezor_t3w1_revA.py @@ -48,9 +48,9 @@ def configure( features_available.append("touch") # sources += ["embed/trezorhal/stm32u5/button.c"] # features_available.append("button") - defines += ["USE_TOUCH=1"] - defines += ["USE_I2C=1"] - # defines += ["USE_BUTTON=1"] + defines += ["USE_TOUCH=1"] + defines += ["USE_I2C=1"] + # defines += ["USE_BUTTON=1"] # if "ble" in features_wanted: # sources += ["embed/trezorhal/stm32f4/ble/ble_hal.c"] @@ -62,7 +62,7 @@ def configure( # "vendor/micropython/lib/stm32lib/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_uart.c" # ] # features_available.append("ble") - # defines += ["USE_BLE=1"] + # defines += ["USE_BLE=1"] if "ble" in features_wanted: sources += [ @@ -72,7 +72,7 @@ def configure( if "sbu" in features_wanted: sources += ["embed/trezorhal/stm32u5/sbu.c"] features_available.append("sbu") - defines += ["USE_SBU=1"] + defines += ["USE_SBU=1"] if "usb" in features_wanted: sources += [