mirror of
https://github.com/suchmememanyskill/TegraExplorer.git
synced 2024-11-22 20:06:43 +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;
|
||||
FRESULT res;
|
||||
|
||||
BYTE *empty_buff;
|
||||
empty_buff = ff_memcalloc(sizeof(BYTE), 16384);
|
||||
|
||||
stat = disk_initialize(pdrv);
|
||||
if (stat & STA_NOINIT) return FR_NOT_READY;
|
||||
|
@ -6167,8 +6169,13 @@ FRESULT f_fdisk (
|
|||
st_dword(p + 12, p_sect); /* Number of sectors */
|
||||
/* Next partition */
|
||||
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) */
|
||||
ff_memfree(empty_buff);
|
||||
|
||||
/* 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;
|
||||
|
|
|
@ -321,6 +321,7 @@ DWORD ff_wtoupper (DWORD uni); /* Unicode upper-case conversion */
|
|||
#endif
|
||||
#if FF_USE_LFN == 3 /* Dynamic memory allocation */
|
||||
void* ff_memalloc (UINT msize); /* Allocate memory block */
|
||||
void* ff_memcalloc (UINT msize, UINT amount);
|
||||
void ff_memfree (void* mblock); /* Free memory block */
|
||||
#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 */
|
||||
}
|
||||
|
||||
void* ff_memcalloc (UINT msize, UINT amount){
|
||||
return calloc(amount, msize);
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------*/
|
||||
/* Free a memory block */
|
||||
|
|
|
@ -29,7 +29,7 @@ __attribute__ ((aligned (16))) FATFS emmc;
|
|||
LIST_INIT(gpt);
|
||||
|
||||
u8 bis_key[4][32];
|
||||
short pkg1ver = -1;
|
||||
pkg1_info pkg1inf = {-1, ""};
|
||||
short currentlyMounted = -1;
|
||||
|
||||
|
||||
|
@ -55,11 +55,11 @@ void print_biskeys(){
|
|||
gfx_hexdump(0, bis_key[2], 32);
|
||||
}
|
||||
|
||||
short returnpkg1ver(){
|
||||
return pkg1ver;
|
||||
pkg1_info returnpkg1info(){
|
||||
return pkg1inf;
|
||||
}
|
||||
|
||||
int mount_mmc(char *partition, int biskeynumb){
|
||||
int mount_mmc(const char *partition, const int biskeynumb){
|
||||
f_unmount("emmc:");
|
||||
|
||||
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(9, bis_key[2] + 0x10, 0x10);
|
||||
|
||||
pkg1ver = pkg1_id->kb;
|
||||
pkg1inf.ver = pkg1_id->kb;
|
||||
strcpy(pkg1inf.id, pkg1_id->id);
|
||||
return 0;
|
||||
}
|
|
@ -1,11 +1,16 @@
|
|||
#pragma once
|
||||
|
||||
typedef struct _pkg1_info {
|
||||
short ver;
|
||||
char id[16];
|
||||
} pkg1_info;
|
||||
|
||||
//int mount_emmc_partition(const char *part, int logicnumb);
|
||||
int dump_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 disconnect_mmc();
|
||||
|
||||
|
|
|
@ -158,7 +158,10 @@ int del_recursive(char *path){
|
|||
DIR dir;
|
||||
FILINFO fno;
|
||||
int res;
|
||||
u32 x, y;
|
||||
char *localpath = NULL;
|
||||
|
||||
gfx_con_getpos(&x, &y);
|
||||
makestring(path, &localpath);
|
||||
|
||||
if ((res = f_opendir(&dir, localpath))){
|
||||
|
@ -171,7 +174,7 @@ int del_recursive(char *path){
|
|||
del_recursive(getnextloc(localpath, fno.fname));
|
||||
|
||||
else {
|
||||
gfx_box(0, 47, 719, 63, COLOR_DEFAULT);
|
||||
gfx_box(0, y, 719, y + 16, COLOR_DEFAULT);
|
||||
SWAPCOLOR(COLOR_RED);
|
||||
gfx_printf("\r");
|
||||
gfx_print_length(37, fno.fname);
|
||||
|
@ -197,15 +200,17 @@ int copy_recursive(char *path, char *dstpath){
|
|||
DIR dir;
|
||||
FILINFO fno;
|
||||
int res;
|
||||
u32 x, y;
|
||||
char *startpath = NULL, *destpath = NULL, *destfoldername = NULL, *temp = NULL;
|
||||
|
||||
gfx_con_getpos(&x, &y);
|
||||
|
||||
makestring(path, &startpath);
|
||||
makestring(strrchr(path, '/') + 1, &destfoldername);
|
||||
|
||||
destpath = (char*) malloc (strlen(dstpath) + strlen(destfoldername) + 2);
|
||||
sprintf(destpath, (dstpath[strlen(dstpath) - 1] == '/') ? "%s%s" : "%s/%s", dstpath, destfoldername);
|
||||
|
||||
|
||||
if ((res = f_opendir(&dir, startpath))){
|
||||
message(COLOR_RED, "Error during f_opendir: %d", res);
|
||||
return 21;
|
||||
|
@ -213,15 +218,12 @@ int copy_recursive(char *path, char *dstpath){
|
|||
|
||||
f_mkdir(destpath);
|
||||
|
||||
if (f_stat(startpath, &fno))
|
||||
return 22;
|
||||
|
||||
while (!f_readdir(&dir, &fno) && fno.fname[0]){
|
||||
if (fno.fattrib & AM_DIR){
|
||||
copy_recursive(getnextloc(startpath, fno.fname), destpath);
|
||||
}
|
||||
else {
|
||||
gfx_box(0, 47, 719, 63, COLOR_DEFAULT);
|
||||
gfx_box(0, y, 719, y + 16, COLOR_DEFAULT);
|
||||
SWAPCOLOR(COLOR_GREEN);
|
||||
gfx_printf("\r");
|
||||
gfx_print_length(37, fno.fname);
|
||||
|
@ -241,8 +243,12 @@ int copy_recursive(char *path, char *dstpath){
|
|||
free(destpath);
|
||||
free(destfoldername);
|
||||
|
||||
if (f_stat(startpath, &fno))
|
||||
return 22;
|
||||
|
||||
if ((res = f_chmod(destpath, fno.fattrib, 0x3A)))
|
||||
return res;
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
|
@ -56,6 +56,12 @@ menu_item formatmenu[4] = {
|
|||
{"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] = {
|
||||
"SAFE",
|
||||
"SYSTEM",
|
||||
|
@ -165,10 +171,28 @@ void te_main(){
|
|||
displaygpio();
|
||||
break;
|
||||
case DUMPFIRMWARE:
|
||||
dumpfirmware();
|
||||
/*
|
||||
if (mainmenu[4].property >= 0){
|
||||
res = makemenu(mmcChoice, 3);
|
||||
|
||||
if (res >= 0)
|
||||
dumpfirmware(res);
|
||||
}
|
||||
else
|
||||
*/
|
||||
dumpfirmware(SYSMMC);
|
||||
|
||||
break;
|
||||
case DUMPUSERSAVE:
|
||||
dumpusersaves();
|
||||
if (mainmenu[4].property >= 0){
|
||||
res = makemenu(mmcChoice, 3);
|
||||
|
||||
if (res >= 0)
|
||||
dumpusersaves(res);
|
||||
}
|
||||
else
|
||||
dumpusersaves(SYSMMC);
|
||||
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
|
|
@ -46,6 +46,4 @@ enum formatmenu_return {
|
|||
FORMAT_ALL_FAT32
|
||||
};
|
||||
|
||||
//menu_item mainmenu[MAINMENU_AMOUNT];
|
||||
|
||||
void te_main();
|
|
@ -25,6 +25,7 @@ void displayinfo(){
|
|||
DWORD fre_clust, fre_sect, tot_sect;
|
||||
u32 capacity;
|
||||
u8 fuse_count = 0;
|
||||
pkg1_info pkg1 = returnpkg1info();
|
||||
int res;
|
||||
|
||||
for (u32 i = 0; i < 32; i++){
|
||||
|
@ -34,7 +35,7 @@ void displayinfo(){
|
|||
|
||||
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();
|
||||
|
||||
RESETCOLOR;
|
||||
|
@ -85,7 +86,7 @@ void displaygpio(){
|
|||
}
|
||||
}
|
||||
|
||||
int dumpfirmware(){
|
||||
int dumpfirmware(int mmc){
|
||||
DIR dir;
|
||||
FILINFO fno;
|
||||
bool fail = false;
|
||||
|
@ -94,14 +95,14 @@ int dumpfirmware(){
|
|||
char sdfolderpath[100] = "";
|
||||
char syspath[100] = "";
|
||||
char sdpath[100] = "";
|
||||
short pkg1ver = returnpkg1ver();
|
||||
pkg1_info pkg1 = returnpkg1info();
|
||||
u32 timer = get_tmr_s();
|
||||
|
||||
clearscreen();
|
||||
connect_mmc(SYSMMC);
|
||||
connect_mmc(mmc);
|
||||
mount_mmc("SYSTEM", 2);
|
||||
|
||||
gfx_printf("PKG1 version: %d\n", pkg1ver);
|
||||
gfx_printf("PKG1 version: %d\n", pkg1.ver);
|
||||
|
||||
ret = f_mkdir("sd:/tegraexplorer");
|
||||
gfx_printf("Creating sd:/tegraexplorer %d\n", ret);
|
||||
|
@ -109,7 +110,7 @@ int dumpfirmware(){
|
|||
ret = f_mkdir("sd:/tegraexplorer/Firmware");
|
||||
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);
|
||||
gfx_printf("Creating %s %d\n", sdfolderpath, ret);
|
||||
|
||||
|
@ -142,10 +143,10 @@ int dumpfirmware(){
|
|||
return fail;
|
||||
}
|
||||
|
||||
void dumpusersaves(){
|
||||
void dumpusersaves(int mmc){
|
||||
int res;
|
||||
|
||||
connect_mmc(SYSMMC);
|
||||
connect_mmc(mmc);
|
||||
mount_mmc("USER", 2);
|
||||
clearscreen();
|
||||
|
||||
|
|
|
@ -3,5 +3,5 @@
|
|||
void displayinfo();
|
||||
void displaygpio();
|
||||
int format(int mode);
|
||||
int dumpfirmware();
|
||||
void dumpusersaves();
|
||||
int dumpfirmware(int mmc);
|
||||
void dumpusersaves(int mmc);
|
Loading…
Reference in a new issue