mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-11-18 13:38:12 +00:00
fix(core): slow down SDIO communication in T3T1 prodtest
[no changelog]
This commit is contained in:
parent
418bc924c4
commit
c8e18dd4d2
@ -403,14 +403,17 @@ static void test_sd(void) {
|
|||||||
static uint32_t buf1[BLOCK_SIZE / sizeof(uint32_t)];
|
static uint32_t buf1[BLOCK_SIZE / sizeof(uint32_t)];
|
||||||
static uint32_t buf2[BLOCK_SIZE / sizeof(uint32_t)];
|
static uint32_t buf2[BLOCK_SIZE / sizeof(uint32_t)];
|
||||||
|
|
||||||
|
bool low_speed = false;
|
||||||
#ifndef TREZOR_MODEL_T3T1
|
#ifndef TREZOR_MODEL_T3T1
|
||||||
if (sectrue != sdcard_is_present()) {
|
if (sectrue != sdcard_is_present()) {
|
||||||
vcp_println("ERROR NOCARD");
|
vcp_println("ERROR NOCARD");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
low_speed = true;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (sectrue != sdcard_power_on_unchecked()) {
|
if (sectrue != sdcard_power_on_unchecked(low_speed)) {
|
||||||
vcp_println("ERROR POWER ON");
|
vcp_println("ERROR POWER ON");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -46,13 +46,14 @@
|
|||||||
#ifndef __TREZORHAL_SDCARD_H__
|
#ifndef __TREZORHAL_SDCARD_H__
|
||||||
#define __TREZORHAL_SDCARD_H__
|
#define __TREZORHAL_SDCARD_H__
|
||||||
|
|
||||||
|
#include <stdbool.h>
|
||||||
#include "secbool.h"
|
#include "secbool.h"
|
||||||
|
|
||||||
// this is a fixed size and should not be changed
|
// this is a fixed size and should not be changed
|
||||||
#define SDCARD_BLOCK_SIZE (512)
|
#define SDCARD_BLOCK_SIZE (512)
|
||||||
|
|
||||||
void sdcard_init(void);
|
void sdcard_init(void);
|
||||||
secbool __wur sdcard_power_on_unchecked(void);
|
secbool __wur sdcard_power_on_unchecked(bool low_speed);
|
||||||
secbool __wur sdcard_power_on(void);
|
secbool __wur sdcard_power_on(void);
|
||||||
void sdcard_power_off(void);
|
void sdcard_power_off(void);
|
||||||
secbool __wur sdcard_is_present(void);
|
secbool __wur sdcard_is_present(void);
|
||||||
|
@ -148,7 +148,7 @@ void HAL_SD_MspDeInit(SD_HandleTypeDef *hsd) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
secbool sdcard_power_on_unchecked(void) {
|
secbool sdcard_power_on_unchecked(bool low_speed) {
|
||||||
if (sd_handle.Instance) {
|
if (sd_handle.Instance) {
|
||||||
return sectrue;
|
return sectrue;
|
||||||
}
|
}
|
||||||
@ -163,7 +163,7 @@ secbool sdcard_power_on_unchecked(void) {
|
|||||||
sd_handle.Init.ClockPowerSave = SDIO_CLOCK_POWER_SAVE_ENABLE;
|
sd_handle.Init.ClockPowerSave = SDIO_CLOCK_POWER_SAVE_ENABLE;
|
||||||
sd_handle.Init.BusWide = SDIO_BUS_WIDE_1B;
|
sd_handle.Init.BusWide = SDIO_BUS_WIDE_1B;
|
||||||
sd_handle.Init.HardwareFlowControl = SDIO_HARDWARE_FLOW_CONTROL_DISABLE;
|
sd_handle.Init.HardwareFlowControl = SDIO_HARDWARE_FLOW_CONTROL_DISABLE;
|
||||||
sd_handle.Init.ClockDiv = SDIO_TRANSFER_CLK_DIV;
|
sd_handle.Init.ClockDiv = low_speed ? 1 : SDIO_TRANSFER_CLK_DIV;
|
||||||
|
|
||||||
// init the SD interface, with retry if it's not ready yet
|
// init the SD interface, with retry if it's not ready yet
|
||||||
for (int retry = 10; HAL_SD_Init(&sd_handle) != HAL_OK; retry--) {
|
for (int retry = 10; HAL_SD_Init(&sd_handle) != HAL_OK; retry--) {
|
||||||
@ -202,7 +202,7 @@ secbool sdcard_power_on(void) {
|
|||||||
return secfalse;
|
return secfalse;
|
||||||
}
|
}
|
||||||
|
|
||||||
return sdcard_power_on_unchecked();
|
return sdcard_power_on_unchecked(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void sdcard_power_off(void) {
|
void sdcard_power_off(void) {
|
||||||
|
@ -152,7 +152,7 @@ void HAL_SD_MspDeInit(SD_HandleTypeDef *hsd) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
secbool sdcard_power_on_unchecked(void) {
|
secbool sdcard_power_on_unchecked(bool low_speed) {
|
||||||
if (sd_handle.Instance) {
|
if (sd_handle.Instance) {
|
||||||
return sectrue;
|
return sectrue;
|
||||||
}
|
}
|
||||||
@ -166,7 +166,7 @@ secbool sdcard_power_on_unchecked(void) {
|
|||||||
sd_handle.Init.ClockPowerSave = SDMMC_CLOCK_POWER_SAVE_ENABLE;
|
sd_handle.Init.ClockPowerSave = SDMMC_CLOCK_POWER_SAVE_ENABLE;
|
||||||
sd_handle.Init.BusWide = SDMMC_BUS_WIDE_1B;
|
sd_handle.Init.BusWide = SDMMC_BUS_WIDE_1B;
|
||||||
sd_handle.Init.HardwareFlowControl = SDMMC_HARDWARE_FLOW_CONTROL_DISABLE;
|
sd_handle.Init.HardwareFlowControl = SDMMC_HARDWARE_FLOW_CONTROL_DISABLE;
|
||||||
sd_handle.Init.ClockDiv = 0;
|
sd_handle.Init.ClockDiv = low_speed ? 1 : 0;
|
||||||
|
|
||||||
// init the SD interface, with retry if it's not ready yet
|
// init the SD interface, with retry if it's not ready yet
|
||||||
for (int retry = 10; HAL_SD_Init(&sd_handle) != HAL_OK; retry--) {
|
for (int retry = 10; HAL_SD_Init(&sd_handle) != HAL_OK; retry--) {
|
||||||
@ -205,7 +205,7 @@ secbool sdcard_power_on(void) {
|
|||||||
return secfalse;
|
return secfalse;
|
||||||
}
|
}
|
||||||
|
|
||||||
return sdcard_power_on_unchecked();
|
return sdcard_power_on_unchecked(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void sdcard_power_off(void) {
|
void sdcard_power_off(void) {
|
||||||
|
@ -87,13 +87,13 @@ void sdcard_init(void) {
|
|||||||
|
|
||||||
secbool sdcard_is_present(void) { return sectrue; }
|
secbool sdcard_is_present(void) { return sectrue; }
|
||||||
|
|
||||||
secbool sdcard_power_on_unchecked(void) {
|
secbool sdcard_power_on_unchecked(bool _low_speed) {
|
||||||
sdcard_init();
|
sdcard_init();
|
||||||
sdcard_powered = sectrue;
|
sdcard_powered = sectrue;
|
||||||
return sectrue;
|
return sectrue;
|
||||||
}
|
}
|
||||||
|
|
||||||
secbool sdcard_power_on(void) { return sdcard_power_on_unchecked(); }
|
secbool sdcard_power_on(void) { return sdcard_power_on_unchecked(false); }
|
||||||
|
|
||||||
void sdcard_power_off(void) { sdcard_powered = secfalse; }
|
void sdcard_power_off(void) { sdcard_powered = secfalse; }
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user