Skip to content

Commit

Permalink
fix(core): reset optiga during initialization
Browse files Browse the repository at this point in the history
[no changelog]
  • Loading branch information
TychoVrahe committed Sep 27, 2023
1 parent 062558e commit 750dc50
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 0 deletions.
1 change: 1 addition & 0 deletions core/SConscript.bootloader_emu
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ if TREZOR_MODEL in ('R', ):
]
SOURCE_TREZORHAL += [
'embed/trezorhal/unix/secret.c',
'embed/trezorhal/unix/optiga_hal.c',
]

SOURCE_UNIX = [
Expand Down
7 changes: 7 additions & 0 deletions core/embed/bootloader/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@
#ifdef USE_I2C
#include "i2c.h"
#endif
#ifdef USE_OPTIGA
#include "optiga_hal.h"
#endif
#ifdef USE_TOUCH
#include "touch.h"
#endif
Expand Down Expand Up @@ -361,6 +364,10 @@ int bootloader_main(void) {
i2c_init();
#endif

#ifdef USE_OPTIGA
optiga_hal_init();
#endif

#ifdef USE_TOUCH
touch_power_on();
touch_init();
Expand Down
3 changes: 3 additions & 0 deletions core/embed/trezorhal/stm32f4/optiga_hal.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ void optiga_hal_init(void) {
GPIO_InitStructure.Alternate = 0;
GPIO_InitStructure.Pin = GPIO_PIN_9;
HAL_GPIO_Init(GPIOD, &GPIO_InitStructure);
// perform reset on every initialization
HAL_GPIO_WritePin(GPIOD, GPIO_PIN_9, GPIO_PIN_RESET);
hal_delay(10);
HAL_GPIO_WritePin(GPIOD, GPIO_PIN_9, GPIO_PIN_SET);
// warm reset startup time min 15ms
hal_delay(20);
Expand Down
26 changes: 26 additions & 0 deletions core/embed/trezorhal/unix/optiga_hal.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/*
* 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/>.
*/

void optiga_hal_init(void) {
// nothing to do
}

void optiga_reset(void) {
// nothing to do
}

0 comments on commit 750dc50

Please sign in to comment.