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:
Such Meme, Many Skill
2020-01-30 23:53:27 +01:00
parent 9885308bce
commit eb8652c6ec
10 changed files with 75 additions and 28 deletions

View File

@@ -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);
@@ -205,7 +205,8 @@ 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;
}

View File

@@ -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();

View File

@@ -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,14 +200,16 @@ 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);
@@ -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);
@@ -240,9 +242,13 @@ int copy_recursive(char *path, char *dstpath){
free(startpath);
free(destpath);
free(destfoldername);
if (f_stat(startpath, &fno))
return 22;
if ((res = f_chmod(destpath, fno.fattrib, 0x3A)))
return res;
return 0;
}

View File

@@ -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;

View File

@@ -46,6 +46,4 @@ enum formatmenu_return {
FORMAT_ALL_FAT32
};
//menu_item mainmenu[MAINMENU_AMOUNT];
void te_main();

View File

@@ -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();

View File

@@ -3,5 +3,5 @@
void displayinfo();
void displaygpio();
int format(int mode);
int dumpfirmware();
void dumpusersaves();
int dumpfirmware(int mmc);
void dumpusersaves(int mmc);