mirror of
https://github.com/suchmememanyskill/TegraExplorer.git
synced 2024-11-26 13:52:06 +00:00
re-implement formatting + add firmware dumping
This commit is contained in:
parent
ae225abb75
commit
47df1b9cd1
9 changed files with 135 additions and 27 deletions
|
@ -70,6 +70,14 @@ int mount_emmc(char *partition, int biskeynumb){
|
|||
return 0;
|
||||
}
|
||||
|
||||
short returnpkg1ver(){
|
||||
return pkg1ver;
|
||||
}
|
||||
|
||||
void disconnect_emmc(){
|
||||
sdmmc_storage_end(&storage);
|
||||
}
|
||||
|
||||
int dump_biskeys(){
|
||||
u8 temp_key[0x10], device_key[0x10] = {0};
|
||||
tsec_ctxt_t tsec_ctxt;
|
||||
|
|
|
@ -4,6 +4,8 @@
|
|||
int dump_biskeys();
|
||||
void print_biskeys();
|
||||
int mount_emmc(char *partition, int biskeynumb);
|
||||
short returnpkg1ver();
|
||||
void disconnect_emmc();
|
||||
|
||||
static const u8 zeros[0x10] = {0};
|
||||
|
||||
|
|
|
@ -295,7 +295,7 @@ int readfolder(const char *path){
|
|||
message(errmes, COLOR_RED);
|
||||
}
|
||||
|
||||
while (!f_readdir(&dir, &fno) && fno.fname[0]){
|
||||
while (!f_readdir(&dir, &fno) && fno.fname[0] && folderamount < 500){
|
||||
addobject(fno.fname, folderamount++, (fno.fattrib & AM_DIR), (fno.fattrib & AM_ARC));
|
||||
}
|
||||
|
||||
|
|
|
@ -41,3 +41,4 @@ int readfolder(const char *path);
|
|||
void filemenu();
|
||||
bool checkfile(char* path);
|
||||
u64 getfilesize(char *path);
|
||||
int copy(const char *locin, const char *locout, bool print);
|
|
@ -37,8 +37,15 @@ menu_item toolsmenu[5] = {
|
|||
{"-- TOOLS --\n", COLOR_VIOLET, -1, 0},
|
||||
{"Back", COLOR_WHITE, -1, 1},
|
||||
{"\nDisplay Console Info", COLOR_GREEN, DISPLAY_INFO, 1},
|
||||
{"Display GPIO pins [DEV]", COLOR_RED, DISPLAY_GPIO, 1},
|
||||
{"FORMAT TEST", COLOR_RED, FORMATFAT32, 1}
|
||||
{"Display GPIO pins", COLOR_VIOLET, DISPLAY_GPIO, 1},
|
||||
{"Dump Firmware", COLOR_BLUE, DUMPFIRMWARE, 1}
|
||||
};
|
||||
|
||||
menu_item formatmenu[4] = {
|
||||
{"-- FORMAT SD --\n", COLOR_RED, -1, 0},
|
||||
{"Back\n", COLOR_WHITE, -1, 1},
|
||||
{"Format to FAT32", COLOR_RED, FORMAT_ALL_FAT32, 1},
|
||||
{"Format for EmuMMC setup", COLOR_RED, FORMAT_EMUMMC, 1}
|
||||
};
|
||||
|
||||
void fillmainmenu(){
|
||||
|
@ -111,15 +118,32 @@ void te_main(){
|
|||
case TOOLS:
|
||||
res = makemenu(toolsmenu, 5);
|
||||
|
||||
if (res == DISPLAY_INFO)
|
||||
switch(res){
|
||||
case DISPLAY_INFO:
|
||||
displayinfo();
|
||||
|
||||
if (res == DISPLAY_GPIO)
|
||||
break;
|
||||
case DISPLAY_GPIO:
|
||||
displaygpio();
|
||||
break;
|
||||
case DUMPFIRMWARE:
|
||||
dumpfirmware();
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
if (res == FORMATFAT32)
|
||||
format();
|
||||
case SD_FORMAT:
|
||||
res = makemenu(formatmenu, 4);
|
||||
|
||||
switch(res){
|
||||
case FORMAT_ALL_FAT32:
|
||||
if (makewaitmenu("Are you sure you want to format your sd?\nThis action is irreversible!\n\nPress Vol+/- to cancel\n", "Press Power to continue", 10))
|
||||
format(1);
|
||||
break;
|
||||
case FORMAT_EMUMMC:
|
||||
if (makewaitmenu("Are you sure you want to format your sd?\nThis action is irreversible!\n\nPress Vol+/- to cancel\n", "Press Power to continue", 10))
|
||||
format(0);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
case CREDITS:
|
||||
|
|
|
@ -33,7 +33,12 @@ enum shutdownmenu_return {
|
|||
enum toolsmenu_return {
|
||||
DISPLAY_INFO = 1,
|
||||
DISPLAY_GPIO,
|
||||
FORMATFAT32
|
||||
DUMPFIRMWARE
|
||||
};
|
||||
|
||||
enum formatmenu_return {
|
||||
FORMAT_ALL_FAT32,
|
||||
FORMAT_EMUMMC
|
||||
};
|
||||
|
||||
//menu_item mainmenu[MAINMENU_AMOUNT];
|
||||
|
|
|
@ -8,7 +8,9 @@
|
|||
#include "../utils/types.h"
|
||||
#include "../libs/fatfs/diskio.h"
|
||||
#include "../storage/sdmmc.h"
|
||||
#include "../utils/sprintf.h"
|
||||
#include "emmc.h"
|
||||
#include "fs.h"
|
||||
|
||||
extern bool sd_mount();
|
||||
extern void sd_unmount();
|
||||
|
@ -17,8 +19,6 @@ extern sdmmc_storage_t sd_storage;
|
|||
void displayinfo(){
|
||||
clearscreen();
|
||||
|
||||
|
||||
|
||||
FATFS *fs;
|
||||
DWORD fre_clust, fre_sect, tot_sect;
|
||||
u32 capacity;
|
||||
|
@ -69,23 +69,79 @@ void displaygpio(){
|
|||
}
|
||||
}
|
||||
|
||||
void format(){
|
||||
int dumpfirmware(){
|
||||
DIR dir;
|
||||
FILINFO fno;
|
||||
bool fail = false;
|
||||
int ret, amount = 0;
|
||||
char path[100] = "emmc:/Contents/registered";
|
||||
char sdfolderpath[100] = "";
|
||||
char syspath[100] = "";
|
||||
char sdpath[100] = "";
|
||||
short pkg1ver = returnpkg1ver();
|
||||
u32 timer = get_tmr_s();
|
||||
|
||||
clearscreen();
|
||||
|
||||
gfx_printf("PKG1 version: %d\n", pkg1ver);
|
||||
|
||||
ret = f_mkdir("sd:/tegraexplorer");
|
||||
gfx_printf("Creating making sd:/tegraexplorer %d\n", ret);
|
||||
|
||||
ret = f_mkdir("sd:/tegraexplorer/Firmware");
|
||||
gfx_printf("Creating sd:/tegraexplorer/Firmware %d\n", ret);
|
||||
|
||||
sprintf(sdfolderpath, "sd:/tegraexplorer/Firmware/%d", pkg1ver);
|
||||
ret = f_mkdir(sdfolderpath);
|
||||
gfx_printf("Creating %s %d\n", sdfolderpath, ret);
|
||||
|
||||
ret = f_opendir(&dir, path);
|
||||
gfx_printf("Result opening system:/ %d\n\n%k", ret, COLOR_GREEN);
|
||||
|
||||
while(!f_readdir(&dir, &fno) && fno.fname[0] && !fail){
|
||||
sprintf(sdpath, "%s/%s", sdfolderpath, fno.fname);
|
||||
|
||||
if (fno.fattrib & AM_DIR)
|
||||
sprintf(syspath, "%s/%s/00", path, fno.fname);
|
||||
else
|
||||
sprintf(syspath, "%s/%s", path, fno.fname);
|
||||
|
||||
ret = copy(syspath, sdpath, false);
|
||||
|
||||
gfx_printf("%d %s\r", ++amount, fno.fname);
|
||||
|
||||
if (ret != 0)
|
||||
fail = true;
|
||||
}
|
||||
|
||||
if (fail)
|
||||
gfx_printf("%k\n\nDump failed! Aborting (%d)", COLOR_RED, ret);
|
||||
|
||||
gfx_printf("%k\n\nPress any button to continue...\nTime taken: %ds", COLOR_WHITE, get_tmr_s() - timer);
|
||||
|
||||
btn_wait();
|
||||
|
||||
return fail;
|
||||
}
|
||||
|
||||
void format(int mode){
|
||||
clearscreen();
|
||||
int res;
|
||||
bool fatalerror = false;
|
||||
|
||||
DWORD plist[] = {666, 61145088};
|
||||
u32 timer, totalsectors;
|
||||
BYTE work[FF_MAX_SS];
|
||||
DWORD plist[] = {666, 61145088};
|
||||
DWORD clustsize = 16 * 512;
|
||||
BYTE formatoptions = 0;
|
||||
formatoptions |= (FM_FAT32);
|
||||
//formatoptions |= (FM_SFD);
|
||||
|
||||
timer = get_tmr_s();
|
||||
disconnect_emmc();
|
||||
|
||||
timer = get_tmr_s();
|
||||
totalsectors = sd_storage.csd.capacity;
|
||||
|
||||
if (mode == 0){
|
||||
if (totalsectors < 61145088){
|
||||
gfx_printf("%k\nNot enough free space for emummc!", COLOR_RED);
|
||||
fatalerror = true;
|
||||
|
@ -94,6 +150,14 @@ void format(){
|
|||
if (!fatalerror){
|
||||
plist[0] = totalsectors - 61145088;
|
||||
gfx_printf("\nStarting SD partitioning:\nTotalSectors: %d\nPartition1 (SD): %d\nPartition2 (EMUMMC): %d\n", totalsectors, plist[0], plist[1]);
|
||||
}
|
||||
}
|
||||
else {
|
||||
plist[0] = totalsectors;
|
||||
plist[1] = 0;
|
||||
}
|
||||
|
||||
if (!fatalerror){
|
||||
gfx_printf("\nPartitioning SD...\n");
|
||||
res = f_fdisk(0, plist, &work);
|
||||
|
||||
|
@ -127,6 +191,9 @@ void format(){
|
|||
}
|
||||
}
|
||||
|
||||
dump_biskeys();
|
||||
mount_emmc("SYSTEM", 2);
|
||||
|
||||
gfx_printf("\nPress any button to return%k\nTotal time taken: %ds", COLOR_WHITE, (get_tmr_s() - timer));
|
||||
btn_wait();
|
||||
}
|
|
@ -2,4 +2,5 @@
|
|||
|
||||
void displayinfo();
|
||||
void displaygpio();
|
||||
void format();
|
||||
void format(int mode);
|
||||
int dumpfirmware();
|
Loading…
Reference in a new issue