parent
28db0504c3
commit
8e4d90891c
Binary file not shown.
@ -0,0 +1 @@
|
||||
memory_T3T1.ld
|
@ -0,0 +1,26 @@
|
||||
#ifndef BOARDS_T3B1_UNIX_H
|
||||
#define BOARDS_T3B1_UNIX_H
|
||||
|
||||
#define USE_BUTTON 1
|
||||
#define USE_SBU 1
|
||||
#define USE_OPTIGA 1
|
||||
|
||||
#define MAX_DISPLAY_RESX 128
|
||||
#define MAX_DISPLAY_RESY 64
|
||||
#define DISPLAY_RESX 128
|
||||
#define DISPLAY_RESY 64
|
||||
#define TREZOR_FONT_BPP 1
|
||||
|
||||
#define WINDOW_WIDTH 193
|
||||
#define WINDOW_HEIGHT 339
|
||||
#define TOUCH_OFFSET_X 32
|
||||
#define TOUCH_OFFSET_Y 84
|
||||
|
||||
#define ORIENTATION_NS 1
|
||||
|
||||
#define BACKGROUND_FILE "T2B1/background_T2B1.h"
|
||||
#define BACKGROUND_NAME background_T2B1_png
|
||||
|
||||
#include "display-unix.h"
|
||||
|
||||
#endif // BOARDS_T2B1_UNIX_H
|
@ -0,0 +1,63 @@
|
||||
#ifndef _TREZOR_T3B1_H
|
||||
#define _TREZOR_T3B1_H
|
||||
|
||||
#define DISPLAY_RESX 128
|
||||
#define DISPLAY_RESY 64
|
||||
|
||||
#define VDD_1V8 1
|
||||
|
||||
#define USE_I2C 1
|
||||
#define USE_BUTTON 1
|
||||
#define USE_SBU 1
|
||||
#define USE_HASH_PROCESSOR 1
|
||||
#define USE_CONSUMPTION_MASK 1
|
||||
|
||||
#include "displays/vg-2864ksweg01.h"
|
||||
|
||||
#define BTN_LEFT_PIN GPIO_PIN_11
|
||||
#define BTN_LEFT_PORT GPIOC
|
||||
#define BTN_LEFT_CLK_ENA __HAL_RCC_GPIOC_CLK_ENABLE
|
||||
#define BTN_RIGHT_PIN GPIO_PIN_10
|
||||
#define BTN_RIGHT_PORT GPIOD
|
||||
#define BTN_RIGHT_CLK_ENA __HAL_RCC_GPIOD_CLK_ENABLE
|
||||
|
||||
#define OLED_DC_PORT GPIOC
|
||||
#define OLED_DC_PIN GPIO_PIN_8 // Data/Command
|
||||
#define OLED_DC_CLK_ENA __HAL_RCC_GPIOC_CLK_ENABLE
|
||||
#define OLED_CS_PORT GPIOG
|
||||
#define OLED_CS_PIN GPIO_PIN_5 // SPI Select
|
||||
#define OLED_CS_CLK_ENA __HAL_RCC_GPIOG_CLK_ENABLE
|
||||
#define OLED_RST_PORT GPIOG
|
||||
#define OLED_RST_PIN GPIO_PIN_8 // Reset display
|
||||
#define OLED_RST_CLK_ENA __HAL_RCC_GPIOG_CLK_ENABLE
|
||||
|
||||
#define OLED_SPI SPI1
|
||||
#define OLED_SPI_AF GPIO_AF5_SPI1
|
||||
#define OLED_SPI_CLK_ENA __HAL_RCC_SPI1_CLK_ENABLE
|
||||
#define OLED_SPI_SCK_PORT GPIOG
|
||||
#define OLED_SPI_SCK_PIN GPIO_PIN_2 // SPI SCK
|
||||
#define OLED_SPI_SCK_CLK_ENA __HAL_RCC_GPIOG_CLK_ENABLE
|
||||
#define OLED_SPI_MOSI_PORT GPIOG
|
||||
#define OLED_SPI_MOSI_PIN GPIO_PIN_4 // SPI MOSI
|
||||
#define OLED_SPI_MOSI_CLK_ENA __HAL_RCC_GPIOG_CLK_ENABLE
|
||||
|
||||
#define I2C_COUNT 1
|
||||
#define I2C_INSTANCE_0 I2C1
|
||||
#define I2C_INSTANCE_0_CLK_EN __HAL_RCC_I2C1_CLK_ENABLE
|
||||
#define I2C_INSTANCE_0_CLK_DIS __HAL_RCC_I2C1_CLK_DISABLE
|
||||
#define I2C_INSTANCE_0_PIN_AF GPIO_AF4_I2C1
|
||||
#define I2C_INSTANCE_0_SDA_PORT GPIOG
|
||||
#define I2C_INSTANCE_0_SDA_PIN GPIO_PIN_13
|
||||
#define I2C_INSTANCE_0_SDA_CLK_EN __HAL_RCC_GPIOG_CLK_ENABLE
|
||||
#define I2C_INSTANCE_0_SCL_PORT GPIOG
|
||||
#define I2C_INSTANCE_0_SCL_PIN GPIO_PIN_14
|
||||
#define I2C_INSTANCE_0_SCL_CLK_EN __HAL_RCC_GPIOG_CLK_ENABLE
|
||||
#define I2C_INSTANCE_0_RESET_REG &RCC->APB1RSTR1
|
||||
#define I2C_INSTANCE_0_RESET_BIT RCC_APB1RSTR1_I2C1RST
|
||||
|
||||
#define OPTIGA_I2C_INSTANCE 0
|
||||
#define OPTIGA_RST_PORT GPIOC
|
||||
#define OPTIGA_RST_PIN GPIO_PIN_13
|
||||
#define OPTIGA_RST_CLK_EN __HAL_RCC_GPIOB_CLK_ENABLE
|
||||
|
||||
#endif //_TREZOR_T3B1_H
|
@ -0,0 +1,48 @@
|
||||
#ifndef MODELS_MODEL_T3B1_H_
|
||||
#define MODELS_MODEL_T3B1_H_
|
||||
|
||||
#include "sizedefs.h"
|
||||
|
||||
#define MODEL_NAME "Safe 3"
|
||||
#define MODEL_FULL_NAME "Trezor Safe 3"
|
||||
#define MODEL_INTERNAL_NAME "T3B1"
|
||||
#define MODEL_INTERNAL_NAME_TOKEN T3B1
|
||||
#define MODEL_INTERNAL_NAME_QSTR MP_QSTR_T3B1
|
||||
|
||||
#define MODEL_BOARDLOADER_KEYS \
|
||||
(const uint8_t *)"\x76\xaf\x42\x6e\x61\x40\x6b\xad\x7c\x07\x7b\x40\x9c\x66\xfd\xe3\x9f\xb8\x17\x91\x93\x13\xae\x1e\x4c\x02\x53\x5c\x80\xbe\xed\x96", \
|
||||
(const uint8_t *)"\x61\x97\x51\xdc\x8d\x2d\x09\xd7\xe5\xdf\xb9\x9e\x41\xf6\x06\xde\xbd\xf4\x19\xf8\x5a\x81\x43\xe8\xe5\x39\x9e\xa6\x7a\x39\x88\xc7", \
|
||||
(const uint8_t *)"\xab\xf9\x4b\x66\x15\xa7\xdd\xe2\xa8\x71\xf7\xd6\x2c\x38\xef\xc7\xd9\xd8\xf6\x01\x0d\x88\x46\xbe\xe6\x36\xe4\xf3\xe6\x58\xa3\x8c",
|
||||
|
||||
#define MODEL_BOOTLOADER_KEYS \
|
||||
(const uint8_t *)"\x33\x8b\x94\x9b\x7e\x3b\x26\x47\x0d\x4f\xe3\x69\x6f\xd6\xff\xf2\x87\x57\x26\x5d\x14\xcc\xa4\x8e\xbf\x2d\xb9\x7b\x4f\x5b\xc0\x39", \
|
||||
(const uint8_t *)"\x28\x68\x20\x27\x73\x0b\x78\x32\x01\xb0\x5a\x8c\x9d\x11\x68\x54\x47\xc1\x72\x97\xdb\x71\xb8\xa6\x0d\xc6\x93\xa4\x46\x10\x75\x1d", \
|
||||
(const uint8_t *)"\x9f\xbf\x31\xb4\xe3\x51\xa4\xcc\x81\xc7\x59\x95\xb2\x25\x7f\x0a\x71\x69\x26\x8d\xa5\xa4\x4e\x94\xb6\xa5\x59\x0d\x43\x4e\x32\xda",
|
||||
|
||||
#define IMAGE_CHUNK_SIZE (128 * 1024)
|
||||
#define IMAGE_HASH_SHA256
|
||||
#define BOARD_CAPABILITIES_ADDR 0x0C00FF00
|
||||
|
||||
// SHARED WITH MAKEFILE
|
||||
#define FLASH_START 0x0C000000
|
||||
#define BOARDLOADER_START 0x0C004000
|
||||
#define BOOTLOADER_START 0x0C010000
|
||||
#define FIRMWARE_START 0x0C050000
|
||||
#define STORAGE_1_OFFSET 0x30000
|
||||
#define STORAGE_2_OFFSET 0x50000
|
||||
#define NORCOW_SECTOR_SIZE (8 * 8 * 1024) // 64 kB
|
||||
#define BOARDLOADER_IMAGE_MAXSIZE (6 * 8 * 1024) // 48 kB
|
||||
#define BOOTLOADER_IMAGE_MAXSIZE (16 * 8 * 1024) // 128 kB
|
||||
#define FIRMWARE_IMAGE_MAXSIZE (208 * 8 * 1024) // 1664 kB
|
||||
#define BOARDLOADER_SECTOR_START 0x2
|
||||
#define BOARDLOADER_SECTOR_END 0x7
|
||||
#define BOOTLOADER_SECTOR_START 0x8
|
||||
#define BOOTLOADER_SECTOR_END 0x17
|
||||
#define FIRMWARE_SECTOR_START 0x28
|
||||
#define FIRMWARE_SECTOR_END 0xF7
|
||||
#define STORAGE_1_SECTOR_START 0x18
|
||||
#define STORAGE_1_SECTOR_END 0x1F
|
||||
#define STORAGE_2_SECTOR_START 0x20
|
||||
#define STORAGE_2_SECTOR_END 0x27
|
||||
|
||||
#endif
|
@ -0,0 +1,96 @@
|
||||
#include "flash.h"
|
||||
#include "model.h"
|
||||
|
||||
const flash_area_t STORAGE_AREAS[STORAGE_AREAS_COUNT] = {
|
||||
{
|
||||
.num_subareas = 1,
|
||||
.subarea[0] =
|
||||
{
|
||||
.first_sector = STORAGE_1_SECTOR_START,
|
||||
.num_sectors =
|
||||
STORAGE_1_SECTOR_END - STORAGE_1_SECTOR_START + 1,
|
||||
},
|
||||
},
|
||||
{
|
||||
.num_subareas = 1,
|
||||
.subarea[0] =
|
||||
{
|
||||
.first_sector = STORAGE_2_SECTOR_START,
|
||||
.num_sectors =
|
||||
STORAGE_2_SECTOR_END - STORAGE_2_SECTOR_START + 1,
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
const flash_area_t BOARDLOADER_AREA = {
|
||||
.num_subareas = 1,
|
||||
.subarea[0] =
|
||||
{
|
||||
.first_sector = BOARDLOADER_SECTOR_START,
|
||||
.num_sectors =
|
||||
BOARDLOADER_SECTOR_END - BOARDLOADER_SECTOR_START + 1,
|
||||
},
|
||||
};
|
||||
|
||||
const flash_area_t BOOTLOADER_AREA = {
|
||||
.num_subareas = 1,
|
||||
.subarea[0] =
|
||||
{
|
||||
.first_sector = BOOTLOADER_SECTOR_START,
|
||||
.num_sectors = BOOTLOADER_SECTOR_END - BOOTLOADER_SECTOR_START + 1,
|
||||
},
|
||||
};
|
||||
|
||||
const flash_area_t FIRMWARE_AREA = {
|
||||
.num_subareas = 1,
|
||||
.subarea[0] =
|
||||
{
|
||||
.first_sector = FIRMWARE_SECTOR_START,
|
||||
.num_sectors = FIRMWARE_SECTOR_END - FIRMWARE_SECTOR_START + 1,
|
||||
},
|
||||
};
|
||||
|
||||
const flash_area_t SECRET_AREA = {
|
||||
.num_subareas = 1,
|
||||
.subarea[0] =
|
||||
{
|
||||
.first_sector = 0,
|
||||
.num_sectors = 2,
|
||||
},
|
||||
};
|
||||
|
||||
const flash_area_t BHK_AREA = {
|
||||
.num_subareas = 1,
|
||||
.subarea[0] =
|
||||
{
|
||||
.first_sector = 1,
|
||||
.num_sectors = 1,
|
||||
},
|
||||
};
|
||||
|
||||
const flash_area_t TRANSLATIONS_AREA = {
|
||||
.num_subareas = 1,
|
||||
.subarea[0] =
|
||||
{
|
||||
.first_sector = 248,
|
||||
.num_sectors = 8,
|
||||
},
|
||||
};
|
||||
|
||||
const flash_area_t WIPE_AREA = {
|
||||
.num_subareas = 1,
|
||||
.subarea[0] =
|
||||
{
|
||||
.first_sector = STORAGE_1_SECTOR_START,
|
||||
.num_sectors = 232,
|
||||
},
|
||||
};
|
||||
|
||||
const flash_area_t ALL_WIPE_AREA = {
|
||||
.num_subareas = 1,
|
||||
.subarea[0] =
|
||||
{
|
||||
.first_sector = BOOTLOADER_SECTOR_START,
|
||||
.num_sectors = 248,
|
||||
},
|
||||
};
|
@ -0,0 +1 @@
|
||||
../stm32f4/button.c
|
@ -0,0 +1,148 @@
|
||||
/*
|
||||
* This file is part of the Trezor project, https://trezor.io/
|
||||
*
|
||||
* Copyright (c) SatoshiLabs
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include STM32_HAL_H
|
||||
#include "rng.h"
|
||||
|
||||
#define SAMPLES 110
|
||||
#define TIMER_PERIOD 16640 // cca 10 KHz @ 180MHz
|
||||
|
||||
#if defined BOARDLOADER
|
||||
#error Not implemented for boardloader!
|
||||
#endif
|
||||
|
||||
#if defined BOOTLOADER
|
||||
__attribute__((section(".buf")))
|
||||
#endif
|
||||
uint32_t pwm_data[SAMPLES] = {0};
|
||||
|
||||
static DMA_NodeTypeDef Node1;
|
||||
static DMA_QListTypeDef Queue;
|
||||
|
||||
void consumption_mask_randomize() {
|
||||
for (int i = 0; i < SAMPLES; i++) {
|
||||
pwm_data[i] = rng_get() % TIMER_PERIOD;
|
||||
}
|
||||
}
|
||||
|
||||
void consumption_mask_init(void) {
|
||||
consumption_mask_randomize();
|
||||
|
||||
__HAL_RCC_GPIOA_CLK_ENABLE();
|
||||
GPIO_InitTypeDef GPIO_InitStructure = {0};
|
||||
GPIO_InitStructure.Mode = GPIO_MODE_AF_PP;
|
||||
GPIO_InitStructure.Pull = GPIO_PULLUP;
|
||||
GPIO_InitStructure.Speed = GPIO_SPEED_FREQ_HIGH;
|
||||
GPIO_InitStructure.Alternate = GPIO_AF3_TIM8;
|
||||
GPIO_InitStructure.Pin = GPIO_PIN_5;
|
||||
HAL_GPIO_Init(GPIOA, &GPIO_InitStructure);
|
||||
|
||||
__HAL_RCC_TIM8_CLK_ENABLE();
|
||||
TIM_HandleTypeDef TIM8_Handle = {0};
|
||||
TIM8_Handle.State = HAL_TIM_STATE_RESET;
|
||||
TIM8_Handle.Instance = TIM8;
|
||||
TIM8_Handle.Init.Period = TIMER_PERIOD;
|
||||
TIM8_Handle.Init.Prescaler = 0;
|
||||
TIM8_Handle.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1;
|
||||
TIM8_Handle.Init.CounterMode = TIM_COUNTERMODE_UP;
|
||||
TIM8_Handle.Init.RepetitionCounter = 0;
|
||||
HAL_TIM_PWM_Init(&TIM8_Handle);
|
||||
|
||||
TIM_OC_InitTypeDef TIM_OC_InitStructure = {0};
|
||||
TIM_OC_InitStructure.Pulse = 0;
|
||||
TIM_OC_InitStructure.OCMode = TIM_OCMODE_PWM1;
|
||||
TIM_OC_InitStructure.OCPolarity = TIM_OCPOLARITY_LOW;
|
||||
TIM_OC_InitStructure.OCFastMode = TIM_OCFAST_DISABLE;
|
||||
TIM_OC_InitStructure.OCNPolarity = TIM_OCNPOLARITY_HIGH;
|
||||
TIM_OC_InitStructure.OCIdleState = TIM_OCIDLESTATE_SET;
|
||||
TIM_OC_InitStructure.OCNIdleState = TIM_OCNIDLESTATE_SET;
|
||||
HAL_TIM_PWM_ConfigChannel(&TIM8_Handle, &TIM_OC_InitStructure, TIM_CHANNEL_1);
|
||||
|
||||
__HAL_RCC_GPDMA1_CLK_ENABLE();
|
||||
DMA_HandleTypeDef dma_handle = {0};
|
||||
|
||||
/* USER CODE END GPDMA1_Init 1 */
|
||||
dma_handle.Instance = GPDMA1_Channel1;
|
||||
dma_handle.InitLinkedList.Priority = DMA_HIGH_PRIORITY;
|
||||
dma_handle.InitLinkedList.LinkStepMode = DMA_LSM_FULL_EXECUTION;
|
||||
dma_handle.InitLinkedList.LinkAllocatedPort = DMA_LINK_ALLOCATED_PORT1;
|
||||
dma_handle.InitLinkedList.TransferEventMode = DMA_TCEM_LAST_LL_ITEM_TRANSFER;
|
||||
dma_handle.InitLinkedList.LinkedListMode = DMA_LINKEDLIST_CIRCULAR;
|
||||
HAL_DMAEx_List_Init(&dma_handle);
|
||||
|
||||
HAL_DMA_ConfigChannelAttributes(&dma_handle, DMA_CHANNEL_SEC |
|
||||
DMA_CHANNEL_SRC_SEC |
|
||||
DMA_CHANNEL_DEST_SEC);
|
||||
|
||||
/* DMA node configuration declaration */
|
||||
DMA_NodeConfTypeDef pNodeConfig = {0};
|
||||
|
||||
/* Set node configuration ################################################*/
|
||||
pNodeConfig.NodeType = DMA_GPDMA_LINEAR_NODE;
|
||||
pNodeConfig.Init.Request = GPDMA1_REQUEST_TIM8_UP;
|
||||
pNodeConfig.Init.BlkHWRequest = DMA_BREQ_SINGLE_BURST;
|
||||
pNodeConfig.Init.Direction = DMA_MEMORY_TO_PERIPH;
|
||||
pNodeConfig.Init.SrcInc = DMA_SINC_INCREMENTED;
|
||||
pNodeConfig.Init.DestInc = DMA_DINC_FIXED;
|
||||
pNodeConfig.Init.SrcDataWidth = DMA_SRC_DATAWIDTH_WORD;
|
||||
pNodeConfig.Init.DestDataWidth = DMA_DEST_DATAWIDTH_WORD;
|
||||
pNodeConfig.Init.SrcBurstLength = 1;
|
||||
pNodeConfig.Init.DestBurstLength = 1;
|
||||
pNodeConfig.Init.TransferAllocatedPort =
|
||||
DMA_SRC_ALLOCATED_PORT0 | DMA_DEST_ALLOCATED_PORT0;
|
||||
pNodeConfig.Init.TransferEventMode = DMA_TCEM_BLOCK_TRANSFER;
|
||||
pNodeConfig.RepeatBlockConfig.RepeatCount = 1;
|
||||
pNodeConfig.RepeatBlockConfig.SrcAddrOffset = 0;
|
||||
pNodeConfig.RepeatBlockConfig.DestAddrOffset = 0;
|
||||
pNodeConfig.RepeatBlockConfig.BlkSrcAddrOffset = 0;
|
||||
pNodeConfig.RepeatBlockConfig.BlkDestAddrOffset = 0;
|
||||
pNodeConfig.TriggerConfig.TriggerPolarity = DMA_TRIG_POLARITY_MASKED;
|
||||
pNodeConfig.DataHandlingConfig.DataExchange = DMA_EXCHANGE_NONE;
|
||||
pNodeConfig.DataHandlingConfig.DataAlignment = DMA_DATA_RIGHTALIGN_ZEROPADDED;
|
||||
pNodeConfig.SrcAddress = (uint32_t)pwm_data;
|
||||
pNodeConfig.DstAddress = (uint32_t)&TIM8->CCR1;
|
||||
pNodeConfig.DataSize = SAMPLES * sizeof(uint32_t);
|
||||
pNodeConfig.DestSecure = DMA_CHANNEL_DEST_SEC;
|
||||
pNodeConfig.SrcSecure = DMA_CHANNEL_SRC_SEC;
|
||||
|
||||
/* Build Node1 Node */
|
||||
HAL_DMAEx_List_BuildNode(&pNodeConfig, &Node1);
|
||||
|
||||
/* Insert Node1 to Queue */
|
||||
HAL_DMAEx_List_InsertNode_Tail(&Queue, &Node1);
|
||||
|
||||
HAL_DMAEx_List_SetCircularModeConfig(&Queue, &Node1);
|
||||
HAL_DMAEx_List_SetCircularMode(&Queue);
|
||||
|
||||
/* Link created queue to DMA channel #######################################*/
|
||||
HAL_DMAEx_List_LinkQ(&dma_handle, &Queue);
|
||||
|
||||
TIM4->CR2 |= TIM_CR2_MMS_1; // update event as TRGO
|
||||
TIM8->CR2 |= TIM_CR2_CCPC; // preloading CCR register
|
||||
TIM8->CR2 |= TIM_CR2_CCUS; // preload when TRGI
|
||||
TIM8->DIER |= TIM_DMA_UPDATE; // allow DMA request from update event
|
||||
TIM8->CCR1 = 0;
|
||||
|
||||
HAL_Delay(1);
|
||||
|
||||
HAL_TIM_Base_Start(&TIM8_Handle);
|
||||
HAL_TIM_PWM_Start(&TIM8_Handle, TIM_CHANNEL_1);
|
||||
|
||||
HAL_DMAEx_List_Start(&dma_handle);
|
||||
}
|
@ -0,0 +1 @@
|
||||
../../stm32f4/displays/vg-2864ksweg01.c
|
@ -0,0 +1 @@
|
||||
../../stm32f4/displays/vg-2864ksweg01.h
|
@ -0,0 +1,20 @@
|
||||
{
|
||||
"header_len": 512,
|
||||
"text": "DEV ONLY, DO NOT USE!",
|
||||
"hw_model": "T3B1",
|
||||
"expiry": 0,
|
||||
"version": [0, 0],
|
||||
"sig_m": 2,
|
||||
"trust": {
|
||||
"allow_run_with_secret": true,
|
||||
"show_vendor_string": false,
|
||||
"require_user_click": false,
|
||||
"red_background": false,
|
||||
"delay": 0
|
||||
},
|
||||
"pubkeys": [
|
||||
"e28a8970753332bd72fef413e6b0b2ef1b4aadda7aa2c141f233712a6876b351",
|
||||
"d4eec1869fb1b8a4e817516ad5a931557cb56805c3eb16e8f3a803d647df7869",
|
||||
"772c8a442b7db06e166cfbc1ccbcbcde6f3eba76a4e98ef3ffc519502237d6ef"
|
||||
]
|
||||
}
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -0,0 +1,23 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Optional
|
||||
|
||||
from .emulator import configure as emul
|
||||
from .trezor_t3b1_revB import configure as configure_revB
|
||||
|
||||
|
||||
def configure_board(
|
||||
revision: Optional[int | str],
|
||||
features_wanted: list[str],
|
||||
env: dict, # type: ignore
|
||||
defines: list[str | tuple[str, str]],
|
||||
sources: list[str],
|
||||
paths: list[str],
|
||||
):
|
||||
if revision is None:
|
||||
revision = "B"
|
||||
if revision == "emulator":
|
||||
return emul(env, features_wanted, defines, sources, paths)
|
||||
elif revision == "B":
|
||||
return configure_revB(env, features_wanted, defines, sources, paths)
|
||||
raise Exception("Unknown model_t3b1_version")
|
@ -0,0 +1,43 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from .. import get_hw_model_as_number
|
||||
|
||||
|
||||
def configure(
|
||||
env: dict,
|
||||
features_wanted: list[str],
|
||||
defines: list[str | tuple[str, str]],
|
||||
sources: list[str],
|
||||
paths: list[str],
|
||||
) -> list[str]:
|
||||
|
||||
board = "T3B1/boards/t3b1-unix.h"
|
||||
hw_model = get_hw_model_as_number("T3B1")
|
||||
hw_revision = 0
|
||||
mcu = "STM32U585xx"
|
||||
|
||||
features = []
|
||||
defines += [mcu]
|
||||
defines += [f'TREZOR_BOARD=\\"{board}\\"']
|
||||
defines += [f"HW_MODEL={hw_model}"]
|
||||
defines += [f"HW_REVISION={hw_revision}"]
|
||||
defines += [f"MCU_TYPE={mcu}"]
|
||||
# todo replace when U5 flash emulator is implemented
|
||||
defines += ["FLASH_BIT_ACCESS=1"]
|
||||
defines += ["FLASH_BLOCK_WORDS=1"]
|
||||
|
||||
if "sbu" in features_wanted:
|
||||
sources += ["embed/trezorhal/unix/sbu.c"]
|
||||
|
||||
if "optiga_hal" in features_wanted:
|
||||
sources += ["embed/trezorhal/unix/optiga_hal.c"]
|
||||
|
||||
if "optiga" in features_wanted:
|
||||
sources += ["embed/trezorhal/unix/optiga.c"]
|
||||
|
||||
if "input" in features_wanted:
|
||||
features.append("button")
|
||||
|
||||
sources += ["embed/models/T3B1/model_T3B1_layout.c"]
|
||||
|
||||
return features
|
@ -0,0 +1,82 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from .. import get_hw_model_as_number
|
||||
from ..stm32u5_common import stm32u5_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] = []
|
||||
board = "T3B1/boards/trezor_t3b1_revB.h"
|
||||
display = "vg-2864ksweg01.c"
|
||||
hw_model = get_hw_model_as_number("T3B1")
|
||||
hw_revision = "B"
|
||||
|
||||
mcu = "STM32U585xx"
|
||||
linker_script = "stm32u58"
|
||||
|
||||
stm32u5_common_files(env, defines, sources, paths)
|
||||
|
||||
env.get("ENV")[
|
||||
"CPU_ASFLAGS"
|
||||
] = "-mthumb -mcpu=cortex-m33 -mfloat-abi=hard -mfpu=fpv5-sp-d16 "
|
||||
env.get("ENV")[
|
||||
"CPU_CCFLAGS"
|
||||
] = "-mthumb -mcpu=cortex-m33 -mfloat-abi=hard -mfpu=fpv5-sp-d16 -mtune=cortex-m33 -mcmse "
|
||||
env.get("ENV")["RUST_TARGET"] = "thumbv8m.main-none-eabihf"
|
||||
|
||||
defines += [mcu]
|
||||
defines += [f'TREZOR_BOARD=\\"{board}\\"']
|
||||
defines += [f"HW_MODEL={hw_model}"]
|
||||
defines += [f"HW_REVISION={ord(hw_revision)}"]
|
||||
sources += [
|
||||
"embed/models/T3B1/model_T3B1_layout.c",
|
||||
]
|
||||
sources += [f"embed/trezorhal/stm32u5/displays/{display}"]
|
||||
|
||||
if "input" in features_wanted:
|
||||
sources += ["embed/trezorhal/stm32u5/button.c"]
|
||||
features_available.append("button")
|
||||
|
||||
if "sbu" in features_wanted:
|
||||
sources += ["embed/trezorhal/stm32u5/sbu.c"]
|
||||
features_available.append("sbu")
|
||||
|
||||
if "usb" in features_wanted:
|
||||
sources += [
|
||||
"embed/trezorhal/stm32u5/usb.c",
|
||||
"embed/trezorhal/stm32u5/usbd_conf.c",
|
||||
"embed/trezorhal/stm32u5/usbd_core.c",
|
||||
"embed/trezorhal/stm32u5/usbd_ctlreq.c",
|
||||
"embed/trezorhal/stm32u5/usbd_ioreq.c",
|
||||
"vendor/stm32u5xx_hal_driver/Src/stm32u5xx_ll_usb.c",
|
||||
]
|
||||
features_available.append("usb")
|
||||
|
||||
if "optiga" in features_wanted:
|
||||
defines += ["USE_OPTIGA=1"]
|
||||
sources += ["embed/trezorhal/stm32u5/i2c.c"]
|
||||
sources += ["embed/trezorhal/stm32u5/optiga_hal.c"]
|
||||
sources += ["embed/trezorhal/optiga/optiga.c"]
|
||||
sources += ["embed/trezorhal/optiga/optiga_commands.c"]
|
||||
sources += ["embed/trezorhal/optiga/optiga_transport.c"]
|
||||
sources += ["vendor/trezor-crypto/hash_to_curve.c"]
|
||||
features_available.append("optiga")
|
||||
|
||||
if "consumption_mask" in features_wanted:
|
||||
sources += ["embed/trezorhal/stm32u5/consumption_mask.c"]
|
||||
sources += ["vendor/stm32u5xx_hal_driver/Src/stm32u5xx_hal_tim.c"]
|
||||
|
||||
env.get("ENV")["TREZOR_BOARD"] = board
|
||||
env.get("ENV")["MCU_TYPE"] = mcu
|
||||
env.get("ENV")["LINKER_SCRIPT"] = linker_script
|
||||
|
||||
defs = env.get("CPPDEFINES_IMPLICIT")
|
||||
defs += ["__ARM_FEATURE_CMSE=3"]
|
||||
|
||||
return features_available
|
Loading…
Reference in new issue