mirror of
https://github.com/CTCaer/hekate.git
synced 2024-12-23 08:32:04 +00:00
nyx: Add SD Card error report in Console Info
This commit is contained in:
parent
96654d9620
commit
67ae7b9dcb
4 changed files with 72 additions and 0 deletions
|
@ -819,6 +819,36 @@ static lv_res_t _create_window_sdcard_info_status(lv_obj_t *btn)
|
|||
lv_obj_set_width(lb_val3, lv_obj_get_width(val3));
|
||||
lv_obj_align(val3, desc3, LV_ALIGN_OUT_RIGHT_MID, 0, 0);
|
||||
|
||||
lv_obj_t *desc4 = lv_cont_create(win, NULL);
|
||||
lv_obj_set_size(desc4, LV_HOR_RES / 2 / 2 * 2, LV_VER_RES - (LV_DPI * 11 / 8) * 4);
|
||||
|
||||
lv_obj_t * lb_desc4 = lv_label_create(desc4, lb_desc);
|
||||
lv_label_set_text(lb_desc4, "#D4FF00 Acquiring FAT volume info...#");
|
||||
lv_obj_set_width(lb_desc4, lv_obj_get_width(desc4));
|
||||
|
||||
lv_label_set_text(lb_desc4,
|
||||
"#00DDFF SDMMC1 Error Counts:#\n"
|
||||
"Init fails:\n"
|
||||
"Read/Write fails:\n"
|
||||
"Read/Write errors:"
|
||||
);
|
||||
lv_obj_set_size(desc4, LV_HOR_RES / 2 / 5 * 2, LV_VER_RES - (LV_DPI * 11 / 8) * 4);
|
||||
lv_obj_set_width(lb_desc4, lv_obj_get_width(desc4));
|
||||
lv_obj_align(desc4, val3, LV_ALIGN_OUT_RIGHT_MID, LV_DPI / 2, 0);
|
||||
|
||||
lv_obj_t *val4 = lv_cont_create(win, NULL);
|
||||
lv_obj_set_size(val4, LV_HOR_RES / 13 * 3, LV_VER_RES - (LV_DPI * 11 / 8) * 4);
|
||||
|
||||
lv_obj_t * lb_val4 = lv_label_create(val4, lb_desc);
|
||||
|
||||
u16 *sd_errors = sd_get_error_count();
|
||||
s_printf(txt_buf, "\n%d\n%d\n%d", sd_errors[0], sd_errors[1], sd_errors[2]);
|
||||
|
||||
lv_label_set_text(lb_val4, txt_buf);
|
||||
|
||||
lv_obj_set_width(lb_val4, lv_obj_get_width(val4));
|
||||
lv_obj_align(val4, desc4, LV_ALIGN_OUT_RIGHT_MID, LV_DPI / 2, 0);
|
||||
|
||||
free(txt_buf);
|
||||
sd_unmount(false);
|
||||
}
|
||||
|
|
|
@ -24,6 +24,29 @@
|
|||
|
||||
static bool sd_mounted = false;
|
||||
static bool sd_init_done = false;
|
||||
static u16 sd_errors[3] = { 0 }; // Init and Read/Write errors.
|
||||
static u32 sd_mode = SD_UHS_SDR104;
|
||||
|
||||
void sd_error_count_increment(u8 type)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case SD_ERROR_INIT_FAIL:
|
||||
sd_errors[0]++;
|
||||
break;
|
||||
case SD_ERROR_RW_FAIL:
|
||||
sd_errors[1]++;
|
||||
break;
|
||||
case SD_ERROR_RW_RETRY:
|
||||
sd_errors[2]++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
u16 *sd_get_error_count()
|
||||
{
|
||||
return sd_errors;
|
||||
}
|
||||
|
||||
bool sd_get_card_removed()
|
||||
{
|
||||
|
@ -93,6 +116,8 @@ bool sd_initialize(bool power_cycle)
|
|||
}
|
||||
else
|
||||
{
|
||||
sd_errors[0]++; // Increment init errors.
|
||||
|
||||
if (sd_mode == SD_INIT_FAIL)
|
||||
break;
|
||||
else
|
||||
|
|
|
@ -31,10 +31,19 @@ enum
|
|||
SD_UHS_SDR104 = 4
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
SD_ERROR_INIT_FAIL = 0,
|
||||
SD_ERROR_RW_FAIL = 1,
|
||||
SD_ERROR_RW_RETRY = 2
|
||||
};
|
||||
|
||||
sdmmc_t sd_sdmmc;
|
||||
sdmmc_storage_t sd_storage;
|
||||
FATFS sd_fs;
|
||||
|
||||
void sd_error_count_increment(u8 type);
|
||||
u16 *sd_get_error_count();
|
||||
bool sd_get_card_removed();
|
||||
u32 sd_get_mode();
|
||||
int sd_init_retry(bool power_cycle);
|
||||
|
|
|
@ -187,6 +187,8 @@ reinit_try:
|
|||
else
|
||||
retries--;
|
||||
|
||||
sd_error_count_increment(SD_ERROR_RW_RETRY);
|
||||
|
||||
msleep(50);
|
||||
} while (retries);
|
||||
|
||||
|
@ -195,10 +197,16 @@ reinit_try:
|
|||
{
|
||||
int res;
|
||||
|
||||
sd_error_count_increment(SD_ERROR_RW_FAIL);
|
||||
|
||||
if (!first_reinit)
|
||||
res = sd_initialize(true);
|
||||
else
|
||||
{
|
||||
res = sd_init_retry(true);
|
||||
if (!res)
|
||||
sd_error_count_increment(SD_ERROR_INIT_FAIL);
|
||||
}
|
||||
|
||||
retries = 3;
|
||||
first_reinit = true;
|
||||
|
|
Loading…
Reference in a new issue