From 63c6cfedef06562cc0f38304e9deacf6ed160640 Mon Sep 17 00:00:00 2001 From: CTCaer Date: Sun, 22 Feb 2026 08:47:22 +0200 Subject: [PATCH] hekate/nyx: adjust handling of sdmmc return values --- bootloader/frontend/fe_info.c | 4 +-- bootloader/frontend/fe_tools.c | 2 +- bootloader/hos/hos.c | 4 +-- bootloader/libs/fatfs/diskio.c | 4 +-- bootloader/main.c | 8 ++--- bootloader/storage/emummc.c | 26 +++++++--------- nyx/nyx_gui/config.c | 2 +- nyx/nyx_gui/frontend/fe_emmc_tools.c | 29 ++++++++++-------- nyx/nyx_gui/frontend/fe_emummc_tools.c | 14 ++++----- nyx/nyx_gui/frontend/gui.c | 10 +++---- nyx/nyx_gui/frontend/gui_info.c | 30 +++++++++---------- nyx/nyx_gui/frontend/gui_options.c | 2 +- nyx/nyx_gui/frontend/gui_tools.c | 14 ++++----- .../frontend/gui_tools_partition_manager.c | 14 ++++----- nyx/nyx_gui/hos/hos.c | 6 ++-- nyx/nyx_gui/libs/fatfs/diskio.c | 10 +++---- nyx/nyx_gui/nyx.c | 8 ++--- 17 files changed, 94 insertions(+), 93 deletions(-) diff --git a/bootloader/frontend/fe_info.c b/bootloader/frontend/fe_info.c index db1182af..546ba459 100644 --- a/bootloader/frontend/fe_info.c +++ b/bootloader/frontend/fe_info.c @@ -65,7 +65,7 @@ void print_mmc_info() static const u32 SECTORS_TO_MIB_COEFF = 11; - if (!emmc_initialize(false)) + if (emmc_initialize(false)) { EPRINTF("Failed to init eMMC."); goto out; @@ -194,7 +194,7 @@ void print_sdcard_info() gfx_clear_partial_grey(0x1B, 0, 1256); gfx_con_setpos(0, 0); - if (sd_initialize(false)) + if (!sd_initialize(false)) { gfx_printf("%kCard IDentification:%k\n", TXT_CLR_CYAN_L, TXT_CLR_DEFAULT); gfx_printf( diff --git a/bootloader/frontend/fe_tools.c b/bootloader/frontend/fe_tools.c index 8c2231d8..9f72ac93 100644 --- a/bootloader/frontend/fe_tools.c +++ b/bootloader/frontend/fe_tools.c @@ -110,7 +110,7 @@ void menu_autorcm() return; } - if (!emmc_initialize(false)) + if (emmc_initialize(false)) { EPRINTF("Failed to init eMMC."); btn_wait(); diff --git a/bootloader/hos/hos.c b/bootloader/hos/hos.c index a142f72e..a4388f8a 100644 --- a/bootloader/hos/hos.c +++ b/bootloader/hos/hos.c @@ -137,12 +137,12 @@ static int _hos_eks_rw_try(u8 *buf, bool write) { if (!write) { - if (sdmmc_storage_read(&sd_storage, 0, 1, buf)) + if (!sdmmc_storage_read(&sd_storage, 0, 1, buf)) return 0; } else { - if (sdmmc_storage_write(&sd_storage, 0, 1, buf)) + if (!sdmmc_storage_write(&sd_storage, 0, 1, buf)) return 0; } } diff --git a/bootloader/libs/fatfs/diskio.c b/bootloader/libs/fatfs/diskio.c index d207d968..965020f9 100644 --- a/bootloader/libs/fatfs/diskio.c +++ b/bootloader/libs/fatfs/diskio.c @@ -43,7 +43,7 @@ DRESULT disk_read ( UINT count /* Number of sectors to read */ ) { - return sdmmc_storage_read(&sd_storage, sector, count, buff) ? RES_OK : RES_ERROR; + return sdmmc_storage_read(&sd_storage, sector, count, buff); } /*-----------------------------------------------------------------------*/ @@ -56,7 +56,7 @@ DRESULT disk_write ( UINT count /* Number of sectors to write */ ) { - return sdmmc_storage_write(&sd_storage, sector, count, (void *)buff) ? RES_OK : RES_ERROR; + return sdmmc_storage_write(&sd_storage, sector, count, (void *)buff); } /*-----------------------------------------------------------------------*/ diff --git a/bootloader/main.c b/bootloader/main.c index f7c29ba4..a9c4bb6a 100644 --- a/bootloader/main.c +++ b/bootloader/main.c @@ -228,7 +228,7 @@ static void _launch_payloads() gfx_clear_grey(0x1B); gfx_con_setpos(0, 0); - if (!sd_mount()) + if (sd_mount()) goto failed_sd_mount; ments = (ment_t *)malloc(sizeof(ment_t) * (max_entries + 3)); @@ -310,7 +310,7 @@ static void _launch_ini_list() gfx_clear_grey(0x1B); gfx_con_setpos(0, 0); - if (!sd_mount()) + if (sd_mount()) goto parse_failed; // Check that ini files exist and parse them. @@ -440,7 +440,7 @@ static void _launch_config() gfx_clear_grey(0x1B); gfx_con_setpos(0, 0); - if (!sd_mount()) + if (sd_mount()) goto parse_failed; // Load emuMMC configuration. @@ -1466,7 +1466,7 @@ void ipl_main() bpmp_clk_rate_set(h_cfg.t210b01 ? ipl_ver.rcfg.bclk_t210b01 : ipl_ver.rcfg.bclk_t210); // Mount SD Card. - if (!sd_mount()) + if (sd_mount()) h_cfg.errors |= ERR_SD_BOOT_EN; // Check if watchdog was fired previously. diff --git a/bootloader/storage/emummc.c b/bootloader/storage/emummc.c index d61b7550..7c889b73 100644 --- a/bootloader/storage/emummc.c +++ b/bootloader/storage/emummc.c @@ -137,13 +137,13 @@ int emummc_storage_init_mmc() emu_cfg.active_part = 0; // Always init eMMC even when in emuMMC. eMMC is needed from the emuMMC driver anyway. - if (!emmc_initialize(false)) + if (emmc_initialize(false)) return 2; if (!emu_cfg.enabled || h_cfg.emummc_force_disable) return 0; - if (!sd_mount()) + if (sd_mount()) goto out; if (!emu_cfg.sector) @@ -180,7 +180,7 @@ int emummc_storage_end() else sd_end(); - return 1; + return 0; } int emummc_storage_read(u32 sector, u32 num_sectors, void *buf) @@ -211,21 +211,19 @@ int emummc_storage_read(u32 sector, u32 num_sectors, void *buf) if (f_open(&fp, emu_cfg.emummc_file_based_path, FA_READ)) { EPRINTF("Failed to open emuMMC image."); - return 0; + return 1; } f_lseek(&fp, (u64)sector << 9); if (f_read(&fp, buf, (u64)num_sectors << 9, NULL)) { EPRINTF("Failed to read emuMMC image."); f_close(&fp); - return 0; + return 1; } f_close(&fp); - return 1; + return 0; } - - return 1; } int emummc_storage_write(u32 sector, u32 num_sectors, void *buf) @@ -255,17 +253,17 @@ int emummc_storage_write(u32 sector, u32 num_sectors, void *buf) } if (f_open(&fp, emu_cfg.emummc_file_based_path, FA_WRITE)) - return 0; + return 1; f_lseek(&fp, (u64)sector << 9); if (f_write(&fp, buf, (u64)num_sectors << 9, NULL)) { f_close(&fp); - return 0; + return 1; } f_close(&fp); - return 1; + return 0; } } @@ -275,7 +273,7 @@ int emummc_storage_set_mmc_partition(u32 partition) emmc_set_partition(partition); if (!emu_cfg.enabled || h_cfg.emummc_force_disable || emu_cfg.sector) - return 1; + return 0; else { strcpy(emu_cfg.emummc_file_based_path, emu_cfg.path); @@ -294,8 +292,6 @@ int emummc_storage_set_mmc_partition(u32 partition) break; } - return 1; + return 0; } - - return 1; } diff --git a/nyx/nyx_gui/config.c b/nyx/nyx_gui/config.c index f3e5c892..e5fc541c 100644 --- a/nyx/nyx_gui/config.c +++ b/nyx/nyx_gui/config.c @@ -188,7 +188,7 @@ int create_nyx_config_entry(bool force_unmount) { bool sd_mounted = sd_get_card_mounted(); - if (!sd_mount()) + if (sd_mount()) return 1; char lbuf[64]; diff --git a/nyx/nyx_gui/frontend/fe_emmc_tools.c b/nyx/nyx_gui/frontend/fe_emmc_tools.c index 8b89a779..7685598d 100644 --- a/nyx/nyx_gui/frontend/fe_emmc_tools.c +++ b/nyx/nyx_gui/frontend/fe_emmc_tools.c @@ -211,7 +211,7 @@ static int _emmc_sd_copy_verify(emmc_tool_gui_t *gui, sdmmc_storage_t *storage, // Full provides all that, plus protection from extremely rare I/O corruption. if ((n_cfg.verification >= 2) || !(sparseShouldVerify % 4)) { - if (!sdmmc_storage_read(storage, lba_curr, num, bufEm)) + if (sdmmc_storage_read(storage, lba_curr, num, bufEm)) { s_printf(gui->txt_buf, "\n#FF0000 Failed to read %d blocks (@LBA %08X),#\n" @@ -629,9 +629,9 @@ static int _dump_emmc_part(emmc_tool_gui_t *gui, char *sd_path, int active_part, int res_read; if (!gui->raw_emummc) - res_read = !sdmmc_storage_read(storage, lba_curr, num, buf); + res_read = sdmmc_storage_read(storage, lba_curr, num, buf); else - res_read = !sdmmc_storage_read(&sd_storage, lba_curr + sd_sector_off, num, buf); + res_read = sdmmc_storage_read(&sd_storage, lba_curr + sd_sector_off, num, buf); while (res_read) { @@ -671,8 +671,13 @@ static int _dump_emmc_part(emmc_tool_gui_t *gui, char *sd_path, int active_part, lv_label_ins_text(gui->label_log, LV_LABEL_POS_LAST, gui->txt_buf); manual_system_maintenance(true); } + + if (!gui->raw_emummc) + res_read = sdmmc_storage_read(storage, lba_curr, num, buf); + else + res_read = sdmmc_storage_read(&sd_storage, lba_curr + sd_sector_off, num, buf); + manual_system_maintenance(false); } - manual_system_maintenance(false); res = f_write_fast(&fp, buf, EMMC_BLOCKSIZE * num); @@ -781,7 +786,7 @@ void dump_emmc_selected(emmcPartType_t dumpType, emmc_tool_gui_t *gui) lv_label_set_text(gui->label_info, "Checking for available free space..."); manual_system_maintenance(true); - if (!sd_mount()) + if (sd_mount()) { lv_label_set_text(gui->label_info, "#FFDD00 Failed to init SD!#"); goto out; @@ -790,7 +795,7 @@ void dump_emmc_selected(emmcPartType_t dumpType, emmc_tool_gui_t *gui) // Get SD Card free space for Partial Backup. f_getfree("", &sd_fs.free_clst, NULL); - if (!emmc_initialize(false)) + if (emmc_initialize(false)) { lv_label_set_text(gui->label_info, "#FFDD00 Failed to init eMMC!#"); goto out; @@ -1302,9 +1307,9 @@ multipart_not_allowed: return 1; } if (!gui->raw_emummc) - res = !sdmmc_storage_write(storage, lba_curr, num, buf); + res = sdmmc_storage_write(storage, lba_curr, num, buf); else - res = !sdmmc_storage_write(&sd_storage, lba_curr + sd_sector_off, num, buf); + res = sdmmc_storage_write(&sd_storage, lba_curr + sd_sector_off, num, buf); manual_system_maintenance(false); @@ -1337,9 +1342,9 @@ multipart_not_allowed: manual_system_maintenance(true); } if (!gui->raw_emummc) - res = !sdmmc_storage_write(storage, lba_curr, num, buf); + res = sdmmc_storage_write(storage, lba_curr, num, buf); else - res = !sdmmc_storage_write(&sd_storage, lba_curr + sd_sector_off, num, buf); + res = sdmmc_storage_write(&sd_storage, lba_curr + sd_sector_off, num, buf); manual_system_maintenance(false); } pct = (u64)((u64)(lba_curr - part->lba_start) * 100u) / (u64)(lba_end - part->lba_start); @@ -1457,13 +1462,13 @@ void restore_emmc_selected(emmcPartType_t restoreType, emmc_tool_gui_t *gui) lv_obj_del(warn_mbox_bg); manual_system_maintenance(true); - if (!sd_mount()) + if (sd_mount()) { lv_label_set_text(gui->label_info, "#FFDD00 Failed to init SD!#"); goto out; } - if (!emmc_initialize(false)) + if (emmc_initialize(false)) { lv_label_set_text(gui->label_info, "#FFDD00 Failed to init eMMC!#"); goto out; diff --git a/nyx/nyx_gui/frontend/fe_emummc_tools.c b/nyx/nyx_gui/frontend/fe_emummc_tools.c index 5b1fe490..bd317459 100644 --- a/nyx/nyx_gui/frontend/fe_emummc_tools.c +++ b/nyx/nyx_gui/frontend/fe_emummc_tools.c @@ -270,7 +270,7 @@ static int _dump_emummc_file_part(emmc_tool_gui_t *gui, char *sd_path, sdmmc_sto retryCount = 0; num = MIN(totalSectors, NUM_SECTORS_PER_ITER); - while (!sdmmc_storage_read(storage, lba_curr, num, buf)) + while (sdmmc_storage_read(storage, lba_curr, num, buf)) { s_printf(gui->txt_buf, "\n#FFDD00 Error reading %d blocks @ LBA %08X,#\n" @@ -368,7 +368,7 @@ void dump_emummc_file(emmc_tool_gui_t *gui) manual_system_maintenance(true); - if (!sd_mount()) + if (sd_mount()) { lv_label_set_text(gui->label_info, "#FFDD00 Failed to init SD!#"); goto out; @@ -380,7 +380,7 @@ void dump_emummc_file(emmc_tool_gui_t *gui) // Get SD Card free space for file based emuMMC. f_getfree("", &sd_fs.free_clst, NULL); - if (!emmc_initialize(false)) + if (emmc_initialize(false)) { lv_label_set_text(gui->label_info, "#FFDD00 Failed to init eMMC!#"); goto out; @@ -570,7 +570,7 @@ static int _dump_emummc_raw_part(emmc_tool_gui_t *gui, int active_part, int part num = MIN(totalSectors, NUM_SECTORS_PER_ITER); // Read data from eMMC. - while (!sdmmc_storage_read(&emmc_storage, lba_curr, num, buf)) + while (sdmmc_storage_read(&emmc_storage, lba_curr, num, buf)) { s_printf(gui->txt_buf, "\n#FFDD00 Error reading %d blocks @LBA %08X,#\n" @@ -600,7 +600,7 @@ static int _dump_emummc_raw_part(emmc_tool_gui_t *gui, int active_part, int part // Write data to SD card. retryCount = 0; - while (!sdmmc_storage_write(&sd_storage, sd_sector_off + lba_curr, num, buf)) + while (sdmmc_storage_write(&sd_storage, sd_sector_off + lba_curr, num, buf)) { s_printf(gui->txt_buf, "\n#FFDD00 Error writing %d blocks @LBA %08X,#\n" @@ -837,13 +837,13 @@ void dump_emummc_raw(emmc_tool_gui_t *gui, int part_idx, u32 sector_start, u32 r manual_system_maintenance(true); - if (!sd_mount()) + if (sd_mount()) { lv_label_set_text(gui->label_info, "#FFDD00 Failed to init SD!#"); goto out; } - if (!emmc_initialize(false)) + if (emmc_initialize(false)) { lv_label_set_text(gui->label_info, "#FFDD00 Failed to init eMMC!#"); goto out; diff --git a/nyx/nyx_gui/frontend/gui.c b/nyx/nyx_gui/frontend/gui.c index acd5a075..220b0f7f 100644 --- a/nyx/nyx_gui/frontend/gui.c +++ b/nyx/nyx_gui/frontend/gui.c @@ -1448,7 +1448,7 @@ static lv_res_t _create_mbox_payloads(lv_obj_t *btn) lv_obj_set_size(list, LV_HOR_RES * 3 / 7, LV_VER_RES * 3 / 7); lv_list_set_single_mode(list, true); - if (!sd_mount()) + if (sd_mount()) { lv_mbox_set_text(mbox, "#FFDD00 Failed to init SD!#"); @@ -1760,7 +1760,7 @@ static lv_res_t _create_window_home_launch(lv_obj_t *btn) u32 curr_btn_idx = 0; // Active buttons. LIST_INIT(ini_sections); - if (!sd_mount()) + if (sd_mount()) goto failed_sd_mount; // Check if we use custom system icons. @@ -2138,10 +2138,10 @@ static lv_res_t _save_options_action(lv_obj_t *btn) int res = 0; - if (sd_mount()) - res = !create_config_entry(); + if (!sd_mount()) + res = create_config_entry(); - if (res) + if (!res) lv_mbox_set_text(mbox, "#FF8000 hekate Configuration#\n\n#96FF00 The configuration was saved to sd card!#"); else lv_mbox_set_text(mbox, "#FF8000 hekate Configuration#\n\n#FFDD00 Failed to save the configuration#\n#FFDD00 to sd card!#"); diff --git a/nyx/nyx_gui/frontend/gui_info.c b/nyx/nyx_gui/frontend/gui_info.c index f8f8c852..665c4938 100644 --- a/nyx/nyx_gui/frontend/gui_info.c +++ b/nyx/nyx_gui/frontend/gui_info.c @@ -74,7 +74,7 @@ static lv_res_t _cal0_dump_window_action(lv_obj_t *btns, const char * txt) if (btn_idx == 1) { - int error = !sd_mount(); + int error = sd_mount(); if (!error) { @@ -94,7 +94,7 @@ static lv_res_t _cal0_dump_window_action(lv_obj_t *btns, const char * txt) static lv_res_t _battery_dump_window_action(lv_obj_t * btn) { - int error = !sd_mount(); + int error = sd_mount(); if (!error) { @@ -118,7 +118,7 @@ static lv_res_t _bootrom_dump_window_action(lv_obj_t * btn) { static const u32 BOOTROM_SIZE = 0x18000; - int error = !sd_mount(); + int error = sd_mount(); if (!error) { char path[64]; @@ -179,7 +179,7 @@ static void _unlock_reserved_odm_fuses(bool lock) static lv_res_t _fuse_dump_window_action(lv_obj_t * btn) { - int error = !sd_mount(); + int error = sd_mount(); if (!error) { char path[128]; @@ -230,7 +230,7 @@ static lv_res_t _kfuse_dump_window_action(lv_obj_t * btn) int error = kfuse_read(buf); if (!error) - error = !sd_mount(); + error = sd_mount(); if (!error) { @@ -1444,7 +1444,7 @@ static lv_res_t _create_mbox_emmc_sandisk_report(lv_obj_t * btn) lv_obj_align(lb_desc2, lb_desc, LV_ALIGN_OUT_RIGHT_TOP, 0, 0); - if (!emmc_initialize(false)) + if (emmc_initialize(false)) { lv_label_set_text(lb_desc, "#FFDD00 Failed to init eMMC!#"); @@ -1454,7 +1454,7 @@ static lv_res_t _create_mbox_emmc_sandisk_report(lv_obj_t * btn) int res = sdmmc_storage_vendor_sandisk_report(&emmc_storage, buf); emmc_end(); - if (!res) + if (res) { lv_label_set_text(lb_desc, "#FFDD00 Device Report not supported!#"); lv_label_set_text(lb_desc2, " "); @@ -1638,12 +1638,12 @@ static lv_res_t _create_mbox_benchmark(bool sd_bench) // Re-initialize to update trimmers. sd_end(); - res = !sd_mount(); + res = sd_mount(); } else { storage = &emmc_storage; - res = !emmc_initialize(false); + res = emmc_initialize(false); if (!res) emmc_set_partition(EMMC_GPP); } @@ -1707,7 +1707,7 @@ static lv_res_t _create_mbox_benchmark(bool sd_bench) while (data_remaining) { u32 time_taken = get_tmr_us(); - error = !sdmmc_storage_read(storage, sector_off + lba_curr, sector_num, (u8 *)MIXD_BUF_ALIGNED); + error = sdmmc_storage_read(storage, sector_off + lba_curr, sector_num, (u8 *)MIXD_BUF_ALIGNED); time_taken = get_tmr_us() - time_taken; timer += time_taken; @@ -1754,7 +1754,7 @@ static lv_res_t _create_mbox_benchmark(bool sd_bench) while (data_remaining) { u32 time_taken = get_tmr_us(); - error = !sdmmc_storage_read(storage, sector_off + lba_curr, sector_num, (u8 *)MIXD_BUF_ALIGNED); + error = sdmmc_storage_read(storage, sector_off + lba_curr, sector_num, (u8 *)MIXD_BUF_ALIGNED); time_taken = get_tmr_us() - time_taken; timer += time_taken; @@ -1829,7 +1829,7 @@ static lv_res_t _create_mbox_benchmark(bool sd_bench) while (data_remaining) { u32 time_taken = get_tmr_us(); - error = !sdmmc_storage_read(storage, sector_off + random_offsets[lba_idx], sector_num, (u8 *)MIXD_BUF_ALIGNED); + error = sdmmc_storage_read(storage, sector_off + random_offsets[lba_idx], sector_num, (u8 *)MIXD_BUF_ALIGNED); time_taken = get_tmr_us() - time_taken; timer += time_taken; @@ -1965,7 +1965,7 @@ static lv_res_t _create_window_emmc_info_status(lv_obj_t *btn) txt_buf[1] = 0; u16 *emmc_errors; - if (!emmc_initialize(false)) + if (emmc_initialize(false)) { lv_label_set_text(lb_desc, "#FFDD00 Failed to init eMMC!#"); lv_obj_set_width(lb_desc, lv_obj_get_width(desc)); @@ -2234,7 +2234,7 @@ static lv_res_t _create_window_sdcard_info_status(lv_obj_t *btn) manual_system_maintenance(true); - if (!sd_mount()) + if (sd_mount()) { lv_label_set_text(lb_desc, "#FFDD00 Failed to init SD!#"); goto failed; @@ -2879,7 +2879,7 @@ static bool _lockpick_exists_check() bool found = false; void *buf = malloc(0x200); - if (sd_mount()) + if (!sd_mount()) { FIL fp; if (f_open(&fp, "bootloader/payloads/Lockpick_RCM.bin", FA_READ)) diff --git a/nyx/nyx_gui/frontend/gui_options.c b/nyx/nyx_gui/frontend/gui_options.c index 0ab730dc..d593b756 100644 --- a/nyx/nyx_gui/frontend/gui_options.c +++ b/nyx/nyx_gui/frontend/gui_options.c @@ -1180,7 +1180,7 @@ static lv_res_t _joycon_info_dump_action(lv_obj_t * btn) jc_pad->bt_conn_r.type = is_r_hos ? jc_pad->bt_conn_r.type : 0; save_data: - error = !sd_mount() ? 5 : 0; + error = sd_mount() ? 5 : 0; if (!error) { diff --git a/nyx/nyx_gui/frontend/gui_tools.c b/nyx/nyx_gui/frontend/gui_tools.c index 41f70525..8d60c307 100644 --- a/nyx/nyx_gui/frontend/gui_tools.c +++ b/nyx/nyx_gui/frontend/gui_tools.c @@ -483,7 +483,7 @@ static lv_res_t _action_ums_emuemmc_boot0(lv_obj_t *btn) usb_ctxt_t usbs; - int error = !sd_mount(); + int error = sd_mount(); if (!error) { emummc_cfg_t emu_info; @@ -530,7 +530,7 @@ static lv_res_t _action_ums_emuemmc_boot1(lv_obj_t *btn) usb_ctxt_t usbs; - int error = !sd_mount(); + int error = sd_mount(); if (!error) { emummc_cfg_t emu_info; @@ -577,7 +577,7 @@ static lv_res_t _action_ums_emuemmc_gpp(lv_obj_t *btn) usb_ctxt_t usbs; - int error = !sd_mount(); + int error = sd_mount(); if (!error) { emummc_cfg_t emu_info; @@ -593,7 +593,7 @@ static lv_res_t _action_ums_emuemmc_gpp(lv_obj_t *btn) usbs.offset = emu_info.sector + 0x4000; u8 *gpt = malloc(SD_BLOCKSIZE); - if (sdmmc_storage_read(&sd_storage, usbs.offset + 1, 1, gpt)) + if (!sdmmc_storage_read(&sd_storage, usbs.offset + 1, 1, gpt)) { if (!memcmp(gpt, "EFI PART", 8)) { @@ -938,7 +938,7 @@ static lv_res_t _create_window_unset_abit_tool(lv_obj_t *btn) lv_label_set_long_mode(lb_desc, LV_LABEL_LONG_BREAK); lv_label_set_recolor(lb_desc, true); - if (!sd_mount()) + if (sd_mount()) { lv_label_set_text(lb_desc, "#FFDD00 Failed to init SD!#"); lv_obj_set_width(lb_desc, lv_obj_get_width(desc)); @@ -1141,7 +1141,7 @@ static lv_res_t _create_window_dump_pk12_tool(lv_obj_t *btn) lv_obj_align(lb_desc2, lb_desc, LV_ALIGN_OUT_RIGHT_TOP, 0, 0); - if (!sd_mount()) + if (sd_mount()) { lv_label_set_text(lb_desc, "#FFDD00 Failed to init SD!#"); @@ -1159,7 +1159,7 @@ static lv_res_t _create_window_dump_pk12_tool(lv_obj_t *btn) char *txt_buf = (char *)malloc(SZ_16K); - if (!emmc_initialize(false)) + if (emmc_initialize(false)) { lv_label_set_text(lb_desc, "#FFDD00 Failed to init eMMC!#"); diff --git a/nyx/nyx_gui/frontend/gui_tools_partition_manager.c b/nyx/nyx_gui/frontend/gui_tools_partition_manager.c index e1dad6d4..e1bdb51a 100644 --- a/nyx/nyx_gui/frontend/gui_tools_partition_manager.c +++ b/nyx/nyx_gui/frontend/gui_tools_partition_manager.c @@ -887,7 +887,7 @@ static lv_res_t _action_flash_linux_data(lv_obj_t * btns, const char * txt) } // Write data block to L4T partition. - res = !sdmmc_storage_write(part_info.storage, lba_curr + l4t_flash_ctxt.offset_sct, num, buf); + res = sdmmc_storage_write(part_info.storage, lba_curr + l4t_flash_ctxt.offset_sct, num, buf); manual_system_maintenance(false); @@ -907,7 +907,7 @@ static lv_res_t _action_flash_linux_data(lv_obj_t * btns, const char * txt) goto exit; } - res = !sdmmc_storage_write(part_info.storage, lba_curr + l4t_flash_ctxt.offset_sct, num, buf); + res = sdmmc_storage_write(part_info.storage, lba_curr + l4t_flash_ctxt.offset_sct, num, buf); manual_system_maintenance(false); } @@ -1922,7 +1922,7 @@ static lv_res_t _emmc_create_mbox_start_partitioning() lv_obj_align(mbox, NULL, LV_ALIGN_CENTER, 0, 0); manual_system_maintenance(true); - if (!emmc_initialize(false)) + if (emmc_initialize(false)) { lv_label_set_text(lbl_extra, "#FFDD00 Failed to init eMMC!#"); goto exit; @@ -2661,7 +2661,7 @@ static lv_res_t _action_fix_mbr_gpt(lv_obj_t *btn) int gpt_emummc_migrate_no = 0; // Try to init sd card. No need for valid MBR. - if (!sd_mount() && !sd_get_card_initialized()) + if (sd_mount() && !sd_get_card_initialized()) { lv_label_set_text(lbl_status, "#FFDD00 Failed to init SD!#"); goto out; @@ -3044,7 +3044,7 @@ lv_res_t create_window_partition_manager(bool emmc) u32 emmc_size = 0; if (!emmc) { - if (!sd_mount()) + if (sd_mount()) { lv_obj_t *lbl = lv_label_create(h1, NULL); lv_label_set_recolor(lbl, true); @@ -3052,7 +3052,7 @@ lv_res_t create_window_partition_manager(bool emmc) return LV_RES_OK; } - if (emmc_initialize(false)) + if (!emmc_initialize(false)) { emmc_set_partition(EMMC_GPP); emmc_size = emmc_storage.sec_cnt >> 11; @@ -3061,7 +3061,7 @@ lv_res_t create_window_partition_manager(bool emmc) } else { - if (!emmc_initialize(false)) + if (emmc_initialize(false)) { lv_obj_t *lbl = lv_label_create(h1, NULL); lv_label_set_recolor(lbl, true); diff --git a/nyx/nyx_gui/hos/hos.c b/nyx/nyx_gui/hos/hos.c index 22021cee..1c6ccb99 100644 --- a/nyx/nyx_gui/hos/hos.c +++ b/nyx/nyx_gui/hos/hos.c @@ -178,12 +178,12 @@ static int _hos_eks_rw_try(u8 *buf, bool write) { if (!write) { - if (sdmmc_storage_read(&sd_storage, 0, 1, buf)) + if (!sdmmc_storage_read(&sd_storage, 0, 1, buf)) return 0; } else { - if (sdmmc_storage_write(&sd_storage, 0, 1, buf)) + if (!sdmmc_storage_write(&sd_storage, 0, 1, buf)) return 0; } } @@ -666,7 +666,7 @@ void hos_bis_keys_clear() int hos_dump_cal0() { // Init eMMC. - if (!emmc_initialize(false)) + if (emmc_initialize(false)) return 1; // Generate BIS keys diff --git a/nyx/nyx_gui/libs/fatfs/diskio.c b/nyx/nyx_gui/libs/fatfs/diskio.c index 1eb38924..b2c47ac3 100644 --- a/nyx/nyx_gui/libs/fatfs/diskio.c +++ b/nyx/nyx_gui/libs/fatfs/diskio.c @@ -55,14 +55,14 @@ DRESULT disk_read ( switch (pdrv) { case DRIVE_SD: - return sdmmc_storage_read(&sd_storage, sector, count, (void *)buff) ? RES_OK : RES_ERROR; + return sdmmc_storage_read(&sd_storage, sector, count, (void *)buff); case DRIVE_RAM: return ram_disk_read(sector, count, (void *)buff); case DRIVE_EMMC: - return sdmmc_storage_read(&emmc_storage, sector, count, (void *)buff) ? RES_OK : RES_ERROR; + return sdmmc_storage_read(&emmc_storage, sector, count, (void *)buff); case DRIVE_BIS: case DRIVE_EMU: - return nx_emmc_bis_read(sector, count, (void *)buff) ? RES_OK : RES_ERROR; + return nx_emmc_bis_read(sector, count, (void *)buff); } return RES_ERROR; @@ -81,7 +81,7 @@ DRESULT disk_write ( switch (pdrv) { case DRIVE_SD: - return sdmmc_storage_write(&sd_storage, sector, count, (void *)buff) ? RES_OK : RES_ERROR; + return sdmmc_storage_write(&sd_storage, sector, count, (void *)buff); case DRIVE_RAM: return ram_disk_write(sector, count, (void *)buff); case DRIVE_EMMC: @@ -90,7 +90,7 @@ DRESULT disk_write ( case DRIVE_EMU: if (pdrv == DRIVE_BIS && !bis_write_allowed) return RES_WRPRT; - return nx_emmc_bis_write(sector, count, (void *)buff) ? RES_OK : RES_ERROR; + return nx_emmc_bis_write(sector, count, (void *)buff); } return RES_ERROR; diff --git a/nyx/nyx_gui/nyx.c b/nyx/nyx_gui/nyx.c index c3c29255..9b7df269 100644 --- a/nyx/nyx_gui/nyx.c +++ b/nyx/nyx_gui/nyx.c @@ -52,7 +52,7 @@ char *emmcsn_path_impl(char *path, char *sub_dir, char *filename, sdmmc_storage_ // Get actual eMMC S/N. if (!storage) { - if (!emmc_initialize(false)) + if (emmc_initialize(false)) strcpy(emmc_sn, "00000000"); else { @@ -121,7 +121,7 @@ lv_res_t launch_payload(lv_obj_t *list) strcpy(path,"bootloader/payloads/"); strcat(path, filename); - if (!sd_mount()) + if (sd_mount()) goto out; // Read payload. @@ -425,13 +425,13 @@ void nyx_init_load_res() _show_errors(SD_NO_ERROR); // Try 2 times to mount SD card. - if (!sd_mount()) + if (sd_mount()) { // Restore speed to SDR104. sd_end(); // Retry. - if (!sd_mount()) + if (sd_mount()) _show_errors(SD_MOUNT_ERROR); // Fatal. }