mirror of
https://github.com/suchmememanyskill/TegraExplorer.git
synced 2024-11-26 13:52:06 +00:00
Bug fixing round & add some emummc menus
Notable bugs fixed: - pkg1id is now also used as foldername during fw dump - Clearing of screen in _recursive functions is no longer hardcoded - Folders get the correct file attributes - first 16 MiB of partition during partitioning gets cleared now
This commit is contained in:
parent
9885308bce
commit
eb8652c6ec
10 changed files with 75 additions and 28 deletions
|
@ -6113,6 +6113,8 @@ FRESULT f_fdisk (
|
||||||
DWORD sz_disk, p_sect, b_cyl, b_sect;
|
DWORD sz_disk, p_sect, b_cyl, b_sect;
|
||||||
FRESULT res;
|
FRESULT res;
|
||||||
|
|
||||||
|
BYTE *empty_buff;
|
||||||
|
empty_buff = ff_memcalloc(sizeof(BYTE), 16384);
|
||||||
|
|
||||||
stat = disk_initialize(pdrv);
|
stat = disk_initialize(pdrv);
|
||||||
if (stat & STA_NOINIT) return FR_NOT_READY;
|
if (stat & STA_NOINIT) return FR_NOT_READY;
|
||||||
|
@ -6167,8 +6169,13 @@ FRESULT f_fdisk (
|
||||||
st_dword(p + 12, p_sect); /* Number of sectors */
|
st_dword(p + 12, p_sect); /* Number of sectors */
|
||||||
/* Next partition */
|
/* Next partition */
|
||||||
b_sect += p_sect;
|
b_sect += p_sect;
|
||||||
|
|
||||||
|
for (int cursect = 0; cursect < 1024; cursect++){
|
||||||
|
disk_write(pdrv, empty_buff, b_sect + (32 * cursect), 32);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
st_word(p, 0xAA55); /* MBR signature (always at offset 510) */
|
st_word(p, 0xAA55); /* MBR signature (always at offset 510) */
|
||||||
|
ff_memfree(empty_buff);
|
||||||
|
|
||||||
/* Write it to the MBR */
|
/* Write it to the MBR */
|
||||||
res = (disk_write(pdrv, buf, 0, 1) == RES_OK && disk_ioctl(pdrv, CTRL_SYNC, 0) == RES_OK) ? FR_OK : FR_DISK_ERR;
|
res = (disk_write(pdrv, buf, 0, 1) == RES_OK && disk_ioctl(pdrv, CTRL_SYNC, 0) == RES_OK) ? FR_OK : FR_DISK_ERR;
|
||||||
|
|
|
@ -321,6 +321,7 @@ DWORD ff_wtoupper (DWORD uni); /* Unicode upper-case conversion */
|
||||||
#endif
|
#endif
|
||||||
#if FF_USE_LFN == 3 /* Dynamic memory allocation */
|
#if FF_USE_LFN == 3 /* Dynamic memory allocation */
|
||||||
void* ff_memalloc (UINT msize); /* Allocate memory block */
|
void* ff_memalloc (UINT msize); /* Allocate memory block */
|
||||||
|
void* ff_memcalloc (UINT msize, UINT amount);
|
||||||
void ff_memfree (void* mblock); /* Free memory block */
|
void ff_memfree (void* mblock); /* Free memory block */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -23,6 +23,10 @@ void* ff_memalloc ( /* Returns pointer to the allocated memory block (null if no
|
||||||
return malloc(msize); /* Allocate a new memory block with POSIX API */
|
return malloc(msize); /* Allocate a new memory block with POSIX API */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void* ff_memcalloc (UINT msize, UINT amount){
|
||||||
|
return calloc(amount, msize);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*------------------------------------------------------------------------*/
|
/*------------------------------------------------------------------------*/
|
||||||
/* Free a memory block */
|
/* Free a memory block */
|
||||||
|
|
|
@ -29,7 +29,7 @@ __attribute__ ((aligned (16))) FATFS emmc;
|
||||||
LIST_INIT(gpt);
|
LIST_INIT(gpt);
|
||||||
|
|
||||||
u8 bis_key[4][32];
|
u8 bis_key[4][32];
|
||||||
short pkg1ver = -1;
|
pkg1_info pkg1inf = {-1, ""};
|
||||||
short currentlyMounted = -1;
|
short currentlyMounted = -1;
|
||||||
|
|
||||||
|
|
||||||
|
@ -55,11 +55,11 @@ void print_biskeys(){
|
||||||
gfx_hexdump(0, bis_key[2], 32);
|
gfx_hexdump(0, bis_key[2], 32);
|
||||||
}
|
}
|
||||||
|
|
||||||
short returnpkg1ver(){
|
pkg1_info returnpkg1info(){
|
||||||
return pkg1ver;
|
return pkg1inf;
|
||||||
}
|
}
|
||||||
|
|
||||||
int mount_mmc(char *partition, int biskeynumb){
|
int mount_mmc(const char *partition, const int biskeynumb){
|
||||||
f_unmount("emmc:");
|
f_unmount("emmc:");
|
||||||
|
|
||||||
se_aes_key_set(8, bis_key[biskeynumb] + 0x00, 0x10);
|
se_aes_key_set(8, bis_key[biskeynumb] + 0x00, 0x10);
|
||||||
|
@ -206,6 +206,7 @@ int dump_biskeys(){
|
||||||
se_aes_key_set(8, bis_key[2] + 0x00, 0x10);
|
se_aes_key_set(8, bis_key[2] + 0x00, 0x10);
|
||||||
se_aes_key_set(9, bis_key[2] + 0x10, 0x10);
|
se_aes_key_set(9, bis_key[2] + 0x10, 0x10);
|
||||||
|
|
||||||
pkg1ver = pkg1_id->kb;
|
pkg1inf.ver = pkg1_id->kb;
|
||||||
|
strcpy(pkg1inf.id, pkg1_id->id);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
|
@ -1,11 +1,16 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
typedef struct _pkg1_info {
|
||||||
|
short ver;
|
||||||
|
char id[16];
|
||||||
|
} pkg1_info;
|
||||||
|
|
||||||
//int mount_emmc_partition(const char *part, int logicnumb);
|
//int mount_emmc_partition(const char *part, int logicnumb);
|
||||||
int dump_biskeys();
|
int dump_biskeys();
|
||||||
void print_biskeys();
|
void print_biskeys();
|
||||||
short returnpkg1ver();
|
pkg1_info returnpkg1info();
|
||||||
|
|
||||||
int mount_mmc(char *partition, int biskeynumb);
|
int mount_mmc(const char *partition, const int biskeynumb);
|
||||||
void connect_mmc(short mmctype);
|
void connect_mmc(short mmctype);
|
||||||
void disconnect_mmc();
|
void disconnect_mmc();
|
||||||
|
|
||||||
|
|
|
@ -158,7 +158,10 @@ int del_recursive(char *path){
|
||||||
DIR dir;
|
DIR dir;
|
||||||
FILINFO fno;
|
FILINFO fno;
|
||||||
int res;
|
int res;
|
||||||
|
u32 x, y;
|
||||||
char *localpath = NULL;
|
char *localpath = NULL;
|
||||||
|
|
||||||
|
gfx_con_getpos(&x, &y);
|
||||||
makestring(path, &localpath);
|
makestring(path, &localpath);
|
||||||
|
|
||||||
if ((res = f_opendir(&dir, localpath))){
|
if ((res = f_opendir(&dir, localpath))){
|
||||||
|
@ -171,7 +174,7 @@ int del_recursive(char *path){
|
||||||
del_recursive(getnextloc(localpath, fno.fname));
|
del_recursive(getnextloc(localpath, fno.fname));
|
||||||
|
|
||||||
else {
|
else {
|
||||||
gfx_box(0, 47, 719, 63, COLOR_DEFAULT);
|
gfx_box(0, y, 719, y + 16, COLOR_DEFAULT);
|
||||||
SWAPCOLOR(COLOR_RED);
|
SWAPCOLOR(COLOR_RED);
|
||||||
gfx_printf("\r");
|
gfx_printf("\r");
|
||||||
gfx_print_length(37, fno.fname);
|
gfx_print_length(37, fno.fname);
|
||||||
|
@ -197,15 +200,17 @@ int copy_recursive(char *path, char *dstpath){
|
||||||
DIR dir;
|
DIR dir;
|
||||||
FILINFO fno;
|
FILINFO fno;
|
||||||
int res;
|
int res;
|
||||||
|
u32 x, y;
|
||||||
char *startpath = NULL, *destpath = NULL, *destfoldername = NULL, *temp = NULL;
|
char *startpath = NULL, *destpath = NULL, *destfoldername = NULL, *temp = NULL;
|
||||||
|
|
||||||
|
gfx_con_getpos(&x, &y);
|
||||||
|
|
||||||
makestring(path, &startpath);
|
makestring(path, &startpath);
|
||||||
makestring(strrchr(path, '/') + 1, &destfoldername);
|
makestring(strrchr(path, '/') + 1, &destfoldername);
|
||||||
|
|
||||||
destpath = (char*) malloc (strlen(dstpath) + strlen(destfoldername) + 2);
|
destpath = (char*) malloc (strlen(dstpath) + strlen(destfoldername) + 2);
|
||||||
sprintf(destpath, (dstpath[strlen(dstpath) - 1] == '/') ? "%s%s" : "%s/%s", dstpath, destfoldername);
|
sprintf(destpath, (dstpath[strlen(dstpath) - 1] == '/') ? "%s%s" : "%s/%s", dstpath, destfoldername);
|
||||||
|
|
||||||
|
|
||||||
if ((res = f_opendir(&dir, startpath))){
|
if ((res = f_opendir(&dir, startpath))){
|
||||||
message(COLOR_RED, "Error during f_opendir: %d", res);
|
message(COLOR_RED, "Error during f_opendir: %d", res);
|
||||||
return 21;
|
return 21;
|
||||||
|
@ -213,15 +218,12 @@ int copy_recursive(char *path, char *dstpath){
|
||||||
|
|
||||||
f_mkdir(destpath);
|
f_mkdir(destpath);
|
||||||
|
|
||||||
if (f_stat(startpath, &fno))
|
|
||||||
return 22;
|
|
||||||
|
|
||||||
while (!f_readdir(&dir, &fno) && fno.fname[0]){
|
while (!f_readdir(&dir, &fno) && fno.fname[0]){
|
||||||
if (fno.fattrib & AM_DIR){
|
if (fno.fattrib & AM_DIR){
|
||||||
copy_recursive(getnextloc(startpath, fno.fname), destpath);
|
copy_recursive(getnextloc(startpath, fno.fname), destpath);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
gfx_box(0, 47, 719, 63, COLOR_DEFAULT);
|
gfx_box(0, y, 719, y + 16, COLOR_DEFAULT);
|
||||||
SWAPCOLOR(COLOR_GREEN);
|
SWAPCOLOR(COLOR_GREEN);
|
||||||
gfx_printf("\r");
|
gfx_printf("\r");
|
||||||
gfx_print_length(37, fno.fname);
|
gfx_print_length(37, fno.fname);
|
||||||
|
@ -241,8 +243,12 @@ int copy_recursive(char *path, char *dstpath){
|
||||||
free(destpath);
|
free(destpath);
|
||||||
free(destfoldername);
|
free(destfoldername);
|
||||||
|
|
||||||
|
if (f_stat(startpath, &fno))
|
||||||
|
return 22;
|
||||||
|
|
||||||
if ((res = f_chmod(destpath, fno.fattrib, 0x3A)))
|
if ((res = f_chmod(destpath, fno.fattrib, 0x3A)))
|
||||||
return res;
|
return res;
|
||||||
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
|
@ -56,6 +56,12 @@ menu_item formatmenu[4] = {
|
||||||
{"Format for EmuMMC setup (FAT32/RAW)", COLOR_RED, FORMAT_EMUMMC, 1}
|
{"Format for EmuMMC setup (FAT32/RAW)", COLOR_RED, FORMAT_EMUMMC, 1}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
menu_item mmcChoice[3] = {
|
||||||
|
{"Back\n", COLOR_WHITE, -1, 1},
|
||||||
|
{"SysMMC", COLOR_ORANGE, SYSMMC, 1},
|
||||||
|
{"EmuMMC", COLOR_BLUE, EMUMMC, 1}
|
||||||
|
};
|
||||||
|
|
||||||
const char emmc_entries[3][8] = {
|
const char emmc_entries[3][8] = {
|
||||||
"SAFE",
|
"SAFE",
|
||||||
"SYSTEM",
|
"SYSTEM",
|
||||||
|
@ -165,10 +171,28 @@ void te_main(){
|
||||||
displaygpio();
|
displaygpio();
|
||||||
break;
|
break;
|
||||||
case DUMPFIRMWARE:
|
case DUMPFIRMWARE:
|
||||||
dumpfirmware();
|
/*
|
||||||
|
if (mainmenu[4].property >= 0){
|
||||||
|
res = makemenu(mmcChoice, 3);
|
||||||
|
|
||||||
|
if (res >= 0)
|
||||||
|
dumpfirmware(res);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
*/
|
||||||
|
dumpfirmware(SYSMMC);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case DUMPUSERSAVE:
|
case DUMPUSERSAVE:
|
||||||
dumpusersaves();
|
if (mainmenu[4].property >= 0){
|
||||||
|
res = makemenu(mmcChoice, 3);
|
||||||
|
|
||||||
|
if (res >= 0)
|
||||||
|
dumpusersaves(res);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
dumpusersaves(SYSMMC);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -46,6 +46,4 @@ enum formatmenu_return {
|
||||||
FORMAT_ALL_FAT32
|
FORMAT_ALL_FAT32
|
||||||
};
|
};
|
||||||
|
|
||||||
//menu_item mainmenu[MAINMENU_AMOUNT];
|
|
||||||
|
|
||||||
void te_main();
|
void te_main();
|
|
@ -25,6 +25,7 @@ void displayinfo(){
|
||||||
DWORD fre_clust, fre_sect, tot_sect;
|
DWORD fre_clust, fre_sect, tot_sect;
|
||||||
u32 capacity;
|
u32 capacity;
|
||||||
u8 fuse_count = 0;
|
u8 fuse_count = 0;
|
||||||
|
pkg1_info pkg1 = returnpkg1info();
|
||||||
int res;
|
int res;
|
||||||
|
|
||||||
for (u32 i = 0; i < 32; i++){
|
for (u32 i = 0; i < 32; i++){
|
||||||
|
@ -34,7 +35,7 @@ void displayinfo(){
|
||||||
|
|
||||||
SWAPCOLOR(COLOR_ORANGE);
|
SWAPCOLOR(COLOR_ORANGE);
|
||||||
|
|
||||||
gfx_printf("Fuse count: %d\nPKG1 version: %d\n\n", fuse_count, returnpkg1ver());
|
gfx_printf("Fuse count: %d\nPKG1 version: %d\nPKG1 id: %s\n\n", fuse_count, pkg1.ver, pkg1.id);
|
||||||
print_biskeys();
|
print_biskeys();
|
||||||
|
|
||||||
RESETCOLOR;
|
RESETCOLOR;
|
||||||
|
@ -85,7 +86,7 @@ void displaygpio(){
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int dumpfirmware(){
|
int dumpfirmware(int mmc){
|
||||||
DIR dir;
|
DIR dir;
|
||||||
FILINFO fno;
|
FILINFO fno;
|
||||||
bool fail = false;
|
bool fail = false;
|
||||||
|
@ -94,14 +95,14 @@ int dumpfirmware(){
|
||||||
char sdfolderpath[100] = "";
|
char sdfolderpath[100] = "";
|
||||||
char syspath[100] = "";
|
char syspath[100] = "";
|
||||||
char sdpath[100] = "";
|
char sdpath[100] = "";
|
||||||
short pkg1ver = returnpkg1ver();
|
pkg1_info pkg1 = returnpkg1info();
|
||||||
u32 timer = get_tmr_s();
|
u32 timer = get_tmr_s();
|
||||||
|
|
||||||
clearscreen();
|
clearscreen();
|
||||||
connect_mmc(SYSMMC);
|
connect_mmc(mmc);
|
||||||
mount_mmc("SYSTEM", 2);
|
mount_mmc("SYSTEM", 2);
|
||||||
|
|
||||||
gfx_printf("PKG1 version: %d\n", pkg1ver);
|
gfx_printf("PKG1 version: %d\n", pkg1.ver);
|
||||||
|
|
||||||
ret = f_mkdir("sd:/tegraexplorer");
|
ret = f_mkdir("sd:/tegraexplorer");
|
||||||
gfx_printf("Creating sd:/tegraexplorer %d\n", ret);
|
gfx_printf("Creating sd:/tegraexplorer %d\n", ret);
|
||||||
|
@ -109,7 +110,7 @@ int dumpfirmware(){
|
||||||
ret = f_mkdir("sd:/tegraexplorer/Firmware");
|
ret = f_mkdir("sd:/tegraexplorer/Firmware");
|
||||||
gfx_printf("Creating sd:/tegraexplorer/Firmware %d\n", ret);
|
gfx_printf("Creating sd:/tegraexplorer/Firmware %d\n", ret);
|
||||||
|
|
||||||
sprintf(sdfolderpath, "sd:/tegraexplorer/Firmware/%d", pkg1ver);
|
sprintf(sdfolderpath, "sd:/tegraexplorer/Firmware/%d (%s)", pkg1.ver, pkg1.id);
|
||||||
ret = f_mkdir(sdfolderpath);
|
ret = f_mkdir(sdfolderpath);
|
||||||
gfx_printf("Creating %s %d\n", sdfolderpath, ret);
|
gfx_printf("Creating %s %d\n", sdfolderpath, ret);
|
||||||
|
|
||||||
|
@ -142,10 +143,10 @@ int dumpfirmware(){
|
||||||
return fail;
|
return fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
void dumpusersaves(){
|
void dumpusersaves(int mmc){
|
||||||
int res;
|
int res;
|
||||||
|
|
||||||
connect_mmc(SYSMMC);
|
connect_mmc(mmc);
|
||||||
mount_mmc("USER", 2);
|
mount_mmc("USER", 2);
|
||||||
clearscreen();
|
clearscreen();
|
||||||
|
|
||||||
|
|
|
@ -3,5 +3,5 @@
|
||||||
void displayinfo();
|
void displayinfo();
|
||||||
void displaygpio();
|
void displaygpio();
|
||||||
int format(int mode);
|
int format(int mode);
|
||||||
int dumpfirmware();
|
int dumpfirmware(int mmc);
|
||||||
void dumpusersaves();
|
void dumpusersaves(int mmc);
|
Loading…
Reference in a new issue