1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-12-22 14:28:07 +00:00

refactor(core): define USE_xxx consistently with feature flags

[no changelog]
This commit is contained in:
cepetr 2024-11-15 10:07:00 +01:00 committed by cepetr
parent 7fc226258e
commit 82bc0ef186
14 changed files with 45 additions and 49 deletions

View File

@ -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;

View File

@ -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.

View File

@ -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 += [

View File

@ -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 += [

View File

@ -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"]

View File

@ -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"]

View File

@ -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"]

View File

@ -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 += [

View File

@ -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"]

View File

@ -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",

View File

@ -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"]

View File

@ -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",

View File

@ -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"]

View File

@ -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 += [