mirror of
https://github.com/suchmememanyskill/TegraExplorer.git
synced 2024-11-22 20:06:43 +00:00
[script] add mmc_dumpPart() and mmc_restorePart()
This commit is contained in:
parent
97bbe2a333
commit
7dc3500a17
5 changed files with 85 additions and 16 deletions
|
@ -122,7 +122,7 @@ int dump_emmc_parts(u16 parts, u8 mmctype){
|
||||||
utils_copystring(fsutil_getnextloc(basepath, pkg2names[i]), &path);
|
utils_copystring(fsutil_getnextloc(basepath, pkg2names[i]), &path);
|
||||||
gfx_printf("Dumping %s\n", pkg2names[i]);
|
gfx_printf("Dumping %s\n", pkg2names[i]);
|
||||||
|
|
||||||
dump_emmc_specific(pkg2names[i], path);
|
emmcDumpSpecific(pkg2names[i], path);
|
||||||
free(path);
|
free(path);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -132,7 +132,36 @@ int dump_emmc_parts(u16 parts, u8 mmctype){
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int dump_emmc_specific(char *part, char *path){
|
int emmcDumpBoot(char *basePath){
|
||||||
|
emmc_part_t bootPart;
|
||||||
|
const u32 BOOT_PART_SIZE = storage.ext_csd.boot_mult << 17;
|
||||||
|
char *path;
|
||||||
|
memset(&bootPart, 0, sizeof(emmc_part_t));
|
||||||
|
|
||||||
|
bootPart.lba_start = 0;
|
||||||
|
bootPart.lba_end = (BOOT_PART_SIZE / NX_EMMC_BLOCKSIZE) - 1;
|
||||||
|
|
||||||
|
for (int i = 0; i < 2; i++){
|
||||||
|
strcpy(bootPart.name, "BOOT");
|
||||||
|
bootPart.name[4] = (u8)('0' + i);
|
||||||
|
bootPart.name[5] = 0;
|
||||||
|
|
||||||
|
emummc_storage_set_mmc_partition(&storage, i + 1);
|
||||||
|
utils_copystring(fsutil_getnextloc(basePath, bootPart.name), &path);
|
||||||
|
|
||||||
|
if (!existsCheck(path))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
gfx_printf("Dumping %s\n", bootPart.name);
|
||||||
|
|
||||||
|
dump_emmc_part(path, &storage, &bootPart);
|
||||||
|
free(path);
|
||||||
|
}
|
||||||
|
emummc_storage_set_mmc_partition(&storage, 0);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int emmcDumpSpecific(char *part, char *path){
|
||||||
if (!existsCheck(path))
|
if (!existsCheck(path))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
|
|
@ -103,6 +103,8 @@ int fillMmcMenu(short mmcType){
|
||||||
}
|
}
|
||||||
|
|
||||||
int handleEntries(short mmcType, menu_entry part){
|
int handleEntries(short mmcType, menu_entry part){
|
||||||
|
int res = 0;
|
||||||
|
|
||||||
if (part.property & ISDIR){
|
if (part.property & ISDIR){
|
||||||
if (!mount_mmc(part.name, part.storage))
|
if (!mount_mmc(part.name, part.storage))
|
||||||
fileexplorer("emmc:/", 1);
|
fileexplorer("emmc:/", 1);
|
||||||
|
@ -116,20 +118,22 @@ int handleEntries(short mmcType, menu_entry part){
|
||||||
if ((menu_make(mmcmenu_filemenu, 4, "-- RAW PARTITION --")) < 3)
|
if ((menu_make(mmcmenu_filemenu, 4, "-- RAW PARTITION --")) < 3)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
f_mkdir("sd:/tegraexplorer");
|
||||||
|
f_mkdir("sd:/tegraexplorer/partition_dumps");
|
||||||
|
|
||||||
|
gfx_clearscreen();
|
||||||
|
|
||||||
if (part.property & isBOOT){
|
if (part.property & isBOOT){
|
||||||
dump_emmc_parts(PART_BOOT, (u8)mmcType);
|
res = emmcDumpBoot("sd:/tegraexplorer/partition_dumps");
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
f_mkdir("sd:/tegraexplorer");
|
|
||||||
f_mkdir("sd:/tegraexplorer/partition_dumps");
|
|
||||||
|
|
||||||
gfx_clearscreen();
|
|
||||||
gfx_printf("Dumping %s...\n", part.name);
|
gfx_printf("Dumping %s...\n", part.name);
|
||||||
|
res = emmcDumpSpecific(part.name, fsutil_getnextloc("sd:/tegraexplorer/partition_dumps", part.name));
|
||||||
|
}
|
||||||
|
|
||||||
if (!dump_emmc_specific(part.name, fsutil_getnextloc("sd:/tegraexplorer/partition_dumps", part.name))){
|
if (!res){
|
||||||
gfx_printf("\nDone!");
|
gfx_printf("\nDone!");
|
||||||
btn_wait();
|
btn_wait();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -182,7 +186,6 @@ int mmcFlashFile(char *path, short mmcType){
|
||||||
if (part != NULL){
|
if (part != NULL){
|
||||||
return restore_emmc_part(path, &storage, part);
|
return restore_emmc_part(path, &storage, part);
|
||||||
}
|
}
|
||||||
clipboardhelper = 0;
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -194,6 +197,7 @@ int makeMmcMenu(short mmcType){
|
||||||
selection = menu_make(mmcMenuEntries, count, (mmcType == SYSMMC) ? "-- SYSMMC --" : "-- EMUMMC --");
|
selection = menu_make(mmcMenuEntries, count, (mmcType == SYSMMC) ? "-- SYSMMC --" : "-- EMUMMC --");
|
||||||
|
|
||||||
switch(selection){
|
switch(selection){
|
||||||
|
case -1:
|
||||||
case 0:
|
case 0:
|
||||||
return 0;
|
return 0;
|
||||||
case 1:
|
case 1:
|
||||||
|
@ -203,10 +207,11 @@ int makeMmcMenu(short mmcType){
|
||||||
gfx_printf("\nDone!");
|
gfx_printf("\nDone!");
|
||||||
btn_wait();
|
btn_wait();
|
||||||
}
|
}
|
||||||
|
clipboardhelper = 0;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
gfx_errDisplay("mmcMenu", ERR_EMPTY_CLIPBOARD, 0);
|
gfx_errDisplay("mmcMenu", ERR_EMPTY_CLIPBOARD, 0);
|
||||||
break; //stubbed
|
break;
|
||||||
default:
|
default:
|
||||||
handleEntries(mmcType, mmcMenuEntries[selection]);
|
handleEntries(mmcType, mmcMenuEntries[selection]);
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
int makeMmcMenu(short mmcType);
|
int makeMmcMenu(short mmcType);
|
||||||
|
int mmcFlashFile(char *path, short mmcType);
|
|
@ -4,5 +4,6 @@
|
||||||
|
|
||||||
int dump_emmc_parts(u16 parts, u8 mmctype);
|
int dump_emmc_parts(u16 parts, u8 mmctype);
|
||||||
int restore_bis_using_file(char *path, u8 mmctype);
|
int restore_bis_using_file(char *path, u8 mmctype);
|
||||||
int dump_emmc_specific(char *part, char *path);
|
int emmcDumpSpecific(char *part, char *path);
|
||||||
int restore_emmc_part(char *path, sdmmc_storage_t *mmcstorage, emmc_part_t *part);
|
int restore_emmc_part(char *path, sdmmc_storage_t *mmcstorage, emmc_part_t *part);
|
||||||
|
int emmcDumpBoot(char *basePath);
|
|
@ -19,11 +19,14 @@
|
||||||
#include "../fs/fsutils.h"
|
#include "../fs/fsutils.h"
|
||||||
#include "../../utils/sprintf.h"
|
#include "../../utils/sprintf.h"
|
||||||
#include "../fs/fsactions.h"
|
#include "../fs/fsactions.h"
|
||||||
|
#include "../emmc/emmcoperations.h"
|
||||||
|
#include "../emmc/emmcmenu.h"
|
||||||
|
|
||||||
extern FIL scriptin;
|
extern FIL scriptin;
|
||||||
extern char **argv;
|
extern char **argv;
|
||||||
extern u32 argc;
|
extern u32 argc;
|
||||||
extern int forceExit;
|
extern int forceExit;
|
||||||
|
extern short currentlyMounted;
|
||||||
|
|
||||||
int parseIntInput(char *in, int *out){
|
int parseIntInput(char *in, int *out){
|
||||||
if (in[0] == '@'){
|
if (in[0] == '@'){
|
||||||
|
@ -462,6 +465,34 @@ int part_fs_combinePath(){
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int part_mmc_dumpPart(){
|
||||||
|
char *left, *right;
|
||||||
|
|
||||||
|
if (parseStringInput(argv[0], &left))
|
||||||
|
return -1;
|
||||||
|
if (parseStringInput(argv[1], &right))
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
if (!strcmp(left, "BOOT")){
|
||||||
|
return emmcDumpBoot(right);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return emmcDumpSpecific(left, right);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int part_mmc_restorePart(){
|
||||||
|
char *path;
|
||||||
|
|
||||||
|
if (parseStringInput(argv[0], &path))
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
if (currentlyMounted < 0)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
return mmcFlashFile(path, currentlyMounted);
|
||||||
|
}
|
||||||
|
|
||||||
str_fnc_struct functions[] = {
|
str_fnc_struct functions[] = {
|
||||||
{"printf", part_printf, 1},
|
{"printf", part_printf, 1},
|
||||||
{"printInt", part_print_int, 1},
|
{"printInt", part_print_int, 1},
|
||||||
|
@ -490,6 +521,8 @@ str_fnc_struct functions[] = {
|
||||||
{"fs_combinePath", part_fs_combinePath, 3},
|
{"fs_combinePath", part_fs_combinePath, 3},
|
||||||
{"mmc_connect", part_ConnectMMC, 1},
|
{"mmc_connect", part_ConnectMMC, 1},
|
||||||
{"mmc_mount", part_MountMMC, 1},
|
{"mmc_mount", part_MountMMC, 1},
|
||||||
|
{"mmc_dumpPart", part_mmc_dumpPart, 2},
|
||||||
|
{"mmc_restorePart", part_mmc_restorePart, 1},
|
||||||
{"pause", part_Pause, 0},
|
{"pause", part_Pause, 0},
|
||||||
{"wait", part_Wait, 1},
|
{"wait", part_Wait, 1},
|
||||||
{"exit", part_Exit, 0},
|
{"exit", part_Exit, 0},
|
||||||
|
|
Loading…
Reference in a new issue