mirror of
https://github.com/suchmememanyskill/TegraExplorer.git
synced 2024-11-25 21:32:08 +00:00
Speed up copy & formats
This commit is contained in:
parent
9799e2b47e
commit
a9ea9725d4
6 changed files with 57 additions and 30 deletions
|
@ -5629,7 +5629,8 @@ FRESULT f_forward (
|
||||||
}
|
}
|
||||||
#endif /* FF_USE_FORWARD */
|
#endif /* FF_USE_FORWARD */
|
||||||
|
|
||||||
|
#pragma GCC push_options
|
||||||
|
#pragma GCC optimize ("Os")
|
||||||
|
|
||||||
#if FF_USE_MKFS && !FF_FS_READONLY
|
#if FF_USE_MKFS && !FF_FS_READONLY
|
||||||
/*-----------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------*/
|
||||||
|
@ -6094,7 +6095,7 @@ FRESULT f_mkfs (
|
||||||
LEAVE_MKFS(FR_OK);
|
LEAVE_MKFS(FR_OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#pragma GCC pop_options
|
||||||
|
|
||||||
#if FF_MULTI_PARTITION
|
#if FF_MULTI_PARTITION
|
||||||
/*-----------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------*/
|
||||||
|
|
|
@ -23,7 +23,7 @@
|
||||||
|
|
||||||
#define COPY_MODE_PRINT 0x1
|
#define COPY_MODE_PRINT 0x1
|
||||||
#define COPY_MODE_CANCEL 0x2
|
#define COPY_MODE_CANCEL 0x2
|
||||||
#define BUFSIZE 32768
|
#define BUFSIZE 65536 //32768
|
||||||
|
|
||||||
#define OPERATIONCOPY 0x2
|
#define OPERATIONCOPY 0x2
|
||||||
#define OPERATIONMOVE 0x4
|
#define OPERATIONMOVE 0x4
|
||||||
|
|
|
@ -45,7 +45,7 @@ int emmcDumpPart(char *path, sdmmc_storage_t *mmcstorage, emmc_part_t *part){
|
||||||
f_lseek(&fp, 0);
|
f_lseek(&fp, 0);
|
||||||
|
|
||||||
while (totalSectors > 0){
|
while (totalSectors > 0){
|
||||||
num = MIN(totalSectors, 64);
|
num = MIN(totalSectors, 128);
|
||||||
if (!emummc_storage_read(mmcstorage, lba_curr, num, buf)){
|
if (!emummc_storage_read(mmcstorage, lba_curr, num, buf)){
|
||||||
gfx_errDisplay("dump_emmc_part", ERR_EMMC_READ_FAILED, 3);
|
gfx_errDisplay("dump_emmc_part", ERR_EMMC_READ_FAILED, 3);
|
||||||
return -1;
|
return -1;
|
||||||
|
|
|
@ -32,7 +32,7 @@ int emmcRestorePart(char *path, sdmmc_storage_t *mmcstorage, emmc_part_t *part){
|
||||||
|
|
||||||
gfx_printf("Initializing\r");
|
gfx_printf("Initializing\r");
|
||||||
|
|
||||||
buf = calloc(16384, sizeof(u8));
|
buf = calloc(BUFSIZE, sizeof(u8));
|
||||||
|
|
||||||
if (!buf){
|
if (!buf){
|
||||||
gfx_errDisplay("restore_emmc_part", ERR_MEM_ALLOC_FAILED, 1);
|
gfx_errDisplay("restore_emmc_part", ERR_MEM_ALLOC_FAILED, 1);
|
||||||
|
@ -78,7 +78,7 @@ int emmcRestorePart(char *path, sdmmc_storage_t *mmcstorage, emmc_part_t *part){
|
||||||
}
|
}
|
||||||
|
|
||||||
while (totalSectors > 0){
|
while (totalSectors > 0){
|
||||||
num = MIN(totalSectors, 32);
|
num = MIN(totalSectors, 128);
|
||||||
|
|
||||||
if ((res = f_read(&fp, buf, num * NX_EMMC_BLOCKSIZE, NULL))){
|
if ((res = f_read(&fp, buf, num * NX_EMMC_BLOCKSIZE, NULL))){
|
||||||
gfx_errDisplay("restore_emmc_part", res, 5);
|
gfx_errDisplay("restore_emmc_part", res, 5);
|
||||||
|
|
|
@ -8,15 +8,16 @@
|
||||||
#include "../utils/utils.h"
|
#include "../utils/utils.h"
|
||||||
#include "../../mem/heap.h"
|
#include "../../mem/heap.h"
|
||||||
#include "../../hid/hid.h"
|
#include "../../hid/hid.h"
|
||||||
|
#include "../../utils/btn.h"
|
||||||
#include "fsutils.h"
|
#include "fsutils.h"
|
||||||
|
|
||||||
int fsact_copy(const char *locin, const char *locout, u8 options){
|
int fsact_copy(const char *locin, const char *locout, u8 options){
|
||||||
FIL in, out;
|
FIL in, out;
|
||||||
FILINFO in_info;
|
FILINFO in_info;
|
||||||
u64 sizeoffile, sizecopied = 0, totalsize;
|
u64 sizeRemaining, toCopy;
|
||||||
UINT temp1, temp2;
|
UINT temp1, temp2;
|
||||||
u8 *buff;
|
u8 *buff, toPrint = options & COPY_MODE_PRINT, toCancel = options & COPY_MODE_CANCEL;
|
||||||
unsigned int x, y, i = 0;
|
u32 x, y, i = 11;
|
||||||
int res;
|
int res;
|
||||||
|
|
||||||
gfx_con_getpos(&x, &y);
|
gfx_con_getpos(&x, &y);
|
||||||
|
@ -41,17 +42,26 @@ int fsact_copy(const char *locin, const char *locout, u8 options){
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
buff = malloc (BUFSIZE);
|
if (toPrint){
|
||||||
sizeoffile = f_size(&in);
|
SWAPCOLOR(COLOR_GREEN);
|
||||||
totalsize = sizeoffile;
|
gfx_printf("[ ]");
|
||||||
|
x += 16;
|
||||||
|
gfx_con_setpos(x, y);
|
||||||
|
}
|
||||||
|
|
||||||
while (sizeoffile > 0){
|
buff = malloc (BUFSIZE);
|
||||||
if ((res = f_read(&in, buff, (sizeoffile > BUFSIZE) ? BUFSIZE : sizeoffile, &temp1))){
|
sizeRemaining = f_size(&in);
|
||||||
|
const u64 totalsize = sizeRemaining;
|
||||||
|
|
||||||
|
while (sizeRemaining > 0){
|
||||||
|
toCopy = MIN(sizeRemaining, BUFSIZE);
|
||||||
|
|
||||||
|
if ((res = f_read(&in, buff, toCopy, &temp1))){
|
||||||
gfx_errDisplay("copy", res, 5);
|
gfx_errDisplay("copy", res, 5);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((res = f_write(&out, buff, (sizeoffile > BUFSIZE) ? BUFSIZE : sizeoffile, &temp2))){
|
if ((res = f_write(&out, buff, toCopy, &temp2))){
|
||||||
gfx_errDisplay("copy", res, 6);
|
gfx_errDisplay("copy", res, 6);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
@ -61,23 +71,28 @@ int fsact_copy(const char *locin, const char *locout, u8 options){
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
sizeoffile -= temp1;
|
sizeRemaining -= toCopy;
|
||||||
sizecopied += temp1;
|
|
||||||
|
|
||||||
if (options & COPY_MODE_PRINT && 10 > i++){
|
if (toPrint && (i > 16 || !sizeRemaining)){
|
||||||
gfx_printf("%k[%d%%]%k", COLOR_GREEN, ((sizecopied * 100) / totalsize) ,COLOR_WHITE);
|
gfx_printf("%3d%%", (u32)(((totalsize - sizeRemaining) * 100) / totalsize));
|
||||||
gfx_con_setpos(x, y);
|
gfx_con_setpos(x, y);
|
||||||
|
}
|
||||||
i = 0;
|
|
||||||
|
|
||||||
if (options & COPY_MODE_CANCEL)
|
if (toCancel && i > 16){
|
||||||
if (hidRead()->buttons & (KEY_VOLP | KEY_VOLM)){
|
if (btn_read() & (BTN_VOL_DOWN | BTN_VOL_UP)){
|
||||||
f_unlink(locout);
|
f_unlink(locout);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (options){
|
||||||
|
if (i++ > 16)
|
||||||
|
i = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
RESETCOLOR;
|
||||||
|
|
||||||
f_close(&in);
|
f_close(&in);
|
||||||
f_close(&out);
|
f_close(&out);
|
||||||
free(buff);
|
free(buff);
|
||||||
|
|
|
@ -185,9 +185,9 @@ int format(int mode){
|
||||||
gfx_clearscreen();
|
gfx_clearscreen();
|
||||||
int res;
|
int res;
|
||||||
bool fatalerror = false;
|
bool fatalerror = false;
|
||||||
DWORD plist[] = {666, 61145088};
|
DWORD plist[] = {666, 61145088, 0, 0};
|
||||||
u32 timer, totalsectors, alignedsectors, extrasectors;
|
u32 timer, totalsectors, alignedsectors, extrasectors;
|
||||||
BYTE work[FF_MAX_SS];
|
u8 *work;
|
||||||
DWORD clustsize = 32768;
|
DWORD clustsize = 32768;
|
||||||
BYTE formatoptions = 0;
|
BYTE formatoptions = 0;
|
||||||
formatoptions |= (FM_FAT32);
|
formatoptions |= (FM_FAT32);
|
||||||
|
@ -198,6 +198,15 @@ int format(int mode){
|
||||||
timer = get_tmr_s();
|
timer = get_tmr_s();
|
||||||
totalsectors = sd_storage.csd.capacity;
|
totalsectors = sd_storage.csd.capacity;
|
||||||
|
|
||||||
|
gfx_printf("Initializing...\n");
|
||||||
|
|
||||||
|
work = calloc(BUFSIZE, sizeof(BYTE));
|
||||||
|
|
||||||
|
if (work == NULL){
|
||||||
|
gfx_errDisplay("format", ERR_MEM_ALLOC_FAILED, 0);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
if (mode == FORMAT_EMUMMC){
|
if (mode == FORMAT_EMUMMC){
|
||||||
if (totalsectors < 83886080){
|
if (totalsectors < 83886080){
|
||||||
gfx_printf("%kYou seem to be running this on a <=32GB SD\nNot enough free space for emummc!", COLOR_RED);
|
gfx_printf("%kYou seem to be running this on a <=32GB SD\nNot enough free space for emummc!", COLOR_RED);
|
||||||
|
@ -219,7 +228,7 @@ int format(int mode){
|
||||||
|
|
||||||
if (!fatalerror){
|
if (!fatalerror){
|
||||||
gfx_printf("\nPartitioning SD...\n");
|
gfx_printf("\nPartitioning SD...\n");
|
||||||
res = f_fdisk(0, plist, &work);
|
res = f_fdisk(0, plist, work);
|
||||||
|
|
||||||
if (res){
|
if (res){
|
||||||
gfx_printf("%kf_fdisk returned %d!\n", COLOR_RED, res);
|
gfx_printf("%kf_fdisk returned %d!\n", COLOR_RED, res);
|
||||||
|
@ -231,7 +240,7 @@ int format(int mode){
|
||||||
|
|
||||||
if (!fatalerror){
|
if (!fatalerror){
|
||||||
gfx_printf("\n\nFormatting Partition1...\n");
|
gfx_printf("\n\nFormatting Partition1...\n");
|
||||||
res = f_mkfs("0:", formatoptions, clustsize, &work, sizeof work);
|
res = f_mkfs("0:", formatoptions, clustsize, work, BUFSIZE * sizeof(BYTE));
|
||||||
|
|
||||||
if (res){
|
if (res){
|
||||||
gfx_printf("%kf_mkfs returned %d!\n", COLOR_RED, res);
|
gfx_printf("%kf_mkfs returned %d!\n", COLOR_RED, res);
|
||||||
|
@ -241,6 +250,8 @@ int format(int mode){
|
||||||
gfx_printf("Smells like a formatted SD\n\n");
|
gfx_printf("Smells like a formatted SD\n\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
free(work);
|
||||||
|
|
||||||
sd_unmount();
|
sd_unmount();
|
||||||
|
|
||||||
if (!fatalerror){
|
if (!fatalerror){
|
||||||
|
|
Loading…
Reference in a new issue