diff --git a/source/libs/fatfs/ff.c b/source/libs/fatfs/ff.c index e171ccb..5ab596e 100644 --- a/source/libs/fatfs/ff.c +++ b/source/libs/fatfs/ff.c @@ -6105,10 +6105,10 @@ FRESULT f_fdisk ( void* work /* Pointer to the working buffer (null: use heap memory) */ ) { - UINT i, n, sz_cyl, tot_cyl, b_cyl, e_cyl, p_cyl; + UINT i, n, sz_cyl, tot_cyl, e_cyl; BYTE s_hd, e_hd, *p, *buf = (BYTE*)work; DSTATUS stat; - DWORD sz_disk, sz_part, s_part; + DWORD sz_disk, sz_part, s_part, p_cyl, b_cyl; FRESULT res; @@ -6134,17 +6134,17 @@ FRESULT f_fdisk ( mem_set(buf, 0, FF_MAX_SS); p = buf + MBR_Table; b_cyl = 0; for (i = 0; i < 4; i++, p += SZ_PTE) { - p_cyl = (szt[i] <= 100U) ? (DWORD)tot_cyl * (szt[i] / 100) : szt[i] / sz_cyl; /* Number of cylinders */ + p_cyl = (szt[i] <= 100U) ? (DWORD)tot_cyl * (szt[i] / 100) : szt[i]; // sz_cyl; /* Number of cylinders */ if (p_cyl == 0) continue; - s_part = (DWORD)sz_cyl * b_cyl; - sz_part = (DWORD)sz_cyl * p_cyl; + s_part = /*(DWORD)sz_cyl * */ b_cyl; + sz_part = /* (DWORD)sz_cyl * */ p_cyl; if (i == 0) { /* Exclude first track of cylinder 0 */ s_hd = 1; s_part += 32768; sz_part -= 32768; } else { s_hd = 0; } - e_cyl = b_cyl + p_cyl - 1; /* End cylinder */ + e_cyl = (b_cyl + p_cyl - 1) / sz_cyl; /* End cylinder */ if (e_cyl >= tot_cyl) LEAVE_MKFS(FR_INVALID_PARAMETER); diff --git a/source/tegraexplorer/emmc.c b/source/tegraexplorer/emmc.c index 611b2bd..a75496f 100644 --- a/source/tegraexplorer/emmc.c +++ b/source/tegraexplorer/emmc.c @@ -77,6 +77,7 @@ short returnpkg1ver(){ } void disconnect_emmc(){ + f_unmount("emmc:"); sdmmc_storage_end(&storage); } diff --git a/source/tegraexplorer/gfx.c b/source/tegraexplorer/gfx.c index e65e892..d6edbb1 100644 --- a/source/tegraexplorer/gfx.c +++ b/source/tegraexplorer/gfx.c @@ -26,7 +26,7 @@ void clearscreen(){ gfx_clear_grey(0x1B); gfx_box(0, 0, 719, 15, COLOR_WHITE); gfx_con_setpos(0, 0); - gfx_printf("%k%KTegraexplorer v1.1.0%k%K\n", COLOR_DEFAULT, COLOR_WHITE, COLOR_WHITE, COLOR_DEFAULT); + gfx_printf("%k%KTegraexplorer v1.1.1%k%K\n", COLOR_DEFAULT, COLOR_WHITE, COLOR_WHITE, COLOR_DEFAULT); } int message(char* message, u32 color){ diff --git a/source/tegraexplorer/tools.c b/source/tegraexplorer/tools.c index bda3463..cb1df22 100644 --- a/source/tegraexplorer/tools.c +++ b/source/tegraexplorer/tools.c @@ -145,7 +145,7 @@ int format(int mode){ int res; bool fatalerror = false; DWORD plist[] = {666, 61145088}; - u32 timer, totalsectors; + u32 timer, totalsectors, alignedsectors, extrasectors; BYTE work[FF_MAX_SS]; DWORD clustsize = 32768; BYTE formatoptions = 0; @@ -163,8 +163,12 @@ int format(int mode){ fatalerror = true; } else { - plist[0] = totalsectors - 61145088; - gfx_printf("\nStarting SD partitioning:\nTotalSectors: %d\nPartition1 (SD): %d\nPartition2 (EMUMMC): %d\n", totalsectors, plist[0], plist[1]); + totalsectors -= plist[1]; + alignedsectors = (totalsectors / 2048) * 2048; + extrasectors = totalsectors - alignedsectors; + plist[0] = alignedsectors; + plist[1] += extrasectors; + gfx_printf("\nStarting SD partitioning:\nTotalSectors: %d\nPartition1 (SD): %d\nPartition2 (EMUMMC): %d\n", plist[0] + plist[1], plist[0], plist[1]); } } else {