1
0
Fork 0
mirror of https://github.com/suchmememanyskill/TegraExplorer.git synced 2024-11-29 07:12:04 +00:00

Speed up copy & formats

This commit is contained in:
Such Meme, Many Skill 2020-05-04 20:30:51 +02:00
parent 9799e2b47e
commit a9ea9725d4
6 changed files with 57 additions and 30 deletions

View file

@ -5629,7 +5629,8 @@ FRESULT f_forward (
}
#endif /* FF_USE_FORWARD */
#pragma GCC push_options
#pragma GCC optimize ("Os")
#if FF_USE_MKFS && !FF_FS_READONLY
/*-----------------------------------------------------------------------*/
@ -6094,7 +6095,7 @@ FRESULT f_mkfs (
LEAVE_MKFS(FR_OK);
}
#pragma GCC pop_options
#if FF_MULTI_PARTITION
/*-----------------------------------------------------------------------*/

View file

@ -23,7 +23,7 @@
#define COPY_MODE_PRINT 0x1
#define COPY_MODE_CANCEL 0x2
#define BUFSIZE 32768
#define BUFSIZE 65536 //32768
#define OPERATIONCOPY 0x2
#define OPERATIONMOVE 0x4

View file

@ -45,7 +45,7 @@ int emmcDumpPart(char *path, sdmmc_storage_t *mmcstorage, emmc_part_t *part){
f_lseek(&fp, 0);
while (totalSectors > 0){
num = MIN(totalSectors, 64);
num = MIN(totalSectors, 128);
if (!emummc_storage_read(mmcstorage, lba_curr, num, buf)){
gfx_errDisplay("dump_emmc_part", ERR_EMMC_READ_FAILED, 3);
return -1;

View file

@ -32,7 +32,7 @@ int emmcRestorePart(char *path, sdmmc_storage_t *mmcstorage, emmc_part_t *part){
gfx_printf("Initializing\r");
buf = calloc(16384, sizeof(u8));
buf = calloc(BUFSIZE, sizeof(u8));
if (!buf){
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){
num = MIN(totalSectors, 32);
num = MIN(totalSectors, 128);
if ((res = f_read(&fp, buf, num * NX_EMMC_BLOCKSIZE, NULL))){
gfx_errDisplay("restore_emmc_part", res, 5);

View file

@ -8,15 +8,16 @@
#include "../utils/utils.h"
#include "../../mem/heap.h"
#include "../../hid/hid.h"
#include "../../utils/btn.h"
#include "fsutils.h"
int fsact_copy(const char *locin, const char *locout, u8 options){
FIL in, out;
FILINFO in_info;
u64 sizeoffile, sizecopied = 0, totalsize;
u64 sizeRemaining, toCopy;
UINT temp1, temp2;
u8 *buff;
unsigned int x, y, i = 0;
u8 *buff, toPrint = options & COPY_MODE_PRINT, toCancel = options & COPY_MODE_CANCEL;
u32 x, y, i = 11;
int res;
gfx_con_getpos(&x, &y);
@ -41,17 +42,26 @@ int fsact_copy(const char *locin, const char *locout, u8 options){
return 1;
}
buff = malloc (BUFSIZE);
sizeoffile = f_size(&in);
totalsize = sizeoffile;
if (toPrint){
SWAPCOLOR(COLOR_GREEN);
gfx_printf("[ ]");
x += 16;
gfx_con_setpos(x, y);
}
while (sizeoffile > 0){
if ((res = f_read(&in, buff, (sizeoffile > BUFSIZE) ? BUFSIZE : sizeoffile, &temp1))){
buff = malloc (BUFSIZE);
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);
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);
return 1;
}
@ -61,22 +71,27 @@ int fsact_copy(const char *locin, const char *locout, u8 options){
return 1;
}
sizeoffile -= temp1;
sizecopied += temp1;
sizeRemaining -= toCopy;
if (options & COPY_MODE_PRINT && 10 > i++){
gfx_printf("%k[%d%%]%k", COLOR_GREEN, ((sizecopied * 100) / totalsize) ,COLOR_WHITE);
if (toPrint && (i > 16 || !sizeRemaining)){
gfx_printf("%3d%%", (u32)(((totalsize - sizeRemaining) * 100) / totalsize));
gfx_con_setpos(x, y);
}
i = 0;
if (options & COPY_MODE_CANCEL)
if (hidRead()->buttons & (KEY_VOLP | KEY_VOLM)){
if (toCancel && i > 16){
if (btn_read() & (BTN_VOL_DOWN | BTN_VOL_UP)){
f_unlink(locout);
break;
}
}
if (options){
if (i++ > 16)
i = 0;
}
}
RESETCOLOR;
f_close(&in);
f_close(&out);

View file

@ -185,9 +185,9 @@ int format(int mode){
gfx_clearscreen();
int res;
bool fatalerror = false;
DWORD plist[] = {666, 61145088};
DWORD plist[] = {666, 61145088, 0, 0};
u32 timer, totalsectors, alignedsectors, extrasectors;
BYTE work[FF_MAX_SS];
u8 *work;
DWORD clustsize = 32768;
BYTE formatoptions = 0;
formatoptions |= (FM_FAT32);
@ -198,6 +198,15 @@ int format(int mode){
timer = get_tmr_s();
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 (totalsectors < 83886080){
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){
gfx_printf("\nPartitioning SD...\n");
res = f_fdisk(0, plist, &work);
res = f_fdisk(0, plist, work);
if (res){
gfx_printf("%kf_fdisk returned %d!\n", COLOR_RED, res);
@ -231,7 +240,7 @@ int format(int mode){
if (!fatalerror){
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){
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");
}
free(work);
sd_unmount();
if (!fatalerror){