diff --git a/nyx/nyx_gui/frontend/fe_emmc_tools.c b/nyx/nyx_gui/frontend/fe_emmc_tools.c index 521e8087..8b89a779 100644 --- a/nyx/nyx_gui/frontend/fe_emmc_tools.c +++ b/nyx/nyx_gui/frontend/fe_emmc_tools.c @@ -380,7 +380,7 @@ 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); - return 0; + return 1; } sd_sector_off = sector_start + (0x2000 * active_part); if (active_part == 2) @@ -424,7 +424,7 @@ 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); - return 0; + return 1; } } // Check if we are continuing a previous raw eMMC or USER partition backup in progress. @@ -447,7 +447,7 @@ 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); - return 0; + return 1; } // Increase maxSplitParts to accommodate previously backed up parts. @@ -485,7 +485,7 @@ static int _dump_emmc_part(emmc_tool_gui_t *gui, char *sd_path, int active_part, if (!(btn_wait() & BTN_POWER)) { lv_obj_del(warn_mbox_bg); - return 0; + return 1; } lv_obj_del(warn_mbox_bg); } @@ -502,7 +502,7 @@ 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); - return 0; + return 1; } u8 *buf = (u8 *)MIXD_BUF_ALIGNED; @@ -553,7 +553,7 @@ static int _dump_emmc_part(emmc_tool_gui_t *gui, char *sd_path, int active_part, strcpy(gui->txt_buf, "\n#FFDD00 Please try again...#\n"); lv_label_ins_text(gui->label_log, LV_LABEL_POS_LAST, gui->txt_buf); manual_system_maintenance(true); - return 0; + return 1; case VERIF_STATUS_ABORT: verification = 0; break; @@ -580,7 +580,7 @@ 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); - return 0; + return 1; } // More parts to backup that do not currently fit the sd card free space or fatal error. @@ -596,7 +596,7 @@ static int _dump_emmc_part(emmc_tool_gui_t *gui, char *sd_path, int active_part, partial_sd_full_unmount = true; - return 1; + return 0; } } @@ -615,7 +615,7 @@ 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); - return 0; + return 1; } bytesWritten = 0; @@ -663,7 +663,7 @@ static int _dump_emmc_part(emmc_tool_gui_t *gui, char *sd_path, int active_part, free(clmt); f_unlink(outFilename); - return 0; + return 1; } else { @@ -686,7 +686,7 @@ static int _dump_emmc_part(emmc_tool_gui_t *gui, char *sd_path, int active_part, free(clmt); f_unlink(outFilename); - return 0; + return 1; } manual_system_maintenance(false); @@ -725,7 +725,7 @@ static int _dump_emmc_part(emmc_tool_gui_t *gui, char *sd_path, int active_part, free(clmt); f_unlink(outFilename); - return 0; + return 1; } } lv_bar_set_value(gui->bar, 100); @@ -745,7 +745,7 @@ 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); - return 0; + return 1; } lv_bar_set_value(gui->bar, 100); lv_label_set_text(gui->label_pct, " "SYMBOL_DOT" 100%"); @@ -764,12 +764,12 @@ static int _dump_emmc_part(emmc_tool_gui_t *gui, char *sd_path, int active_part, partial_sd_full_unmount = true; } - return 1; + return 0; } void dump_emmc_selected(emmcPartType_t dumpType, emmc_tool_gui_t *gui) { - int res = 0; + int res = 1; u32 timer = 0; char *txt_buf = (char *)malloc(SZ_16K); @@ -844,7 +844,7 @@ void dump_emmc_selected(emmcPartType_t dumpType, emmc_tool_gui_t *gui) res = _dump_emmc_part(gui, sdPath, i, &emmc_storage, &bootPart); - if (!res) + if (res) strcpy(txt_buf, "#FFDD00 Failed!#\n"); else strcpy(txt_buf, "Done!\n"); @@ -884,7 +884,7 @@ void dump_emmc_selected(emmcPartType_t dumpType, emmc_tool_gui_t *gui) emmcsn_path_impl(sdPath, "/partitions", part->name, &emmc_storage); res = _dump_emmc_part(gui, sdPath, 0, &emmc_storage, part); // If a part failed, don't continue. - if (!res) + if (res) { strcpy(txt_buf, "#FFDD00 Failed!#\n"); lv_label_ins_text(gui->label_log, LV_LABEL_POS_LAST, txt_buf); @@ -927,7 +927,7 @@ void dump_emmc_selected(emmcPartType_t dumpType, emmc_tool_gui_t *gui) res = _dump_emmc_part(gui, sdPath, 2, &emmc_storage, &rawPart); - if (!res) + if (res) strcpy(txt_buf, "#FFDD00 Failed!#\n"); else strcpy(txt_buf, "Done!\n"); @@ -941,9 +941,9 @@ void dump_emmc_selected(emmcPartType_t dumpType, emmc_tool_gui_t *gui) timer = get_tmr_s() - timer; emmc_end(); - if (res && n_cfg.verification && !gui->raw_emummc) + if (!res && n_cfg.verification && !gui->raw_emummc) s_printf(txt_buf, "Time taken: %dm %ds.\n#96FF00 Finished and verified!#", timer / 60, timer % 60); - else if (res) + else if (!res) s_printf(txt_buf, "Time taken: %dm %ds.\nFinished!", timer / 60, timer % 60); else s_printf(txt_buf, "Time taken: %dm %ds.", timer / 60, timer % 60); @@ -1027,13 +1027,13 @@ static int _restore_emmc_part(emmc_tool_gui_t *gui, char *sd_path, int active_pa lv_label_ins_text(gui->label_log, LV_LABEL_POS_LAST, gui->txt_buf); manual_system_maintenance(true); - return 0; + return 1; } else if (f_stat(outFilename, &fno)) { if (!gui->raw_emummc) { - s_printf(gui->txt_buf, "\n#FFDD00 Error (%d) file not found#\n#FFDD00 %s.#\n\n", res, outFilename); + s_printf(gui->txt_buf, "\n#FFDD00 Error file not found#\n#FFDD00 %s.#\n\n", outFilename); lv_label_ins_text(gui->label_log, LV_LABEL_POS_LAST, gui->txt_buf); manual_system_maintenance(true); @@ -1056,7 +1056,7 @@ static int _restore_emmc_part(emmc_tool_gui_t *gui, char *sd_path, int active_pa lv_label_ins_text(gui->label_log, LV_LABEL_POS_LAST, gui->txt_buf); manual_system_maintenance(true); - return 0; + return 1; } } else @@ -1069,7 +1069,7 @@ static int _restore_emmc_part(emmc_tool_gui_t *gui, char *sd_path, int active_pa lv_label_ins_text(gui->label_log, LV_LABEL_POS_LAST, gui->txt_buf); manual_system_maintenance(true); - return 0; + return 1; } check_4MB_aligned = false; @@ -1097,7 +1097,7 @@ static int _restore_emmc_part(emmc_tool_gui_t *gui, char *sd_path, int active_pa lv_label_ins_text(gui->label_log, LV_LABEL_POS_LAST, gui->txt_buf); manual_system_maintenance(true); - return 0; + return 1; } lv_obj_del(warn_mbox_bg); @@ -1143,7 +1143,7 @@ multipart_not_allowed: manual_system_maintenance(true); } - return -1; + return 2; } else if (!use_multipart && (((u32)((u64)f_size(&fp) >> (u64)9)) != totalSectors)) // Check total restore size vs emmc size. { @@ -1155,7 +1155,7 @@ multipart_not_allowed: f_close(&fp); - return 0; + return 1; } else if (!gui->raw_emummc) { @@ -1174,7 +1174,7 @@ multipart_not_allowed: f_close(&fp); - return 0; + return 1; } lv_obj_del(warn_mbox_bg); } @@ -1216,7 +1216,7 @@ multipart_not_allowed: lv_label_ins_text(gui->label_log, LV_LABEL_POS_LAST, gui->txt_buf); manual_system_maintenance(true); - return 0; + return 1; } sd_sector_off = sector_start + (0x2000 * active_part); } @@ -1246,7 +1246,7 @@ multipart_not_allowed: strcpy(gui->txt_buf, "\n#FFDD00 Please try again...#\n"); lv_label_ins_text(gui->label_log, LV_LABEL_POS_LAST, gui->txt_buf); manual_system_maintenance(true); - return 0; + return 1; case VERIF_STATUS_ABORT: verification = 0; break; @@ -1275,7 +1275,7 @@ multipart_not_allowed: lv_label_ins_text(gui->label_log, LV_LABEL_POS_LAST, gui->txt_buf); manual_system_maintenance(true); - return 0; + return 1; } fileSize = (u64)f_size(&fp); bytesWritten = 0; @@ -1299,7 +1299,7 @@ multipart_not_allowed: f_close(&fp); free(clmt); - return 0; + return 1; } if (!gui->raw_emummc) res = !sdmmc_storage_write(storage, lba_curr, num, buf); @@ -1328,7 +1328,7 @@ multipart_not_allowed: f_close(&fp); free(clmt); - return 0; + return 1; } else { @@ -1373,7 +1373,7 @@ multipart_not_allowed: lv_label_ins_text(gui->label_log, LV_LABEL_POS_LAST, gui->txt_buf); manual_system_maintenance(true); - return 0; + return 1; } lv_bar_set_value(gui->bar, 100); lv_label_set_text(gui->label_pct, " "SYMBOL_DOT" 100%"); @@ -1397,7 +1397,7 @@ multipart_not_allowed: save_emummc_cfg(part_idx, sector_start, sdPath); } - return 1; + return 0; } void restore_emmc_selected(emmcPartType_t restoreType, emmc_tool_gui_t *gui) @@ -1512,15 +1512,14 @@ void restore_emmc_selected(emmcPartType_t restoreType, emmc_tool_gui_t *gui) emmcsn_path_impl(sdPath, "/restore/emummc", bootPart.name, &emmc_storage); res = _restore_emmc_part(gui, sdPath, i, &emmc_storage, &bootPart, false); - if (!res) + if (res == 1) strcpy(txt_buf, "#FFDD00 Failed!#\n"); - else if (res > 0) + else if (!res) strcpy(txt_buf, "Done!\n"); - if (res >= 0) + if (res <= 1) lv_label_ins_text(gui->label_log, LV_LABEL_POS_LAST, txt_buf); - else - res = 0; + manual_system_maintenance(true); } } @@ -1548,15 +1547,14 @@ void restore_emmc_selected(emmcPartType_t restoreType, emmc_tool_gui_t *gui) emmcsn_path_impl(sdPath, "/restore/partitions", part->name, &emmc_storage); res = _restore_emmc_part(gui, sdPath, 0, &emmc_storage, part, false); - if (!res) + if (res == 1) strcpy(txt_buf, "#FFDD00 Failed!#\n"); - else if (res > 0) + else if (!res) strcpy(txt_buf, "Done!\n"); - if (res >= 0) + if (res <= 1) lv_label_ins_text(gui->label_log, LV_LABEL_POS_LAST, txt_buf); - else - res = 0; + manual_system_maintenance(true); } emmc_gpt_free(&gpt); @@ -1587,15 +1585,14 @@ void restore_emmc_selected(emmcPartType_t restoreType, emmc_tool_gui_t *gui) emmcsn_path_impl(sdPath, "/restore/emummc", rawPart.name, &emmc_storage); res = _restore_emmc_part(gui, sdPath, 2, &emmc_storage, &rawPart, true); - if (!res) + if (res == 1) strcpy(txt_buf, "#FFDD00 Failed!#\n"); - else if (res > 0) + else if (!res) strcpy(txt_buf, "Done!\n"); - if (res >= 0) + if (res <= 1) lv_label_ins_text(gui->label_log, LV_LABEL_POS_LAST, txt_buf); - else - res = 0; + manual_system_maintenance(true); } } @@ -1603,9 +1600,9 @@ void restore_emmc_selected(emmcPartType_t restoreType, emmc_tool_gui_t *gui) timer = get_tmr_s() - timer; emmc_end(); - if (res && n_cfg.verification && !gui->raw_emummc) + if (!res && n_cfg.verification && !gui->raw_emummc) s_printf(txt_buf, "Time taken: %dm %ds.\n#96FF00 Finished and verified!#", timer / 60, timer % 60); - else if (res) + else if (!res) s_printf(txt_buf, "Time taken: %dm %ds.\nFinished!", timer / 60, timer % 60); else s_printf(txt_buf, "Time taken: %dm %ds.", timer / 60, timer % 60); diff --git a/nyx/nyx_gui/frontend/fe_emummc_tools.c b/nyx/nyx_gui/frontend/fe_emummc_tools.c index 614fb75b..5b1fe490 100644 --- a/nyx/nyx_gui/frontend/fe_emummc_tools.c +++ b/nyx/nyx_gui/frontend/fe_emummc_tools.c @@ -170,7 +170,7 @@ static int _dump_emummc_file_part(emmc_tool_gui_t *gui, char *sd_path, sdmmc_sto lv_label_ins_text(gui->label_log, LV_LABEL_POS_LAST, gui->txt_buf); manual_system_maintenance(true); - return 0; + return 1; } // Check if filesystem is FAT32 or the free space is smaller and dump in parts. @@ -196,7 +196,7 @@ static int _dump_emummc_file_part(emmc_tool_gui_t *gui, char *sd_path, sdmmc_sto lv_label_ins_text(gui->label_log, LV_LABEL_POS_LAST, gui->txt_buf); manual_system_maintenance(true); - return 0; + return 1; } u8 *buf = (u8 *)MIXD_BUF_ALIGNED; @@ -242,7 +242,7 @@ static int _dump_emummc_file_part(emmc_tool_gui_t *gui, char *sd_path, sdmmc_sto lv_label_ins_text(gui->label_log, LV_LABEL_POS_LAST, gui->txt_buf); manual_system_maintenance(true); - return 0; + return 1; } bytesWritten = 0; @@ -264,7 +264,7 @@ static int _dump_emummc_file_part(emmc_tool_gui_t *gui, char *sd_path, sdmmc_sto msleep(1000); - return 0; + return 1; } retryCount = 0; @@ -290,7 +290,7 @@ static int _dump_emummc_file_part(emmc_tool_gui_t *gui, char *sd_path, sdmmc_sto free(clmt); f_unlink(outFilename); - return 0; + return 1; } else { @@ -316,7 +316,7 @@ static int _dump_emummc_file_part(emmc_tool_gui_t *gui, char *sd_path, sdmmc_sto free(clmt); f_unlink(outFilename); - return 0; + return 1; } pct = (u64)((u64)(lba_curr - part->lba_start) * 100u) / (u64)(part->lba_end - part->lba_start); if (pct != prevPct) @@ -350,12 +350,12 @@ static int _dump_emummc_file_part(emmc_tool_gui_t *gui, char *sd_path, sdmmc_sto f_close(&fp); free(clmt); - return 1; + return 0; } void dump_emummc_file(emmc_tool_gui_t *gui) { - int res = 0; + int res = 1; int base_len = 0; u32 timer = 0; @@ -432,7 +432,7 @@ void dump_emummc_file(emmc_tool_gui_t *gui) strcat(sdPath, bootPart.name); res = _dump_emummc_file_part(gui, sdPath, &emmc_storage, &bootPart); - if (!res) + if (res) { s_printf(txt_buf, "#FFDD00 Failed!#\n"); goto out_failed; @@ -467,7 +467,7 @@ void dump_emummc_file(emmc_tool_gui_t *gui) res = _dump_emummc_file_part(gui, sdPath, &emmc_storage, &rawPart); - if (!res) + if (res) s_printf(txt_buf, "#FFDD00 Failed!#\n"); else s_printf(txt_buf, "Done!\n"); @@ -479,7 +479,7 @@ out_failed: timer = get_tmr_s() - timer; emmc_end(); - if (res) + if (!res) { s_printf(txt_buf, "Time taken: %dm %ds.\nFinished!", timer / 60, timer % 60); gui->base_path[strlen(gui->base_path) - 5] = '\0'; @@ -543,7 +543,7 @@ static int _dump_emummc_raw_part(emmc_tool_gui_t *gui, int active_part, int part lv_label_ins_text(gui->label_log, LV_LABEL_POS_LAST, gui->txt_buf); manual_system_maintenance(true); - return 0; + return 1; } user_offset = user_part->lba_start; @@ -557,13 +557,13 @@ static int _dump_emummc_raw_part(emmc_tool_gui_t *gui, int active_part, int part // Check for cancellation combo. if (btn_read_vol() == (BTN_VOL_UP | BTN_VOL_DOWN)) { - s_printf(gui->txt_buf, "\n#FFDD00 The emuMMC was cancelled!#\n"); + s_printf(gui->txt_buf, "\n#FFDD00 emuMMC creation was cancelled!#\n"); lv_label_ins_text(gui->label_log, LV_LABEL_POS_LAST, gui->txt_buf); manual_system_maintenance(true); msleep(1000); - return 0; + return 1; } retryCount = 0; @@ -586,7 +586,7 @@ static int _dump_emummc_raw_part(emmc_tool_gui_t *gui, int active_part, int part lv_label_ins_text(gui->label_log, LV_LABEL_POS_LAST, gui->txt_buf); manual_system_maintenance(true); - return 0; + return 1; } else { @@ -616,7 +616,7 @@ static int _dump_emummc_raw_part(emmc_tool_gui_t *gui, int active_part, int part lv_label_ins_text(gui->label_log, LV_LABEL_POS_LAST, gui->txt_buf); manual_system_maintenance(true); - return 0; + return 1; } else { @@ -688,7 +688,7 @@ static int _dump_emummc_raw_part(emmc_tool_gui_t *gui, int active_part, int part s_printf(gui->txt_buf, "#FF0000 Failed (%d)!#\nPlease try again...\n", mkfs_error); lv_label_ins_text(gui->label_log, LV_LABEL_POS_LAST, gui->txt_buf); - return 0; + return 1; } lv_label_ins_text(gui->label_log, LV_LABEL_POS_LAST, "Done!\n"); @@ -720,7 +720,7 @@ static int _dump_emummc_raw_part(emmc_tool_gui_t *gui, int active_part, int part lv_label_ins_text(gui->label_log, LV_LABEL_POS_LAST, gui->txt_buf); free(gpt); - return 0; + return 1; } // Set new emuMMC size and USER size. @@ -761,7 +761,7 @@ static int _dump_emummc_raw_part(emmc_tool_gui_t *gui, int active_part, int part free(gpt); } - return 1; + return 0; } int emummc_raw_derive_bis_keys() @@ -825,7 +825,7 @@ error: void dump_emummc_raw(emmc_tool_gui_t *gui, int part_idx, u32 sector_start, u32 resized_count) { - int res = 0; + int res = 1; u32 timer = 0; char *txt_buf = (char *)malloc(SZ_16K); @@ -896,7 +896,7 @@ void dump_emummc_raw(emmc_tool_gui_t *gui, int part_idx, u32 sector_start, u32 r strcat(sdPath, bootPart.name); res = _dump_emummc_raw_part(gui, i, part_idx, sector_start, &bootPart, 0); - if (!res) + if (res) { s_printf(txt_buf, "#FFDD00 Failed!#\n"); goto out_failed; @@ -930,7 +930,7 @@ void dump_emummc_raw(emmc_tool_gui_t *gui, int part_idx, u32 sector_start, u32 r res = _dump_emummc_raw_part(gui, 2, part_idx, sector_start, &rawPart, resized_count); - if (!res) + if (res) s_printf(txt_buf, "#FFDD00 Failed!#\n"); else s_printf(txt_buf, "Done!\n"); @@ -943,7 +943,7 @@ out_failed: timer = get_tmr_s() - timer; emmc_end(); - if (res) + if (!res) { s_printf(txt_buf, "Time taken: %dm %ds.\nFinished!", timer / 60, timer % 60); strcpy(sdPath, gui->base_path);