remove prints, fix backup/restore
This commit is contained in:
@@ -41,8 +41,8 @@
|
|||||||
#include <storage/mbr_gpt.h>
|
#include <storage/mbr_gpt.h>
|
||||||
#include <gfx_utils.h>
|
#include <gfx_utils.h>
|
||||||
|
|
||||||
#define EFSPRINTF(text, ...) print_error(); gfx_printf("%k"text"%k\n", 0xFFFFFF00, 0xFFFFFFFF);
|
// #define EFSPRINTF(text, ...) print_error(); gfx_printf("%k"text"%k\n", 0xFFFFFF00, 0xFFFFFFFF);
|
||||||
//#define EFSPRINTF(...)
|
#define EFSPRINTF(...)
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------
|
/*--------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|||||||
@@ -121,15 +121,12 @@ static bool _boot_storage_mount(){
|
|||||||
for(BYTE i = 0; i < ARRAY_SIZE(emmc_drives); i++){
|
for(BYTE i = 0; i < ARRAY_SIZE(emmc_drives); i++){
|
||||||
res = f_mount(&boot_storage_fs, drive_base_paths[emmc_drives[i]], true);
|
res = f_mount(&boot_storage_fs, drive_base_paths[emmc_drives[i]], true);
|
||||||
if(res == FR_OK){
|
if(res == FR_OK){
|
||||||
gfx_printf("trying %s\n", drive_base_paths[emmc_drives[i]]);
|
|
||||||
res = f_chdrive(drive_base_paths[emmc_drives[i]]);
|
res = f_chdrive(drive_base_paths[emmc_drives[i]]);
|
||||||
if(res == FR_OK && _is_eligible()){
|
if(res == FR_OK && _is_eligible()){
|
||||||
gfx_printf("%s ok\n", drive_base_paths[emmc_drives[i]]);
|
|
||||||
drive_cur = emmc_drives[i];
|
drive_cur = emmc_drives[i];
|
||||||
drive = drive_cur;
|
drive = drive_cur;
|
||||||
break;
|
break;
|
||||||
}else{
|
}else{
|
||||||
gfx_printf("%s fail\n", drive_base_paths[emmc_drives[i]]);
|
|
||||||
f_mount(NULL, drive_base_paths[emmc_drives[i]],false);
|
f_mount(NULL, drive_base_paths[emmc_drives[i]],false);
|
||||||
res = FR_INVALID_DRIVE;
|
res = FR_INVALID_DRIVE;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,6 @@
|
|||||||
#include <libs/fatfs/ff.h>
|
#include <libs/fatfs/ff.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include "gfx_utils.h"
|
|
||||||
|
|
||||||
typedef struct{
|
typedef struct{
|
||||||
FIL active_file;
|
FIL active_file;
|
||||||
@@ -21,8 +20,6 @@ int file_based_storage_init(const char *base_path) {
|
|||||||
strcpy(ctx.base_path, base_path);
|
strcpy(ctx.base_path, base_path);
|
||||||
strcat(ctx.base_path, "00");
|
strcat(ctx.base_path, "00");
|
||||||
|
|
||||||
gfx_printf("file based init %d %s\n", ctx.base_path_len, ctx.base_path);
|
|
||||||
|
|
||||||
FILINFO fi;
|
FILINFO fi;
|
||||||
if(f_stat(ctx.base_path, &fi) != FR_OK) {
|
if(f_stat(ctx.base_path, &fi) != FR_OK) {
|
||||||
return 0;
|
return 0;
|
||||||
@@ -30,7 +27,6 @@ int file_based_storage_init(const char *base_path) {
|
|||||||
|
|
||||||
if(fi.fsize) {
|
if(fi.fsize) {
|
||||||
ctx.part_sz_sct = fi.fsize >> 9;
|
ctx.part_sz_sct = fi.fsize >> 9;
|
||||||
gfx_printf("file based init sz 0x%x\n", ctx.part_sz_sct);
|
|
||||||
}else{
|
}else{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -67,7 +63,6 @@ static int file_based_storage_change_file(const char *name, s32 idx) {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
if(res != FR_OK){
|
if(res != FR_OK){
|
||||||
gfx_printf("file based open fail %s\n", ctx.base_path);
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -95,7 +90,6 @@ static int file_based_storage_readwrite_single(u32 sector, u32 num_sectors, void
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(res != FR_OK){
|
if(res != FR_OK){
|
||||||
gfx_printf("file based rw fail %s 0x%x 0x%x \n", ctx.base_path, num_sectors, sector);
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -94,14 +94,10 @@ bool emusd_set_path(char *path) {
|
|||||||
strcat(emu_sd_cfg.emummc_file_based_path, "");
|
strcat(emu_sd_cfg.emummc_file_based_path, "");
|
||||||
strcpy(emu_sd_cfg.emummc_file_based_path, path);
|
strcpy(emu_sd_cfg.emummc_file_based_path, path);
|
||||||
strcat(emu_sd_cfg.emummc_file_based_path, "/raw_emmc_based");
|
strcat(emu_sd_cfg.emummc_file_based_path, "/raw_emmc_based");
|
||||||
gfx_printf("1 %s \n", emu_sd_cfg.emummc_file_based_path);
|
|
||||||
if(!f_open(&fp, emu_sd_cfg.emummc_file_based_path, FA_READ))
|
if(!f_open(&fp, emu_sd_cfg.emummc_file_based_path, FA_READ))
|
||||||
{
|
{
|
||||||
gfx_printf("open done\n");
|
|
||||||
if(!f_read(&fp, &emu_sd_cfg.sector, 4, NULL)){
|
if(!f_read(&fp, &emu_sd_cfg.sector, 4, NULL)){
|
||||||
gfx_printf("found sct\n");
|
|
||||||
if(emu_sd_cfg.sector){
|
if(emu_sd_cfg.sector){
|
||||||
gfx_printf("!=0\n");
|
|
||||||
found = true;
|
found = true;
|
||||||
emu_sd_cfg.enabled = 4;
|
emu_sd_cfg.enabled = 4;
|
||||||
goto out;
|
goto out;
|
||||||
@@ -112,14 +108,10 @@ bool emusd_set_path(char *path) {
|
|||||||
strcpy(emu_sd_cfg.emummc_file_based_path, "");
|
strcpy(emu_sd_cfg.emummc_file_based_path, "");
|
||||||
strcat(emu_sd_cfg.emummc_file_based_path, path);
|
strcat(emu_sd_cfg.emummc_file_based_path, path);
|
||||||
strcat(emu_sd_cfg.emummc_file_based_path, "/raw_emmc_based");
|
strcat(emu_sd_cfg.emummc_file_based_path, "/raw_emmc_based");
|
||||||
gfx_printf("1 %s \n", emu_sd_cfg.emummc_file_based_path);
|
|
||||||
if (!f_open(&fp, emu_sd_cfg.emummc_file_based_path, FA_READ))
|
if (!f_open(&fp, emu_sd_cfg.emummc_file_based_path, FA_READ))
|
||||||
{
|
{
|
||||||
gfx_printf("open done\n");
|
|
||||||
if (!f_read(&fp, &emu_sd_cfg.sector, 4, NULL)){
|
if (!f_read(&fp, &emu_sd_cfg.sector, 4, NULL)){
|
||||||
gfx_printf("found sct\n");
|
|
||||||
if (emu_sd_cfg.sector){
|
if (emu_sd_cfg.sector){
|
||||||
gfx_printf("!=0\n");
|
|
||||||
found = true;
|
found = true;
|
||||||
emu_sd_cfg.enabled = 4;
|
emu_sd_cfg.enabled = 4;
|
||||||
goto out;
|
goto out;
|
||||||
@@ -131,15 +123,12 @@ bool emusd_set_path(char *path) {
|
|||||||
strcpy(emu_sd_cfg.emummc_file_based_path, "");
|
strcpy(emu_sd_cfg.emummc_file_based_path, "");
|
||||||
strcat(emu_sd_cfg.emummc_file_based_path, path);
|
strcat(emu_sd_cfg.emummc_file_based_path, path);
|
||||||
strcat(emu_sd_cfg.emummc_file_based_path, "/file_based");
|
strcat(emu_sd_cfg.emummc_file_based_path, "/file_based");
|
||||||
gfx_printf("1 %s \n", emu_sd_cfg.emummc_file_based_path);
|
|
||||||
if (!f_stat(emu_sd_cfg.emummc_file_based_path, NULL))
|
if (!f_stat(emu_sd_cfg.emummc_file_based_path, NULL))
|
||||||
{
|
{
|
||||||
gfx_printf("open done\n");
|
|
||||||
emu_sd_cfg.sector = 0;
|
emu_sd_cfg.sector = 0;
|
||||||
emu_sd_cfg.path = path;
|
emu_sd_cfg.path = path;
|
||||||
emu_sd_cfg.enabled = 1;
|
emu_sd_cfg.enabled = 1;
|
||||||
|
|
||||||
gfx_printf("path %s\n", emu_sd_cfg.path);
|
|
||||||
found = true;
|
found = true;
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
@@ -148,15 +137,12 @@ bool emusd_set_path(char *path) {
|
|||||||
strcpy(emu_sd_cfg.emummc_file_based_path, "");
|
strcpy(emu_sd_cfg.emummc_file_based_path, "");
|
||||||
strcat(emu_sd_cfg.emummc_file_based_path, path);
|
strcat(emu_sd_cfg.emummc_file_based_path, path);
|
||||||
strcat(emu_sd_cfg.emummc_file_based_path, "/file_emmc_based");
|
strcat(emu_sd_cfg.emummc_file_based_path, "/file_emmc_based");
|
||||||
gfx_printf("1 %s \n", emu_sd_cfg.emummc_file_based_path);
|
|
||||||
if (!f_stat(emu_sd_cfg.emummc_file_based_path, NULL))
|
if (!f_stat(emu_sd_cfg.emummc_file_based_path, NULL))
|
||||||
{
|
{
|
||||||
gfx_printf("open done\n");
|
|
||||||
emu_sd_cfg.sector = 0;
|
emu_sd_cfg.sector = 0;
|
||||||
emu_sd_cfg.path = path;
|
emu_sd_cfg.path = path;
|
||||||
emu_sd_cfg.enabled = 4;
|
emu_sd_cfg.enabled = 4;
|
||||||
|
|
||||||
gfx_printf("path %s\n", emu_sd_cfg.path);
|
|
||||||
found = true;
|
found = true;
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -222,7 +222,7 @@ static int _stat_and_copy_files(const char *src, const char *dst, char *path, u3
|
|||||||
u32 dirLength = 0;
|
u32 dirLength = 0;
|
||||||
static FILINFO fno;
|
static FILINFO fno;
|
||||||
|
|
||||||
DBG_PRINT_ARGS("chdrive %d", f_chdrive(src));
|
f_chdrive(src);
|
||||||
|
|
||||||
// Open directory.
|
// Open directory.
|
||||||
res = f_opendir(&dir, path);
|
res = f_opendir(&dir, path);
|
||||||
@@ -287,9 +287,9 @@ static int _stat_and_copy_files(const char *src, const char *dst, char *path, u3
|
|||||||
|
|
||||||
// Open file for writing.
|
// Open file for writing.
|
||||||
f_chdrive(dst);
|
f_chdrive(dst);
|
||||||
DBG_PRINT_ARGS("open %d", f_open(&fp_dst, path, FA_CREATE_ALWAYS | FA_WRITE));
|
f_open(&fp_dst, path, FA_CREATE_ALWAYS | FA_WRITE);
|
||||||
DBG_PRINT_ARGS("seek1 %d", f_lseek(&fp_dst, fno.fsize));
|
f_lseek(&fp_dst, fno.fsize);
|
||||||
DBG_PRINT_ARGS("seek2 %d", f_lseek(&fp_dst, 0));
|
f_lseek(&fp_dst, 0);
|
||||||
|
|
||||||
// Open file for reading.
|
// Open file for reading.
|
||||||
f_chdrive(src);
|
f_chdrive(src);
|
||||||
@@ -1793,8 +1793,11 @@ static int _backup_and_restore_files(bool backup, const char *drive, lv_obj_t **
|
|||||||
|
|
||||||
// Copy all or hekate/Nyx files.
|
// Copy all or hekate/Nyx files.
|
||||||
DBG_PRINT("start stat");
|
DBG_PRINT("start stat");
|
||||||
|
gfx_printf("src %s\ndst %s\npath %s\n", src_drv, dst_drv, path);
|
||||||
res = _stat_and_copy_files(src_drv, dst_drv, path, &total_files, &total_size, labels);
|
res = _stat_and_copy_files(src_drv, dst_drv, path, &total_files, &total_size, labels);
|
||||||
|
|
||||||
|
gfx_printf("bkup res %d mws %d pld %d tot %d\n", res, (u32)backup_mws, (u32)backup_pld, total_files);
|
||||||
|
|
||||||
// If incomplete backup mode, copy MWS and payload.bin also.
|
// If incomplete backup mode, copy MWS and payload.bin also.
|
||||||
if (!res)
|
if (!res)
|
||||||
{
|
{
|
||||||
@@ -1998,8 +2001,6 @@ static lv_res_t _create_mbox_start_partitioning(lv_obj_t *btn)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
DBG_PRINT("backup done");
|
|
||||||
|
|
||||||
if(part_info.drive == DRIVE_SD){
|
if(part_info.drive == DRIVE_SD){
|
||||||
sd_unmount();
|
sd_unmount();
|
||||||
}else{
|
}else{
|
||||||
@@ -2041,7 +2042,6 @@ static lv_res_t _create_mbox_start_partitioning(lv_obj_t *btn)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
lv_label_set_text(lbl_status, "#00ddff Status:# Formatting FAT32 partition...");
|
lv_label_set_text(lbl_status, "#00ddff Status:# Formatting FAT32 partition...");
|
||||||
manual_system_maintenance(true);
|
manual_system_maintenance(true);
|
||||||
|
|
||||||
@@ -2095,10 +2095,11 @@ static lv_res_t _create_mbox_start_partitioning(lv_obj_t *btn)
|
|||||||
if(part_info.drive == DRIVE_SD){
|
if(part_info.drive == DRIVE_SD){
|
||||||
sd_mount();
|
sd_mount();
|
||||||
}else{
|
}else{
|
||||||
DBG_PRINT_ARGS("emmc mount %d", emmc_mount());
|
emmc_mount();
|
||||||
}
|
}
|
||||||
|
|
||||||
f_setlabel(part_info.drive == DRIVE_SD ? "sd:SWITCH SD" : "emmc:SWITCH EMMC");
|
int res = f_setlabel(part_info.drive == DRIVE_SD ? "sd:SWITCH SD" : "emmc:SWITCH EMMC");
|
||||||
|
gfx_printf("setlabel %d\n", res);
|
||||||
|
|
||||||
if(boot_storage_get_drive() != part_info.drive){
|
if(boot_storage_get_drive() != part_info.drive){
|
||||||
// if we havent booted from the drive currently being formatted, create .no_boot_storage
|
// if we havent booted from the drive currently being formatted, create .no_boot_storage
|
||||||
|
|||||||
Reference in New Issue
Block a user