mirror of
https://github.com/suchmememanyskill/TegraExplorer.git
synced 2024-11-22 20:06:43 +00:00
cleanup of mmc restores/dumps
This commit is contained in:
parent
c2a2694baf
commit
6551930233
11 changed files with 110 additions and 100 deletions
|
@ -85,8 +85,7 @@ enum fs_menu_file_return {
|
|||
FILE_PAYLOAD,
|
||||
FILE_SCRIPT,
|
||||
FILE_HEXVIEW,
|
||||
FILE_DUMPBIS,
|
||||
FILE_RESTOREBIS
|
||||
FILE_DUMPBIS
|
||||
};
|
||||
|
||||
extern menu_entry fs_menu_file[];
|
||||
|
|
|
@ -52,8 +52,7 @@ menu_entry fs_menu_file[] = {
|
|||
{"Launch Payload", COLOR_ORANGE, ISMENU},
|
||||
{"Launch Script", COLOR_YELLOW, ISMENU},
|
||||
{"View Hex", COLOR_GREEN, ISMENU},
|
||||
{"\nExtract BIS", COLOR_YELLOW, ISMENU},
|
||||
{"Restore BIS", COLOR_RED, ISMENU}
|
||||
{"\nExtract BIS", COLOR_YELLOW, ISMENU}
|
||||
};
|
||||
|
||||
menu_entry fs_menu_folder[] = {
|
||||
|
|
|
@ -241,3 +241,11 @@ link_t *selectGpt(short mmcType){
|
|||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int checkGptRules(char *in){
|
||||
for (int i = 0; gpt_fs_rules[i].name != NULL; i++){
|
||||
if (!strcmp(in, gpt_fs_rules[i].name))
|
||||
return gpt_fs_rules[i].property;
|
||||
}
|
||||
return 0;
|
||||
}
|
|
@ -18,6 +18,7 @@ void disconnect_mmc();
|
|||
int connect_part(const char *partition);
|
||||
void dumpEmuGpt();
|
||||
link_t *selectGpt(short mmcType);
|
||||
int checkGptRules(char *in);
|
||||
|
||||
static const u8 zeros[0x10] = {0};
|
||||
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
extern sdmmc_storage_t storage;
|
||||
extern emmc_part_t *system_part;
|
||||
|
||||
int dump_emmc_part(char *path, sdmmc_storage_t *mmcstorage, emmc_part_t *part){
|
||||
int emmcDumpPart(char *path, sdmmc_storage_t *mmcstorage, emmc_part_t *part){
|
||||
FIL fp;
|
||||
u8 *buf;
|
||||
u32 lba_curr = part->lba_start;
|
||||
|
@ -158,7 +158,7 @@ int emmcDumpBoot(char *basePath){
|
|||
gfx_printf("Dumping %s\n", bootPart.name);
|
||||
RESETCOLOR;
|
||||
|
||||
dump_emmc_part(path, &storage, &bootPart);
|
||||
emmcDumpPart(path, &storage, &bootPart);
|
||||
free(path);
|
||||
}
|
||||
emummc_storage_set_mmc_partition(&storage, 0);
|
||||
|
@ -178,7 +178,7 @@ int emmcDumpSpecific(char *part, char *path){
|
|||
SWAPCOLOR(COLOR_VIOLET);
|
||||
gfx_printf("Dumping %s\n", part);
|
||||
RESETCOLOR;
|
||||
dump_emmc_part(path, &storage, system_part);
|
||||
emmcDumpPart(path, &storage, system_part);
|
||||
|
||||
return 0;
|
||||
}
|
|
@ -3,21 +3,12 @@
|
|||
#include "../../mem/heap.h"
|
||||
#include "../../utils/types.h"
|
||||
#include "../../libs/fatfs/ff.h"
|
||||
#include "../../utils/sprintf.h"
|
||||
#include "../../utils/btn.h"
|
||||
#include "../../gfx/gfx.h"
|
||||
#include "../../utils/util.h"
|
||||
#include "../../hos/pkg1.h"
|
||||
#include "../../storage/sdmmc.h"
|
||||
#include "../../storage/nx_emmc.h"
|
||||
#include "../../sec/tsec.h"
|
||||
#include "../../soc/t210.h"
|
||||
#include "../../soc/fuse.h"
|
||||
#include "../../mem/mc.h"
|
||||
#include "../../sec/se.h"
|
||||
#include "../../soc/hw_init.h"
|
||||
#include "../../mem/emc.h"
|
||||
#include "../../mem/sdram.h"
|
||||
#include "../../storage/emummc.h"
|
||||
#include "../../config/config.h"
|
||||
#include "../common/common.h"
|
||||
|
@ -38,13 +29,6 @@ extern emmc_part_t *system_part;
|
|||
extern char *clipboard;
|
||||
extern u8 clipboardhelper;
|
||||
|
||||
int checkGptRules(char *in){
|
||||
for (int i = 0; gpt_fs_rules[i].name != NULL; i++){
|
||||
if (!strcmp(in, gpt_fs_rules[i].name))
|
||||
return gpt_fs_rules[i].property;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void addEntry(emmc_part_t *part, u8 property, int spot){
|
||||
if (mmcMenuEntries[spot].name != NULL){
|
||||
|
@ -140,61 +124,6 @@ int handleEntries(short mmcType, menu_entry part){
|
|||
return 0;
|
||||
}
|
||||
|
||||
emmc_part_t *mmcFindPart(char *path, short mmcType){
|
||||
char *filename, *extention, *path_local;
|
||||
emmc_part_t *part;
|
||||
|
||||
utils_copystring(path, &path_local);
|
||||
filename = strrchr(path_local, '/') + 1;
|
||||
extention = strrchr(path_local, '.');
|
||||
|
||||
if (extention != NULL)
|
||||
*extention = '\0';
|
||||
|
||||
if (checkGptRules(filename)){
|
||||
gfx_errDisplay("mmcFindPart", ERR_CANNOT_COPY_FILE_TO_FS_PART, 1);
|
||||
free(path_local);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
part = nx_emmc_part_find(selectGpt(mmcType), filename);
|
||||
|
||||
if (part != NULL){
|
||||
emummc_storage_set_mmc_partition(&storage, 0);
|
||||
free(path_local);
|
||||
return part;
|
||||
}
|
||||
|
||||
if (!strcmp(filename, "BOOT0") || !strcmp(filename, "BOOT1")){
|
||||
const u32 BOOT_PART_SIZE = storage.ext_csd.boot_mult << 17;
|
||||
part = calloc(1, sizeof(emmc_part_t));
|
||||
|
||||
part->lba_start = 0;
|
||||
part->lba_end = (BOOT_PART_SIZE / NX_EMMC_BLOCKSIZE) - 1;
|
||||
|
||||
strcpy(part->name, filename);
|
||||
|
||||
emummc_storage_set_mmc_partition(&storage, (!strcmp(filename, "BOOT0")) ? 1 : 2);
|
||||
free(path_local);
|
||||
return part;
|
||||
}
|
||||
|
||||
//gfx_printf("Path: %s\nFilename: %s", path, filename);
|
||||
//btn_wait();
|
||||
gfx_errDisplay("mmcFindPart", ERR_NO_DESTENATION, 2);
|
||||
free(path_local);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int mmcFlashFile(char *path, short mmcType){
|
||||
emmc_part_t *part;
|
||||
part = mmcFindPart(path, mmcType);
|
||||
if (part != NULL){
|
||||
return restore_emmc_part(path, &storage, part);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
int makeMmcMenu(short mmcType){
|
||||
int count, selection;
|
||||
count = fillMmcMenu(mmcType);
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
#pragma once
|
||||
|
||||
int makeMmcMenu(short mmcType);
|
||||
int mmcFlashFile(char *path, short mmcType);
|
|
@ -2,7 +2,9 @@
|
|||
#include "../../utils/types.h"
|
||||
#include "../../storage/nx_emmc.h"
|
||||
|
||||
int restore_bis_using_file(char *path, u8 mmctype);
|
||||
int emmcDumpSpecific(char *part, char *path);
|
||||
int restore_emmc_part(char *path, sdmmc_storage_t *mmcstorage, emmc_part_t *part);
|
||||
int emmcDumpBoot(char *basePath);
|
||||
int mmcFlashFile(char *path, short mmcType);
|
||||
|
||||
int emmcDumpPart(char *path, sdmmc_storage_t *mmcstorage, emmc_part_t *part);
|
||||
int emmcRestorePart(char *path, sdmmc_storage_t *mmcstorage, emmc_part_t *part);
|
|
@ -18,7 +18,7 @@
|
|||
extern sdmmc_storage_t storage;
|
||||
extern emmc_part_t *system_part;
|
||||
|
||||
int restore_emmc_part(char *path, sdmmc_storage_t *mmcstorage, emmc_part_t *part){
|
||||
int emmcRestorePart(char *path, sdmmc_storage_t *mmcstorage, emmc_part_t *part){
|
||||
FIL fp;
|
||||
FILINFO fno;
|
||||
u8 *buf;
|
||||
|
@ -106,6 +106,7 @@ int restore_emmc_part(char *path, sdmmc_storage_t *mmcstorage, emmc_part_t *part
|
|||
}
|
||||
|
||||
// function replaced by new mmc implementation. Will be removed at some point
|
||||
/*
|
||||
int restore_emmc_file(char *path, const char *target, u8 partition, u8 mmctype){
|
||||
connect_mmc(mmctype);
|
||||
|
||||
|
@ -166,3 +167,63 @@ int restore_bis_using_file(char *path, u8 mmctype){
|
|||
|
||||
return 0;
|
||||
}
|
||||
*/
|
||||
|
||||
emmc_part_t *mmcFindPart(char *path, short mmcType){
|
||||
char *filename, *extention, *path_local;
|
||||
emmc_part_t *part;
|
||||
|
||||
utils_copystring(path, &path_local);
|
||||
filename = strrchr(path_local, '/') + 1;
|
||||
extention = strrchr(path_local, '.');
|
||||
|
||||
if (extention != NULL)
|
||||
*extention = '\0';
|
||||
|
||||
if (checkGptRules(filename)){
|
||||
gfx_errDisplay("mmcFindPart", ERR_CANNOT_COPY_FILE_TO_FS_PART, 1);
|
||||
free(path_local);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
part = nx_emmc_part_find(selectGpt(mmcType), filename);
|
||||
|
||||
if (part != NULL){
|
||||
emummc_storage_set_mmc_partition(&storage, 0);
|
||||
free(path_local);
|
||||
return part;
|
||||
}
|
||||
|
||||
if (!strcmp(filename, "BOOT0") || !strcmp(filename, "BOOT1")){
|
||||
const u32 BOOT_PART_SIZE = storage.ext_csd.boot_mult << 17;
|
||||
part = calloc(1, sizeof(emmc_part_t));
|
||||
|
||||
part->lba_start = 0;
|
||||
part->lba_end = (BOOT_PART_SIZE / NX_EMMC_BLOCKSIZE) - 1;
|
||||
|
||||
strcpy(part->name, filename);
|
||||
|
||||
emummc_storage_set_mmc_partition(&storage, (!strcmp(filename, "BOOT0")) ? 1 : 2);
|
||||
free(path_local);
|
||||
return part;
|
||||
}
|
||||
|
||||
//gfx_printf("Path: %s\nFilename: %s", path, filename);
|
||||
//btn_wait();
|
||||
gfx_errDisplay("mmcFindPart", ERR_NO_DESTENATION, 2);
|
||||
free(path_local);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int mmcFlashFile(char *path, short mmcType){
|
||||
emmc_part_t *part;
|
||||
int res;
|
||||
|
||||
part = mmcFindPart(path, mmcType);
|
||||
if (part != NULL){
|
||||
res = emmcRestorePart(path, &storage, part);
|
||||
emummc_storage_set_mmc_partition(&storage, 0);
|
||||
return res;
|
||||
}
|
||||
return 1;
|
||||
}
|
|
@ -146,9 +146,8 @@ int filemenu(menu_entry file){
|
|||
SETBIT(fs_menu_file[7].property, ISHIDE, !(strstr(file.name, ".bin") != NULL && file.property & ISKB));
|
||||
SETBIT(fs_menu_file[8].property, ISHIDE, !(strstr(file.name, ".te") != NULL));
|
||||
SETBIT(fs_menu_file[10].property, ISHIDE, !(strstr(file.name, ".bis") != NULL));
|
||||
SETBIT(fs_menu_file[11].property, ISHIDE, !(strstr(file.name, ".bis") != NULL));
|
||||
|
||||
temp = menu_make(fs_menu_file, 12, "-- File Menu --");
|
||||
temp = menu_make(fs_menu_file, 11, "-- File Menu --");
|
||||
|
||||
switch (temp){
|
||||
case FILE_COPY:
|
||||
|
@ -177,9 +176,6 @@ int filemenu(menu_entry file){
|
|||
fsreader_readfolder(currentpath);
|
||||
btn_wait();
|
||||
break;
|
||||
case FILE_RESTOREBIS:
|
||||
restore_bis_using_file(fsutil_getnextloc(currentpath, file.name), SYSMMC);
|
||||
break;
|
||||
case -1:
|
||||
return -1;
|
||||
}
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
#include "../../storage/nx_emmc.h"
|
||||
#include "../common/types.h"
|
||||
#include "../utils/utils.h"
|
||||
#include "fsactions.h"
|
||||
|
||||
u32 DecodeInt(u8* data) {
|
||||
u32 out = 0;
|
||||
|
@ -55,6 +56,7 @@ int extract_bis_file(char *path, char *outfolder){
|
|||
u8 args;
|
||||
u8 temp[0x4];
|
||||
u32 filesizes[4];
|
||||
char *tempPath;
|
||||
|
||||
if ((res = f_open(&in, path, FA_READ | FA_OPEN_EXISTING))){
|
||||
gfx_errDisplay("extract_bis_file", res, 0);
|
||||
|
@ -71,21 +73,35 @@ int extract_bis_file(char *path, char *outfolder){
|
|||
|
||||
gfx_printf("Version: %s\n\n", version);
|
||||
|
||||
if (args & BOOT0_ARG){
|
||||
gfx_printf("\nExtracting BOOT0\n");
|
||||
if (args & BOOT0_ARG)
|
||||
gen_part(filesizes[0], &in, fsutil_getnextloc(outfolder, "BOOT0.bin"));
|
||||
}
|
||||
|
||||
if (args & BOOT1_ARG){
|
||||
gfx_printf("Extracting BOOT1\n");
|
||||
if (args & BOOT1_ARG)
|
||||
gen_part(filesizes[1], &in, fsutil_getnextloc(outfolder, "BOOT1.bin"));
|
||||
}
|
||||
|
||||
gfx_printf("Extracting BCPKG2_1\n");
|
||||
if (args & BCPKG2_1_ARG)
|
||||
gen_part(filesizes[2], &in, fsutil_getnextloc(outfolder, "BCPKG2-1-Normal-Main"));
|
||||
if (args & BCPKG2_1_ARG){
|
||||
utils_copystring(fsutil_getnextloc(outfolder, "BCPKG2-1-Normal-Main"), &tempPath);
|
||||
gfx_printf("Extracting BCPKG2_1/2\n");
|
||||
|
||||
gfx_printf("Extracting BCPKG2_3\n");
|
||||
if (args & BCPKG2_3_ARG)
|
||||
gen_part(filesizes[3], &in, fsutil_getnextloc(outfolder, "BCPKG2-3-SafeMode-Main"));
|
||||
gen_part(filesizes[2], &in, tempPath);
|
||||
fsact_copy(tempPath, fsutil_getnextloc(outfolder, "BCPKG2-2-Normal-Sub"), COPY_MODE_PRINT);
|
||||
RESETCOLOR;
|
||||
free(tempPath);
|
||||
}
|
||||
|
||||
if (args & BCPKG2_3_ARG){
|
||||
utils_copystring(fsutil_getnextloc(outfolder, "BCPKG2-3-SafeMode-Main"), &tempPath);
|
||||
gfx_printf("Extracting BCPKG2_3/4\n");
|
||||
|
||||
gen_part(filesizes[3], &in, tempPath);
|
||||
fsact_copy(tempPath, fsutil_getnextloc(outfolder, "BCPKG2-4-SafeMode-Sub"), COPY_MODE_PRINT);
|
||||
RESETCOLOR;
|
||||
free(tempPath);
|
||||
}
|
||||
|
||||
gfx_printf("\n\nDone!\n");
|
||||
|
||||
|
|
Loading…
Reference in a new issue