mirror of
https://github.com/trezor/trezor-firmware.git
synced 2025-06-18 05:58:45 +00:00
refactor(core): improve flexibility of build, allow different touch panel driver, allow STM32F429
[no changelog]
This commit is contained in:
parent
b049abff15
commit
ead61d1e90
@ -18,6 +18,8 @@ if TREZOR_MODEL in ('1', ):
|
|||||||
)
|
)
|
||||||
Return()
|
Return()
|
||||||
|
|
||||||
|
FEATURES_WANTED = ["sdcard"]
|
||||||
|
|
||||||
CCFLAGS_MOD = ''
|
CCFLAGS_MOD = ''
|
||||||
CPPPATH_MOD = []
|
CPPPATH_MOD = []
|
||||||
CPPDEFINES_MOD = []
|
CPPDEFINES_MOD = []
|
||||||
@ -92,7 +94,6 @@ SOURCE_TREZORHAL = [
|
|||||||
'embed/trezorhal/flash.c',
|
'embed/trezorhal/flash.c',
|
||||||
'embed/trezorhal/lowlevel.c',
|
'embed/trezorhal/lowlevel.c',
|
||||||
'embed/trezorhal/mini_printf.c',
|
'embed/trezorhal/mini_printf.c',
|
||||||
'embed/trezorhal/sdcard.c',
|
|
||||||
'embed/trezorhal/stm32.c',
|
'embed/trezorhal/stm32.c',
|
||||||
'embed/trezorhal/systick.c',
|
'embed/trezorhal/systick.c',
|
||||||
'embed/trezorhal/rng.c',
|
'embed/trezorhal/rng.c',
|
||||||
@ -102,7 +103,7 @@ SOURCE_TREZORHAL = [
|
|||||||
|
|
||||||
env = Environment(ENV=os.environ, CFLAGS='%s -DPRODUCTION=%s' % (ARGUMENTS.get('CFLAGS', ''), ARGUMENTS.get('PRODUCTION', '0')))
|
env = Environment(ENV=os.environ, CFLAGS='%s -DPRODUCTION=%s' % (ARGUMENTS.get('CFLAGS', ''), ARGUMENTS.get('PRODUCTION', '0')))
|
||||||
|
|
||||||
tools.configure_board(TREZOR_MODEL, env, CPPDEFINES_MOD, SOURCE_TREZORHAL)
|
FEATURES_AVAILABLE = tools.configure_board(TREZOR_MODEL, FEATURES_WANTED, env, CPPDEFINES_MOD, SOURCE_TREZORHAL)
|
||||||
|
|
||||||
env.Replace(
|
env.Replace(
|
||||||
CP='cp',
|
CP='cp',
|
||||||
|
@ -19,6 +19,8 @@ if TREZOR_MODEL in ('1', ):
|
|||||||
)
|
)
|
||||||
Return()
|
Return()
|
||||||
|
|
||||||
|
FEATURES_WANTED = ["input", "rgb_led"]
|
||||||
|
|
||||||
CCFLAGS_MOD = ''
|
CCFLAGS_MOD = ''
|
||||||
CPPPATH_MOD = []
|
CPPPATH_MOD = []
|
||||||
CPPDEFINES_MOD = []
|
CPPDEFINES_MOD = []
|
||||||
@ -133,12 +135,6 @@ SOURCE_TREZORHAL = [
|
|||||||
'embed/trezorhal/vectortable.s',
|
'embed/trezorhal/vectortable.s',
|
||||||
]
|
]
|
||||||
|
|
||||||
if TREZOR_MODEL in ('R'):
|
|
||||||
SOURCE_TREZORHAL.append('embed/trezorhal/button.c')
|
|
||||||
SOURCE_TREZORHAL.append('embed/trezorhal/rgb_led.c')
|
|
||||||
if TREZOR_MODEL in ('T',):
|
|
||||||
SOURCE_TREZORHAL.append('embed/trezorhal/touch.c')
|
|
||||||
|
|
||||||
if DMA2D:
|
if DMA2D:
|
||||||
SOURCE_STMHAL.append('vendor/micropython/lib/stm32lib/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_dma2d.c')
|
SOURCE_STMHAL.append('vendor/micropython/lib/stm32lib/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_dma2d.c')
|
||||||
SOURCE_TREZORHAL.append('embed/trezorhal/dma2d.c')
|
SOURCE_TREZORHAL.append('embed/trezorhal/dma2d.c')
|
||||||
@ -155,7 +151,7 @@ tools.add_font('MONO', FONT_MONO, CPPDEFINES_MOD, SOURCE_MOD)
|
|||||||
|
|
||||||
env = Environment(ENV=os.environ, CFLAGS='%s -DPRODUCTION=%s' % (ARGUMENTS.get('CFLAGS', ''), ARGUMENTS.get('PRODUCTION', '0')))
|
env = Environment(ENV=os.environ, CFLAGS='%s -DPRODUCTION=%s' % (ARGUMENTS.get('CFLAGS', ''), ARGUMENTS.get('PRODUCTION', '0')))
|
||||||
|
|
||||||
tools.configure_board(TREZOR_MODEL, env, CPPDEFINES_MOD, SOURCE_TREZORHAL)
|
FEATURES_AVAILABLE = tools.configure_board(TREZOR_MODEL, FEATURES_WANTED, env, CPPDEFINES_MOD, SOURCE_TREZORHAL)
|
||||||
|
|
||||||
env.Replace(
|
env.Replace(
|
||||||
CP='cp',
|
CP='cp',
|
||||||
|
@ -18,6 +18,8 @@ if TREZOR_MODEL in ('1', ):
|
|||||||
)
|
)
|
||||||
Return()
|
Return()
|
||||||
|
|
||||||
|
FEATURES_WANTED = ["input"]
|
||||||
|
|
||||||
CCFLAGS_MOD = ''
|
CCFLAGS_MOD = ''
|
||||||
CPPPATH_MOD = []
|
CPPPATH_MOD = []
|
||||||
CPPDEFINES_MOD = []
|
CPPDEFINES_MOD = []
|
||||||
@ -77,6 +79,7 @@ SOURCE_MOD += [
|
|||||||
SOURCE_STMHAL = [
|
SOURCE_STMHAL = [
|
||||||
'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_dma.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',
|
||||||
@ -120,7 +123,6 @@ SOURCE_TREZORHAL = [
|
|||||||
'embed/trezorhal/rng.c',
|
'embed/trezorhal/rng.c',
|
||||||
'embed/trezorhal/stm32.c',
|
'embed/trezorhal/stm32.c',
|
||||||
'embed/trezorhal/systick.c',
|
'embed/trezorhal/systick.c',
|
||||||
'embed/trezorhal/touch.c',
|
|
||||||
'embed/trezorhal/usb.c',
|
'embed/trezorhal/usb.c',
|
||||||
'embed/trezorhal/usbd_conf.c',
|
'embed/trezorhal/usbd_conf.c',
|
||||||
'embed/trezorhal/usbd_core.c',
|
'embed/trezorhal/usbd_core.c',
|
||||||
@ -138,7 +140,7 @@ tools.add_font('MONO', FONT_MONO, CPPDEFINES_MOD, SOURCE_MOD)
|
|||||||
|
|
||||||
env = Environment(ENV=os.environ, CFLAGS='%s -DPRODUCTION=%s' % (ARGUMENTS.get('CFLAGS', ''), ARGUMENTS.get('PRODUCTION', '0')))
|
env = Environment(ENV=os.environ, CFLAGS='%s -DPRODUCTION=%s' % (ARGUMENTS.get('CFLAGS', ''), ARGUMENTS.get('PRODUCTION', '0')))
|
||||||
|
|
||||||
tools.configure_board(TREZOR_MODEL, env, CPPDEFINES_MOD, SOURCE_TREZORHAL)
|
FEATURES_AVAILABLE = tools.configure_board(TREZOR_MODEL, FEATURES_WANTED, env, CPPDEFINES_MOD, SOURCE_TREZORHAL)
|
||||||
|
|
||||||
env.Replace(
|
env.Replace(
|
||||||
CP='cp',
|
CP='cp',
|
||||||
|
@ -16,6 +16,8 @@ FEATURE_FLAGS = {
|
|||||||
"SYSTEM_VIEW": False,
|
"SYSTEM_VIEW": False,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
FEATURES_WANTED = ["input", "sbu", "sdcard", "rgb_led"]
|
||||||
|
|
||||||
CCFLAGS_MOD = ''
|
CCFLAGS_MOD = ''
|
||||||
CPPPATH_MOD = []
|
CPPPATH_MOD = []
|
||||||
CPPDEFINES_MOD = []
|
CPPDEFINES_MOD = []
|
||||||
@ -376,21 +378,6 @@ SOURCE_TREZORHAL = [
|
|||||||
'embed/trezorhal/util.s',
|
'embed/trezorhal/util.s',
|
||||||
'embed/trezorhal/vectortable.s',
|
'embed/trezorhal/vectortable.s',
|
||||||
]
|
]
|
||||||
if TREZOR_MODEL in ('T',):
|
|
||||||
SOURCE_TREZORHAL += [
|
|
||||||
'embed/trezorhal/sbu.c',
|
|
||||||
'embed/trezorhal/sdcard.c',
|
|
||||||
'embed/trezorhal/touch.c',
|
|
||||||
]
|
|
||||||
elif TREZOR_MODEL in ('R',):
|
|
||||||
SOURCE_TREZORHAL += [
|
|
||||||
'embed/trezorhal/button.c',
|
|
||||||
'embed/trezorhal/rgb_led.c',
|
|
||||||
]
|
|
||||||
elif TREZOR_MODEL in ('1',):
|
|
||||||
SOURCE_TREZORHAL += [
|
|
||||||
'embed/trezorhal/button.c',
|
|
||||||
]
|
|
||||||
|
|
||||||
|
|
||||||
if DMA2D:
|
if DMA2D:
|
||||||
@ -435,7 +422,7 @@ SOURCE_QSTR = SOURCE_MOD + SOURCE_MICROPYTHON + SOURCE_MICROPYTHON_SPEED
|
|||||||
|
|
||||||
env = Environment(ENV=os.environ, CFLAGS='%s -DPRODUCTION=%s -DPYOPT=%s -DBITCOIN_ONLY=%s' % (ARGUMENTS.get('CFLAGS', ''), ARGUMENTS.get('PRODUCTION', '0'), PYOPT, BITCOIN_ONLY))
|
env = Environment(ENV=os.environ, CFLAGS='%s -DPRODUCTION=%s -DPYOPT=%s -DBITCOIN_ONLY=%s' % (ARGUMENTS.get('CFLAGS', ''), ARGUMENTS.get('PRODUCTION', '0'), PYOPT, BITCOIN_ONLY))
|
||||||
|
|
||||||
tools.configure_board(TREZOR_MODEL, env, CPPDEFINES_MOD, SOURCE_TREZORHAL)
|
FEATURES_AVAILABLE = tools.configure_board(TREZOR_MODEL, FEATURES_WANTED, env, CPPDEFINES_MOD, SOURCE_TREZORHAL)
|
||||||
|
|
||||||
env.Tool('micropython')
|
env.Tool('micropython')
|
||||||
|
|
||||||
|
@ -6,6 +6,8 @@ import tools
|
|||||||
TREZOR_MODEL = ARGUMENTS.get('TREZOR_MODEL', 'T')
|
TREZOR_MODEL = ARGUMENTS.get('TREZOR_MODEL', 'T')
|
||||||
CMAKELISTS = int(ARGUMENTS.get('CMAKELISTS', 0))
|
CMAKELISTS = int(ARGUMENTS.get('CMAKELISTS', 0))
|
||||||
|
|
||||||
|
FEATURES_WANTED = ["input", "sbu", "sdcard", "rdb_led"]
|
||||||
|
|
||||||
CCFLAGS_MOD = ''
|
CCFLAGS_MOD = ''
|
||||||
CPPPATH_MOD = []
|
CPPPATH_MOD = []
|
||||||
CPPDEFINES_MOD = []
|
CPPDEFINES_MOD = []
|
||||||
@ -85,11 +87,8 @@ SOURCE_TREZORHAL = [
|
|||||||
'embed/trezorhal/mini_printf.c',
|
'embed/trezorhal/mini_printf.c',
|
||||||
'embed/trezorhal/random_delays.c',
|
'embed/trezorhal/random_delays.c',
|
||||||
'embed/trezorhal/rng.c',
|
'embed/trezorhal/rng.c',
|
||||||
'embed/trezorhal/sbu.c',
|
|
||||||
'embed/trezorhal/sdcard.c',
|
|
||||||
'embed/trezorhal/stm32.c',
|
'embed/trezorhal/stm32.c',
|
||||||
'embed/trezorhal/systick.c',
|
'embed/trezorhal/systick.c',
|
||||||
'embed/trezorhal/touch.c',
|
|
||||||
'embed/trezorhal/usb.c',
|
'embed/trezorhal/usb.c',
|
||||||
'embed/trezorhal/usbd_conf.c',
|
'embed/trezorhal/usbd_conf.c',
|
||||||
'embed/trezorhal/usbd_core.c',
|
'embed/trezorhal/usbd_core.c',
|
||||||
@ -107,7 +106,7 @@ tools.add_font('MONO', FONT_MONO, CPPDEFINES_MOD, SOURCE_MOD)
|
|||||||
|
|
||||||
env = Environment(ENV=os.environ, CFLAGS='%s -DPRODUCTION=%s' % (ARGUMENTS.get('CFLAGS', ''), ARGUMENTS.get('PRODUCTION', '0')))
|
env = Environment(ENV=os.environ, CFLAGS='%s -DPRODUCTION=%s' % (ARGUMENTS.get('CFLAGS', ''), ARGUMENTS.get('PRODUCTION', '0')))
|
||||||
|
|
||||||
tools.configure_board(TREZOR_MODEL, env, CPPDEFINES_MOD, SOURCE_TREZORHAL)
|
FEATURES_AVAILABLE = tools.configure_board(TREZOR_MODEL, FEATURES_WANTED, env, CPPDEFINES_MOD, SOURCE_TREZORHAL)
|
||||||
|
|
||||||
env.Replace(
|
env.Replace(
|
||||||
CP='cp',
|
CP='cp',
|
||||||
|
@ -6,6 +6,8 @@ import tools
|
|||||||
TREZOR_MODEL = ARGUMENTS.get('TREZOR_MODEL', 'T')
|
TREZOR_MODEL = ARGUMENTS.get('TREZOR_MODEL', 'T')
|
||||||
CMAKELISTS = int(ARGUMENTS.get('CMAKELISTS', 0))
|
CMAKELISTS = int(ARGUMENTS.get('CMAKELISTS', 0))
|
||||||
|
|
||||||
|
FEATURES_WANTED = ["input", "sdcard"]
|
||||||
|
|
||||||
CCFLAGS_MOD = ''
|
CCFLAGS_MOD = ''
|
||||||
CPPPATH_MOD = []
|
CPPPATH_MOD = []
|
||||||
CPPDEFINES_MOD = []
|
CPPDEFINES_MOD = []
|
||||||
@ -78,11 +80,8 @@ SOURCE_TREZORHAL = [
|
|||||||
'embed/trezorhal/flash.c',
|
'embed/trezorhal/flash.c',
|
||||||
'embed/trezorhal/mini_printf.c',
|
'embed/trezorhal/mini_printf.c',
|
||||||
'embed/trezorhal/rng.c',
|
'embed/trezorhal/rng.c',
|
||||||
'embed/trezorhal/sbu.c',
|
|
||||||
'embed/trezorhal/sdcard.c',
|
|
||||||
'embed/trezorhal/systick.c',
|
'embed/trezorhal/systick.c',
|
||||||
'embed/trezorhal/stm32.c',
|
'embed/trezorhal/stm32.c',
|
||||||
'embed/trezorhal/touch.c',
|
|
||||||
'embed/trezorhal/usb.c',
|
'embed/trezorhal/usb.c',
|
||||||
'embed/trezorhal/usbd_conf.c',
|
'embed/trezorhal/usbd_conf.c',
|
||||||
'embed/trezorhal/usbd_core.c',
|
'embed/trezorhal/usbd_core.c',
|
||||||
@ -100,7 +99,7 @@ tools.add_font('MONO', FONT_MONO, CPPDEFINES_MOD, SOURCE_MOD)
|
|||||||
|
|
||||||
env = Environment(ENV=os.environ, CFLAGS='%s -DPRODUCTION=%s' % (ARGUMENTS.get('CFLAGS', ''), ARGUMENTS.get('PRODUCTION', '0')))
|
env = Environment(ENV=os.environ, CFLAGS='%s -DPRODUCTION=%s' % (ARGUMENTS.get('CFLAGS', ''), ARGUMENTS.get('PRODUCTION', '0')))
|
||||||
|
|
||||||
tools.configure_board(TREZOR_MODEL, env, CPPDEFINES_MOD, SOURCE_TREZORHAL)
|
FEATURES_AVAILABLE = tools.configure_board(TREZOR_MODEL, FEATURES_WANTED, env, CPPDEFINES_MOD, SOURCE_TREZORHAL)
|
||||||
|
|
||||||
env.Replace(
|
env.Replace(
|
||||||
CP='cp',
|
CP='cp',
|
||||||
|
@ -340,7 +340,7 @@ SOURCE_UNIX = [
|
|||||||
'embed/unix/profile.c',
|
'embed/unix/profile.c',
|
||||||
'embed/unix/random_delays.c',
|
'embed/unix/random_delays.c',
|
||||||
'embed/unix/rng.c',
|
'embed/unix/rng.c',
|
||||||
'embed/unix/touch.c',
|
'embed/unix/touch/touch.c',
|
||||||
'embed/unix/usb.c',
|
'embed/unix/usb.c',
|
||||||
'vendor/micropython/shared/runtime/gchelper_generic.c',
|
'vendor/micropython/shared/runtime/gchelper_generic.c',
|
||||||
'vendor/micropython/ports/unix/alloc.c',
|
'vendor/micropython/ports/unix/alloc.c',
|
||||||
|
@ -26,7 +26,7 @@
|
|||||||
#include "flash.h"
|
#include "flash.h"
|
||||||
#include "image.h"
|
#include "image.h"
|
||||||
#include "rng.h"
|
#include "rng.h"
|
||||||
#ifdef TREZOR_MODEL_T
|
#ifdef USE_SD_CARD
|
||||||
#include "sdcard.h"
|
#include "sdcard.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -68,7 +68,7 @@ struct BoardCapabilities capablities
|
|||||||
extern uint32_t sram_start[];
|
extern uint32_t sram_start[];
|
||||||
#define sdcard_buf sram_start
|
#define sdcard_buf sram_start
|
||||||
|
|
||||||
#if defined TREZOR_MODEL_T
|
#if defined USE_SD_CARD
|
||||||
static uint32_t check_sdcard(void) {
|
static uint32_t check_sdcard(void) {
|
||||||
if (sectrue != sdcard_power_on()) {
|
if (sectrue != sdcard_power_on()) {
|
||||||
return 0;
|
return 0;
|
||||||
@ -218,7 +218,7 @@ int main(void) {
|
|||||||
display_init();
|
display_init();
|
||||||
display_clear();
|
display_clear();
|
||||||
|
|
||||||
#if defined TREZOR_MODEL_T
|
#if defined USE_SD_CARD
|
||||||
sdcard_init();
|
sdcard_init();
|
||||||
|
|
||||||
if (check_sdcard()) {
|
if (check_sdcard()) {
|
||||||
|
@ -34,12 +34,12 @@
|
|||||||
#include "mini_printf.h"
|
#include "mini_printf.h"
|
||||||
#include "version.h"
|
#include "version.h"
|
||||||
|
|
||||||
#if defined TREZOR_MODEL_T
|
#if defined USE_TOUCH
|
||||||
#include "touch.h"
|
#include "touch/touch.h"
|
||||||
#elif defined TREZOR_MODEL_R
|
#elif defined USE_BUTTON
|
||||||
#include "button.h"
|
#include "button.h"
|
||||||
#else
|
#else
|
||||||
#error Unknown Trezor model
|
#error No input method defined
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define BACKLIGHT_NORMAL 150
|
#define BACKLIGHT_NORMAL 150
|
||||||
@ -376,7 +376,7 @@ void ui_fadeout(void) {
|
|||||||
|
|
||||||
int ui_user_input(int zones) {
|
int ui_user_input(int zones) {
|
||||||
for (;;) {
|
for (;;) {
|
||||||
#if defined TREZOR_MODEL_T
|
#if defined USE_TOUCH
|
||||||
uint32_t evt = touch_click();
|
uint32_t evt = touch_click();
|
||||||
uint16_t x = touch_unpack_x(evt);
|
uint16_t x = touch_unpack_x(evt);
|
||||||
uint16_t y = touch_unpack_y(evt);
|
uint16_t y = touch_unpack_y(evt);
|
||||||
@ -400,7 +400,7 @@ int ui_user_input(int zones) {
|
|||||||
y < 54 + 32) {
|
y < 54 + 32) {
|
||||||
return INPUT_INFO;
|
return INPUT_INFO;
|
||||||
}
|
}
|
||||||
#elif defined TREZOR_MODEL_R
|
#elif defined USE_BUTTON
|
||||||
uint32_t evt = button_read();
|
uint32_t evt = button_read();
|
||||||
if (evt == (BTN_LEFT | BTN_EVT_DOWN)) {
|
if (evt == (BTN_LEFT | BTN_EVT_DOWN)) {
|
||||||
return INPUT_CANCEL;
|
return INPUT_CANCEL;
|
||||||
@ -409,7 +409,7 @@ int ui_user_input(int zones) {
|
|||||||
return INPUT_CONFIRM;
|
return INPUT_CONFIRM;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
#error Unknown Trezor model
|
#error No input method defined
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -30,12 +30,16 @@
|
|||||||
#include "random_delays.h"
|
#include "random_delays.h"
|
||||||
#include "secbool.h"
|
#include "secbool.h"
|
||||||
#include "stm32.h"
|
#include "stm32.h"
|
||||||
#ifdef TREZOR_MODEL_T
|
#ifdef USE_DMA2D
|
||||||
#include "dma2d.h"
|
#include "dma2d.h"
|
||||||
#include "touch.h"
|
|
||||||
#endif
|
#endif
|
||||||
#if defined TREZOR_MODEL_R
|
#ifdef USE_TOUCH
|
||||||
|
#include "touch/touch.h"
|
||||||
|
#endif
|
||||||
|
#ifdef USE_BUTTON
|
||||||
#include "button.h"
|
#include "button.h"
|
||||||
|
#endif
|
||||||
|
#ifdef USE_RGB_LED
|
||||||
#include "rgb_led.h"
|
#include "rgb_led.h"
|
||||||
#endif
|
#endif
|
||||||
#include "usb.h"
|
#include "usb.h"
|
||||||
@ -259,12 +263,16 @@ int main(void) {
|
|||||||
#if defined TREZOR_MODEL_T
|
#if defined TREZOR_MODEL_T
|
||||||
set_core_clock(CLOCK_180_MHZ);
|
set_core_clock(CLOCK_180_MHZ);
|
||||||
display_set_little_endian();
|
display_set_little_endian();
|
||||||
|
#endif
|
||||||
|
#ifdef USE_TOUCH
|
||||||
touch_power_on();
|
touch_power_on();
|
||||||
touch_init();
|
touch_init();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined TREZOR_MODEL_R
|
#ifdef USE_BUTTON
|
||||||
button_init();
|
button_init();
|
||||||
|
#endif
|
||||||
|
#ifdef USE_RGB_LED
|
||||||
rgb_led_init();
|
rgb_led_init();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -285,7 +293,7 @@ int main(void) {
|
|||||||
// delay to detect touch or skip if we know we are staying in bootloader
|
// delay to detect touch or skip if we know we are staying in bootloader
|
||||||
// anyway
|
// anyway
|
||||||
uint32_t touched = 0;
|
uint32_t touched = 0;
|
||||||
#if defined TREZOR_MODEL_T
|
#ifdef USE_TOUCH
|
||||||
if (stay_in_bootloader != sectrue) {
|
if (stay_in_bootloader != sectrue) {
|
||||||
for (int i = 0; i < 100; i++) {
|
for (int i = 0; i < 100; i++) {
|
||||||
touched = touch_is_detected() | touch_read();
|
touched = touch_is_detected() | touch_read();
|
||||||
@ -295,7 +303,7 @@ int main(void) {
|
|||||||
hal_delay(1);
|
hal_delay(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#elif defined TREZOR_MODEL_R
|
#elif defined USE_BUTTON
|
||||||
button_read();
|
button_read();
|
||||||
if (button_state_left() == 1) {
|
if (button_state_left() == 1) {
|
||||||
touched = 1;
|
touched = 1;
|
||||||
@ -425,9 +433,9 @@ int main(void) {
|
|||||||
|
|
||||||
if ((vhdr.vtrust & VTRUST_CLICK) == 0) {
|
if ((vhdr.vtrust & VTRUST_CLICK) == 0) {
|
||||||
ui_screen_boot_click();
|
ui_screen_boot_click();
|
||||||
#if defined TREZOR_MODEL_T
|
#if defined USE_TOUCH
|
||||||
touch_click();
|
touch_click();
|
||||||
#elif defined TREZOR_MODEL_R
|
#elif defined USE_BUTTON
|
||||||
for (;;) {
|
for (;;) {
|
||||||
button_read();
|
button_read();
|
||||||
if (button_state_left() != 0 && button_state_right() != 0) {
|
if (button_state_left() != 0 && button_state_right() != 0) {
|
||||||
|
@ -29,7 +29,9 @@
|
|||||||
#include "random_delays.h"
|
#include "random_delays.h"
|
||||||
#include "rng.h"
|
#include "rng.h"
|
||||||
#include "secbool.h"
|
#include "secbool.h"
|
||||||
#include "touch.h"
|
#ifdef USE_TOUCH
|
||||||
|
#include "touch/touch.h"
|
||||||
|
#endif
|
||||||
#include "usb.h"
|
#include "usb.h"
|
||||||
#include "version.h"
|
#include "version.h"
|
||||||
|
|
||||||
@ -215,8 +217,10 @@ static void check_bootloader_version(void) {
|
|||||||
|
|
||||||
int main(void) {
|
int main(void) {
|
||||||
random_delays_init();
|
random_delays_init();
|
||||||
|
#ifdef USE_TOUCH
|
||||||
touch_init();
|
touch_init();
|
||||||
touch_power_on();
|
touch_power_on();
|
||||||
|
#endif
|
||||||
|
|
||||||
mpu_config_bootloader();
|
mpu_config_bootloader();
|
||||||
|
|
||||||
|
@ -28,7 +28,7 @@
|
|||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
#include "button.h"
|
#include "button.h"
|
||||||
#include "touch.h"
|
#include "touch/touch.h"
|
||||||
#include "usb.h"
|
#include "usb.h"
|
||||||
|
|
||||||
// Whether USB data pins were connected on last check (USB configured)
|
// Whether USB data pins were connected on last check (USB configured)
|
||||||
|
BIN
core/embed/firmware/bootloaders/bootloader_T2B1.bin
Executable file
BIN
core/embed/firmware/bootloaders/bootloader_T2B1.bin
Executable file
Binary file not shown.
@ -44,24 +44,28 @@
|
|||||||
#include "image.h"
|
#include "image.h"
|
||||||
#include "mpu.h"
|
#include "mpu.h"
|
||||||
#include "random_delays.h"
|
#include "random_delays.h"
|
||||||
#ifdef TREZOR_MODEL_R
|
#ifdef USE_RGB_LED
|
||||||
#include "rgb_led.h"
|
#include "rgb_led.h"
|
||||||
#endif
|
#endif
|
||||||
#ifdef TREZOR_MODEL_T
|
#ifdef USE_DMA2D
|
||||||
#include "dma2d.h"
|
#include "dma2d.h"
|
||||||
#endif
|
#endif
|
||||||
#if defined TREZOR_MODEL_R || defined TREZOR_MODEL_1
|
#ifdef USE_BUTTON
|
||||||
#include "button.h"
|
#include "button.h"
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef USE_TOUCH
|
||||||
|
#include "touch/touch.h"
|
||||||
|
#endif
|
||||||
|
#ifdef USE_SD_CARD
|
||||||
|
#include "sdcard.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef SYSTEM_VIEW
|
#ifdef SYSTEM_VIEW
|
||||||
#include "systemview.h"
|
#include "systemview.h"
|
||||||
#endif
|
#endif
|
||||||
#include "rng.h"
|
#include "rng.h"
|
||||||
#include "sdcard.h"
|
|
||||||
#include "stm32.h"
|
#include "stm32.h"
|
||||||
#include "supervise.h"
|
#include "supervise.h"
|
||||||
#include "touch.h"
|
|
||||||
#ifdef USE_SECP256K1_ZKP
|
#ifdef USE_SECP256K1_ZKP
|
||||||
#include "zkp_context.h"
|
#include "zkp_context.h"
|
||||||
#endif
|
#endif
|
||||||
@ -111,18 +115,23 @@ int main(void) {
|
|||||||
SCB->SHCSR |= (SCB_SHCSR_USGFAULTENA_Msk | SCB_SHCSR_BUSFAULTENA_Msk);
|
SCB->SHCSR |= (SCB_SHCSR_USGFAULTENA_Msk | SCB_SHCSR_BUSFAULTENA_Msk);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined TREZOR_MODEL_1
|
#if defined TREZOR_MODEL_T
|
||||||
|
set_core_clock(CLOCK_180_MHZ);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef USE_BUTTON
|
||||||
button_init();
|
button_init();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined TREZOR_MODEL_R
|
#ifdef USE_RGB_LED
|
||||||
button_init();
|
|
||||||
rgb_led_init();
|
rgb_led_init();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined TREZOR_MODEL_T
|
#ifdef USE_TOUCH
|
||||||
set_core_clock(CLOCK_180_MHZ);
|
|
||||||
touch_init();
|
touch_init();
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef USE_SD_CARD
|
||||||
sdcard_init();
|
sdcard_init();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -32,7 +32,7 @@
|
|||||||
#include "sbu.h"
|
#include "sbu.h"
|
||||||
#include "sdcard.h"
|
#include "sdcard.h"
|
||||||
#include "secbool.h"
|
#include "secbool.h"
|
||||||
#include "touch.h"
|
#include "touch/touch.h"
|
||||||
#include "usb.h"
|
#include "usb.h"
|
||||||
|
|
||||||
#include "memzero.h"
|
#include "memzero.h"
|
||||||
|
@ -31,7 +31,7 @@
|
|||||||
#include "sbu.h"
|
#include "sbu.h"
|
||||||
#include "sdcard.h"
|
#include "sdcard.h"
|
||||||
#include "secbool.h"
|
#include "secbool.h"
|
||||||
#include "touch.h"
|
#include "touch/touch.h"
|
||||||
|
|
||||||
static void progress_callback(int pos, int len) { display_printf("."); }
|
static void progress_callback(int pos, int len) { display_printf("."); }
|
||||||
|
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
#ifndef _TREZOR_1_H
|
#ifndef _TREZOR_1_H
|
||||||
#define _TREZOR_1_H
|
#define _TREZOR_1_H
|
||||||
|
|
||||||
|
#define USE_BUTTON 1
|
||||||
|
|
||||||
#include "displays/vg-2864ksweg01.h"
|
#include "displays/vg-2864ksweg01.h"
|
||||||
|
|
||||||
#define BTN_LEFT_PIN GPIO_PIN_5
|
#define BTN_LEFT_PIN GPIO_PIN_5
|
||||||
|
@ -1,6 +1,9 @@
|
|||||||
#ifndef _TREZOR_R_V3_H
|
#ifndef _TREZOR_R_V3_H
|
||||||
#define _TREZOR_R_V3_H
|
#define _TREZOR_R_V3_H
|
||||||
|
|
||||||
|
#define USE_BUTTON 1
|
||||||
|
#define USE_SBU 1
|
||||||
|
|
||||||
#include "displays/ug-2828tswig01.h"
|
#include "displays/ug-2828tswig01.h"
|
||||||
|
|
||||||
#define BTN_LEFT_PIN GPIO_PIN_0
|
#define BTN_LEFT_PIN GPIO_PIN_0
|
||||||
|
@ -1,6 +1,9 @@
|
|||||||
#ifndef _TREZOR_R_V4_H
|
#ifndef _TREZOR_R_V4_H
|
||||||
#define _TREZOR_R_V4_H
|
#define _TREZOR_R_V4_H
|
||||||
|
|
||||||
|
#define USE_BUTTON 1
|
||||||
|
#define USE_SBU 1
|
||||||
|
|
||||||
#include "displays/vg-2864ksweg01.h"
|
#include "displays/vg-2864ksweg01.h"
|
||||||
|
|
||||||
#define BTN_LEFT_PIN GPIO_PIN_5
|
#define BTN_LEFT_PIN GPIO_PIN_5
|
||||||
|
@ -1,6 +1,10 @@
|
|||||||
#ifndef _TREZOR_T_H
|
#ifndef _TREZOR_T_H
|
||||||
#define _TREZOR_T_H
|
#define _TREZOR_T_H
|
||||||
|
|
||||||
|
#define USE_SD_CARD 1
|
||||||
|
#define USE_TOUCH 1
|
||||||
|
#define USE_SBU 1
|
||||||
|
|
||||||
#include "displays/st7789v.h"
|
#include "displays/st7789v.h"
|
||||||
|
|
||||||
#endif //_TREZOR_T_H
|
#endif //_TREZOR_T_H
|
||||||
|
@ -81,7 +81,7 @@ extern const uint8_t FIRMWARE_SECTORS[FIRMWARE_SECTORS_COUNT];
|
|||||||
|
|
||||||
// note: FLASH_SR_RDERR is STM32F42xxx and STM32F43xxx specific (STM32F427)
|
// note: FLASH_SR_RDERR is STM32F42xxx and STM32F43xxx specific (STM32F427)
|
||||||
// (reference RM0090 section 3.7.5)
|
// (reference RM0090 section 3.7.5)
|
||||||
#ifndef STM32F427xx
|
#if !defined STM32F427xx && !defined STM32F429xx
|
||||||
#define FLASH_SR_RDERR 0
|
#define FLASH_SR_RDERR 0
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -72,7 +72,7 @@ void mpu_config_bootloader(void) {
|
|||||||
LL_MPU_REGION_SIZE_1GB | LL_MPU_REGION_FULL_ACCESS |
|
LL_MPU_REGION_SIZE_1GB | LL_MPU_REGION_FULL_ACCESS |
|
||||||
MPU_RASR_XN_Msk;
|
MPU_RASR_XN_Msk;
|
||||||
|
|
||||||
#ifdef STM32F427xx
|
#if defined STM32F427xx || defined STM32F429xx
|
||||||
// CCMRAM (0x10000000 - 0x1000FFFF, read-write, execute never)
|
// CCMRAM (0x10000000 - 0x1000FFFF, read-write, execute never)
|
||||||
MPU->RNR = MPU_REGION_NUMBER5;
|
MPU->RNR = MPU_REGION_NUMBER5;
|
||||||
MPU->RBAR = CCMDATARAM_BASE;
|
MPU->RBAR = CCMDATARAM_BASE;
|
||||||
@ -153,7 +153,7 @@ void mpu_config_firmware(void) {
|
|||||||
LL_MPU_REGION_SIZE_1GB | LL_MPU_REGION_FULL_ACCESS |
|
LL_MPU_REGION_SIZE_1GB | LL_MPU_REGION_FULL_ACCESS |
|
||||||
MPU_RASR_XN_Msk;
|
MPU_RASR_XN_Msk;
|
||||||
|
|
||||||
#ifdef STM32F427xx
|
#if defined STM32F427xx || defined STM32F429xx
|
||||||
// CCMRAM (0x10000000 - 0x1000FFFF, read-write, execute never)
|
// CCMRAM (0x10000000 - 0x1000FFFF, read-write, execute never)
|
||||||
MPU->RNR = MPU_REGION_NUMBER7;
|
MPU->RNR = MPU_REGION_NUMBER7;
|
||||||
MPU->RBAR = CCMDATARAM_BASE;
|
MPU->RBAR = CCMDATARAM_BASE;
|
||||||
|
@ -34,7 +34,7 @@ typedef struct {
|
|||||||
uint32_t plln;
|
uint32_t plln;
|
||||||
} clock_conf_t;
|
} clock_conf_t;
|
||||||
|
|
||||||
#ifdef STM32F427xx
|
#if defined STM32F427xx || defined STM32F429xx
|
||||||
#ifdef TREZOR_MODEL_T
|
#ifdef TREZOR_MODEL_T
|
||||||
#define DEFAULT_FREQ 168U
|
#define DEFAULT_FREQ 168U
|
||||||
#define DEFAULT_PLLQ 7U
|
#define DEFAULT_PLLQ 7U
|
||||||
|
@ -51,6 +51,10 @@
|
|||||||
#ifdef STM32F427xx
|
#ifdef STM32F427xx
|
||||||
#define USE_USB_HS
|
#define USE_USB_HS
|
||||||
#define USE_USB_HS_IN_FS
|
#define USE_USB_HS_IN_FS
|
||||||
|
#elif STM32F429xx
|
||||||
|
#define USE_USB_HS
|
||||||
|
#define USE_USB_HS_IN_FS
|
||||||
|
#define HAL_LTDC_MODULE_ENABLED
|
||||||
#elif STM32F405xx
|
#elif STM32F405xx
|
||||||
#define USE_USB_FS
|
#define USE_USB_FS
|
||||||
#else
|
#else
|
||||||
|
@ -24,6 +24,7 @@
|
|||||||
#include "common.h"
|
#include "common.h"
|
||||||
#include "secbool.h"
|
#include "secbool.h"
|
||||||
|
|
||||||
|
#include "ft6x36.h"
|
||||||
#include "touch.h"
|
#include "touch.h"
|
||||||
|
|
||||||
#define TOUCH_ADDRESS \
|
#define TOUCH_ADDRESS \
|
||||||
@ -360,21 +361,3 @@ uint32_t touch_read(void) {
|
|||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t touch_click(void) {
|
|
||||||
uint32_t r = 0;
|
|
||||||
// flush touch events if any
|
|
||||||
while (touch_read()) {
|
|
||||||
}
|
|
||||||
// wait for TOUCH_START
|
|
||||||
while ((touch_read() & TOUCH_START) == 0) {
|
|
||||||
}
|
|
||||||
// wait for TOUCH_END
|
|
||||||
while (((r = touch_read()) & TOUCH_END) == 0) {
|
|
||||||
}
|
|
||||||
// flush touch events if any
|
|
||||||
while (touch_read()) {
|
|
||||||
}
|
|
||||||
// return last touch coordinate
|
|
||||||
return r;
|
|
||||||
}
|
|
@ -17,30 +17,7 @@
|
|||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef TREZORHAL_TOUCH_H
|
#ifndef _TOUCH_FT6X36_H
|
||||||
#define TREZORHAL_TOUCH_H
|
#define _TOUCH_FT6X36_H
|
||||||
|
|
||||||
#include <stdint.h>
|
|
||||||
|
|
||||||
#define TOUCH_START (1U << 24)
|
|
||||||
#define TOUCH_MOVE (1U << 25)
|
|
||||||
#define TOUCH_END (1U << 26)
|
|
||||||
|
|
||||||
void touch_init(void);
|
|
||||||
void touch_power_on(void);
|
|
||||||
void touch_power_off(void);
|
|
||||||
void touch_sensitivity(uint8_t value);
|
|
||||||
uint32_t touch_read(void);
|
|
||||||
uint32_t touch_click(void);
|
|
||||||
uint32_t touch_is_detected(void);
|
|
||||||
static inline uint16_t touch_unpack_x(uint32_t evt) {
|
|
||||||
return (evt >> 12) & 0xFFF;
|
|
||||||
}
|
|
||||||
static inline uint16_t touch_unpack_y(uint32_t evt) {
|
|
||||||
return (evt >> 0) & 0xFFF;
|
|
||||||
}
|
|
||||||
static inline uint32_t touch_pack_xy(uint16_t x, uint16_t y) {
|
|
||||||
return ((x & 0xFFF) << 12) | (y & 0xFFF);
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
#endif
|
20
core/embed/trezorhal/touch/touch.c
Normal file
20
core/embed/trezorhal/touch/touch.c
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
|
||||||
|
#include "touch.h"
|
||||||
|
|
||||||
|
uint32_t touch_click(void) {
|
||||||
|
uint32_t r = 0;
|
||||||
|
// flush touch events if any
|
||||||
|
while (touch_read()) {
|
||||||
|
}
|
||||||
|
// wait for TOUCH_START
|
||||||
|
while ((touch_read() & TOUCH_START) == 0) {
|
||||||
|
}
|
||||||
|
// wait for TOUCH_END
|
||||||
|
while (((r = touch_read()) & TOUCH_END) == 0) {
|
||||||
|
}
|
||||||
|
// flush touch events if any
|
||||||
|
while (touch_read()) {
|
||||||
|
}
|
||||||
|
// return last touch coordinate
|
||||||
|
return r;
|
||||||
|
}
|
28
core/embed/trezorhal/touch/touch.h
Normal file
28
core/embed/trezorhal/touch/touch.h
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
#ifndef _TOUCH_H
|
||||||
|
#define _TOUCH_H
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
|
#define TOUCH_START (1U << 24)
|
||||||
|
#define TOUCH_MOVE (1U << 25)
|
||||||
|
#define TOUCH_END (1U << 26)
|
||||||
|
|
||||||
|
void touch_init(void);
|
||||||
|
void touch_power_on(void);
|
||||||
|
void touch_power_off(void);
|
||||||
|
void touch_sensitivity(uint8_t value);
|
||||||
|
uint32_t touch_read(void);
|
||||||
|
uint32_t touch_click(void);
|
||||||
|
uint32_t touch_is_detected(void);
|
||||||
|
|
||||||
|
static inline uint16_t touch_unpack_x(uint32_t evt) {
|
||||||
|
return (evt >> 12) & 0xFFF;
|
||||||
|
}
|
||||||
|
static inline uint16_t touch_unpack_y(uint32_t evt) {
|
||||||
|
return (evt >> 0) & 0xFFF;
|
||||||
|
}
|
||||||
|
static inline uint32_t touch_pack_xy(uint16_t x, uint16_t y) {
|
||||||
|
return ((x & 0xFFF) << 12) | (y & 0xFFF);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif //_TOUCH_H
|
@ -1 +0,0 @@
|
|||||||
../trezorhal/touch.h
|
|
1
core/embed/unix/touch/touch.h
Symbolic link
1
core/embed/unix/touch/touch.h
Symbolic link
@ -0,0 +1 @@
|
|||||||
|
../../trezorhal/touch/touch.h
|
@ -28,7 +28,6 @@
|
|||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
#include "profile.h"
|
#include "profile.h"
|
||||||
#include "touch.h"
|
|
||||||
#include "usb.h"
|
#include "usb.h"
|
||||||
|
|
||||||
#include "memzero.h"
|
#include "memzero.h"
|
||||||
|
3
core/site_scons/boards/__init__.py
Normal file
3
core/site_scons/boards/__init__.py
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
def get_hw_model_as_number(hw_model):
|
||||||
|
return int.from_bytes(hw_model.encode(), 'little')
|
||||||
|
|
22
core/site_scons/boards/trezor_1.py
Normal file
22
core/site_scons/boards/trezor_1.py
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
from . import get_hw_model_as_number
|
||||||
|
|
||||||
|
|
||||||
|
def configure(env, features_wanted, defines, sources):
|
||||||
|
features_available = []
|
||||||
|
board = 'trezor_1.h'
|
||||||
|
display = 'vg-2864ksweg01.c'
|
||||||
|
hw_model = get_hw_model_as_number('T1B1')
|
||||||
|
hw_revision = 0
|
||||||
|
|
||||||
|
defines += [f'TREZOR_BOARD=\\"boards/{board}\\"', ]
|
||||||
|
defines += [f'HW_MODEL={hw_model}', ]
|
||||||
|
defines += [f'HW_REVISION={hw_revision}', ]
|
||||||
|
sources += [f'embed/trezorhal/displays/{display}', ]
|
||||||
|
|
||||||
|
if "input" in features_wanted:
|
||||||
|
sources += ['embed/trezorhal/button.c']
|
||||||
|
features_available.append("button")
|
||||||
|
|
||||||
|
env.get('ENV')['TREZOR_BOARD'] = board
|
||||||
|
|
||||||
|
return features_available
|
30
core/site_scons/boards/trezor_r_v3.py
Normal file
30
core/site_scons/boards/trezor_r_v3.py
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
from . import get_hw_model_as_number
|
||||||
|
|
||||||
|
|
||||||
|
def configure(env, features_wanted, defines, sources):
|
||||||
|
features_available = []
|
||||||
|
hw_model = get_hw_model_as_number('T2B1')
|
||||||
|
hw_revision = 3
|
||||||
|
board = 'trezor_r_v3.h'
|
||||||
|
display = "ug-2828tswig01.c"
|
||||||
|
|
||||||
|
defines += [f'TREZOR_BOARD=\\"boards/{board}\\"', ]
|
||||||
|
defines += [f'HW_MODEL={hw_model}', ]
|
||||||
|
defines += [f'HW_REVISION={hw_revision}', ]
|
||||||
|
sources += [f'embed/trezorhal/displays/{display}', ]
|
||||||
|
|
||||||
|
if "input" in features_wanted:
|
||||||
|
sources += ['embed/trezorhal/button.c']
|
||||||
|
features_available.append("button")
|
||||||
|
|
||||||
|
if "rgb_led" in features_wanted:
|
||||||
|
sources += ['embed/trezorhal/rgb_led.c']
|
||||||
|
features_available.append("rgb_led")
|
||||||
|
|
||||||
|
if "sbu" in features_wanted:
|
||||||
|
sources += ['embed/trezorhal/sbu.c', ]
|
||||||
|
features_available.append("sbu")
|
||||||
|
|
||||||
|
env.get('ENV')['TREZOR_BOARD'] = board
|
||||||
|
|
||||||
|
return features_available
|
26
core/site_scons/boards/trezor_r_v4.py
Normal file
26
core/site_scons/boards/trezor_r_v4.py
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
from . import get_hw_model_as_number
|
||||||
|
|
||||||
|
|
||||||
|
def configure(env, features_wanted, defines, sources):
|
||||||
|
features_available = []
|
||||||
|
hw_model = get_hw_model_as_number('T2B1')
|
||||||
|
hw_revision = 4
|
||||||
|
board = 'trezor_r_v4.h'
|
||||||
|
display = 'vg-2864ksweg01.c'
|
||||||
|
|
||||||
|
defines += [f'TREZOR_BOARD=\\"boards/{board}\\"', ]
|
||||||
|
defines += [f'HW_MODEL={hw_model}', ]
|
||||||
|
defines += [f'HW_REVISION={hw_revision}', ]
|
||||||
|
sources += [f'embed/trezorhal/displays/{display}', ]
|
||||||
|
|
||||||
|
if "input" in features_wanted:
|
||||||
|
sources += ['embed/trezorhal/button.c']
|
||||||
|
features_available.append("button")
|
||||||
|
|
||||||
|
if "sbu" in features_wanted:
|
||||||
|
sources += ['embed/trezorhal/sbu.c', ]
|
||||||
|
features_available.append("sbu")
|
||||||
|
|
||||||
|
env.get('ENV')['TREZOR_BOARD'] = board
|
||||||
|
|
||||||
|
return features_available
|
31
core/site_scons/boards/trezor_t.py
Normal file
31
core/site_scons/boards/trezor_t.py
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
from . import get_hw_model_as_number
|
||||||
|
|
||||||
|
|
||||||
|
def configure(env, features_wanted, defines, sources):
|
||||||
|
features_available = []
|
||||||
|
board = 'trezor_t.h'
|
||||||
|
display = 'st7789v.c'
|
||||||
|
hw_model = get_hw_model_as_number('T2T1')
|
||||||
|
hw_revision = 0
|
||||||
|
|
||||||
|
defines += [f'TREZOR_BOARD=\\"boards/{board}\\"', ]
|
||||||
|
defines += [f'HW_MODEL={hw_model}', ]
|
||||||
|
defines += [f'HW_REVISION={hw_revision}', ]
|
||||||
|
sources += [f'embed/trezorhal/displays/{display}', ]
|
||||||
|
|
||||||
|
if "input" in features_wanted:
|
||||||
|
sources += ['embed/trezorhal/touch/touch.c', ]
|
||||||
|
sources += ['embed/trezorhal/touch/ft6x36.c', ]
|
||||||
|
features_available.append("touch")
|
||||||
|
|
||||||
|
if "sdcard" in features_wanted:
|
||||||
|
sources += ['embed/trezorhal/sdcard.c', ]
|
||||||
|
features_available.append("sdcard")
|
||||||
|
|
||||||
|
if "sbu" in features_wanted:
|
||||||
|
sources += ['embed/trezorhal/sbu.c', ]
|
||||||
|
features_available.append("sbu")
|
||||||
|
|
||||||
|
env.get('ENV')['TREZOR_BOARD'] = board
|
||||||
|
|
||||||
|
return features_available
|
@ -1,6 +1,8 @@
|
|||||||
import os.path
|
import os.path
|
||||||
|
|
||||||
import subprocess
|
import subprocess
|
||||||
|
from boards import trezor_1, trezor_r_v3, trezor_r_v4, trezor_t
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def add_font(font_name, font, defines, sources):
|
def add_font(font_name, font, defines, sources):
|
||||||
@ -14,41 +16,21 @@ def add_font(font_name, font, defines, sources):
|
|||||||
sources.append(sourcefile)
|
sources.append(sourcefile)
|
||||||
|
|
||||||
|
|
||||||
def get_hw_model_as_number(hw_model):
|
def configure_board(model, features_wanted, env, defines, sources):
|
||||||
return int.from_bytes(hw_model.encode(), 'little')
|
|
||||||
|
|
||||||
|
|
||||||
def configure_board(model, env, defines, sources):
|
|
||||||
model_r_version = 4
|
model_r_version = 4
|
||||||
|
|
||||||
if model in ('1',):
|
if model in ('1',):
|
||||||
board = 'trezor_1.h'
|
return trezor_1.configure(env, features_wanted, defines, sources)
|
||||||
display = 'vg-2864ksweg01.c'
|
|
||||||
hw_model = get_hw_model_as_number('T1B1')
|
|
||||||
hw_revision = 0
|
|
||||||
elif model in ('T',):
|
elif model in ('T',):
|
||||||
board = 'trezor_t.h'
|
return trezor_t.configure(env, features_wanted, defines, sources)
|
||||||
display = 'st7789v.c'
|
|
||||||
hw_model = get_hw_model_as_number('T2T1')
|
|
||||||
hw_revision = 0
|
|
||||||
elif model in ('R',):
|
elif model in ('R',):
|
||||||
hw_model = get_hw_model_as_number('T2B1')
|
|
||||||
hw_revision = model_r_version
|
|
||||||
if model_r_version == 3:
|
if model_r_version == 3:
|
||||||
board = 'trezor_r_v3.h'
|
return trezor_r_v3.configure(env, features_wanted, defines, sources)
|
||||||
display = "ug-2828tswig01.c"
|
|
||||||
else:
|
else:
|
||||||
board = 'trezor_r_v4.h'
|
return trezor_r_v4.configure(env, features_wanted, defines, sources)
|
||||||
display = 'vg-2864ksweg01.c'
|
|
||||||
else:
|
else:
|
||||||
raise Exception("Unknown model")
|
raise Exception("Unknown model")
|
||||||
|
|
||||||
defines += [f'TREZOR_BOARD=\\"boards/{board}\\"', ]
|
|
||||||
defines += [f'HW_MODEL={hw_model}', ]
|
|
||||||
defines += [f'HW_REVISION={hw_revision}', ]
|
|
||||||
sources += [f'embed/trezorhal/displays/{display}', ]
|
|
||||||
env.get('ENV')['TREZOR_BOARD'] = board
|
|
||||||
|
|
||||||
|
|
||||||
def get_model_identifier(model):
|
def get_model_identifier(model):
|
||||||
if model == '1':
|
if model == '1':
|
||||||
|
Loading…
Reference in New Issue
Block a user