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

fix(core/prodtest): do not require sd detect pin for running SD card test

[no changelog]
This commit is contained in:
tychovrahe 2024-03-27 09:42:43 +01:00 committed by TychoVrahe
parent 4b189eb2cb
commit ba065c5b38
5 changed files with 28 additions and 10 deletions

View File

@ -402,12 +402,17 @@ static void test_sd(void) {
static uint32_t buf1[BLOCK_SIZE / sizeof(uint32_t)];
static uint32_t buf2[BLOCK_SIZE / sizeof(uint32_t)];
#ifndef TREZOR_MODEL_T3T1
if (sectrue != sdcard_is_present()) {
vcp_println("ERROR NOCARD");
return;
}
#endif
ensure(sdcard_power_on(), NULL);
if (sectrue != sdcard_power_on_unchecked()) {
vcp_println("ERROR POWER ON");
return;
}
if (sectrue != sdcard_read_blocks(buf1, 0, BLOCK_SIZE / SDCARD_BLOCK_SIZE)) {
vcp_println("ERROR sdcard_read_blocks (0)");
goto power_off;

View File

@ -52,6 +52,7 @@
#define SDCARD_BLOCK_SIZE (512)
void sdcard_init(void);
secbool __wur sdcard_power_on_unchecked(void);
secbool __wur sdcard_power_on(void);
void sdcard_power_off(void);
secbool __wur sdcard_is_present(void);

View File

@ -148,10 +148,7 @@ void HAL_SD_MspDeInit(SD_HandleTypeDef *hsd) {
}
}
secbool sdcard_power_on(void) {
if (sectrue != sdcard_is_present()) {
return secfalse;
}
secbool sdcard_power_on_unchecked(void) {
if (sd_handle.Instance) {
return sectrue;
}
@ -200,6 +197,14 @@ error:
return secfalse;
}
secbool sdcard_power_on(void) {
if (sectrue != sdcard_is_present()) {
return secfalse;
}
return sdcard_power_on_unchecked();
}
void sdcard_power_off(void) {
if (sd_handle.Instance) {
HAL_SD_DeInit(&sd_handle);

View File

@ -152,10 +152,7 @@ void HAL_SD_MspDeInit(SD_HandleTypeDef *hsd) {
}
}
secbool sdcard_power_on(void) {
if (sectrue != sdcard_is_present()) {
return secfalse;
}
secbool sdcard_power_on_unchecked(void) {
if (sd_handle.Instance) {
return sectrue;
}
@ -203,6 +200,14 @@ error:
return secfalse;
}
secbool sdcard_power_on(void) {
if (sectrue != sdcard_is_present()) {
return secfalse;
}
return sdcard_power_on_unchecked();
}
void sdcard_power_off(void) {
if (sd_handle.Instance) {
HAL_SD_DeInit(&sd_handle);

View File

@ -87,12 +87,14 @@ void sdcard_init(void) {
secbool sdcard_is_present(void) { return sectrue; }
secbool sdcard_power_on(void) {
secbool sdcard_power_on_unchecked(void) {
sdcard_init();
sdcard_powered = sectrue;
return sectrue;
}
secbool sdcard_power_on(void) { return sdcard_power_on_unchecked(); }
void sdcard_power_off(void) { sdcard_powered = secfalse; }
uint64_t sdcard_get_capacity_in_bytes(void) {