mirror of
https://github.com/suchmememanyskill/TegraExplorer.git
synced 2024-11-26 05:42:07 +00:00
Add experimental emummc formatter
This commit is contained in:
parent
57714daa87
commit
73a6fc460b
7 changed files with 107 additions and 14 deletions
|
@ -49,6 +49,11 @@
|
|||
|
||||
---------------------------------------------------------------------------*/
|
||||
|
||||
PARTITION VolToPart[2] = {
|
||||
{0, 1},
|
||||
{1, 1}
|
||||
};
|
||||
|
||||
#if FF_DEFINED != 86604 /* Revision ID */
|
||||
#error Wrong include file (ff.h).
|
||||
#endif
|
||||
|
@ -6039,7 +6044,7 @@ FRESULT f_mkfs (
|
|||
sys = 0x07; /* HPFS/NTFS/exFAT */
|
||||
} else {
|
||||
if (fmt == FS_FAT32) {
|
||||
sys = 0x0C; /* FAT32X */
|
||||
sys = 0x0B; /* FAT32X */
|
||||
} else {
|
||||
if (sz_vol >= 0x10000) {
|
||||
sys = 0x06; /* FAT12/16 (large) */
|
||||
|
@ -6117,12 +6122,13 @@ FRESULT f_fdisk (
|
|||
e_hd = (BYTE)(n - 1);
|
||||
sz_cyl = 63 * n;
|
||||
tot_cyl = sz_disk / sz_cyl;
|
||||
gfx_printf("tot_cyl: %d\nsz_disk: %d\nsz_cyl: %d\n", tot_cyl, sz_disk, sz_cyl);
|
||||
|
||||
/* Create partition table */
|
||||
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;
|
||||
|
|
|
@ -38,7 +38,7 @@
|
|||
/ f_findnext(). (0:Disable, 1:Enable 2:Enable with matching altname[] too) */
|
||||
|
||||
|
||||
#define FF_USE_MKFS 0
|
||||
#define FF_USE_MKFS 1
|
||||
/* This option switches f_mkfs() function. (0:Disable or 1:Enable) */
|
||||
|
||||
|
||||
|
@ -169,6 +169,7 @@
|
|||
|
||||
#define FF_STR_VOLUME_ID 1
|
||||
#define FF_VOLUME_STRS "sd", "emmc"
|
||||
|
||||
/* FF_STR_VOLUME_ID switches support for volume ID in arbitrary strings.
|
||||
/ When FF_STR_VOLUME_ID is set to 1 or 2, arbitrary strings can be used as drive
|
||||
/ number in the path name. FF_VOLUME_STRS defines the volume ID strings for each
|
||||
|
@ -181,7 +182,7 @@
|
|||
*/
|
||||
|
||||
|
||||
#define FF_MULTI_PARTITION 0
|
||||
#define FF_MULTI_PARTITION 1
|
||||
/* This option switches support for multiple volumes on the physical drive.
|
||||
/ By default (0), each logical drive number is bound to the same physical drive
|
||||
/ number and only an FAT volume found on the physical drive will be mounted.
|
||||
|
|
|
@ -206,9 +206,9 @@ void filemenu(const char *startpath){
|
|||
else
|
||||
explfilemenu[7].property = -1;
|
||||
|
||||
res = makemenu(explfilemenu, 8);
|
||||
tempint = makemenu(explfilemenu, 8);
|
||||
|
||||
switch (res){
|
||||
switch (tempint){
|
||||
case COPY:
|
||||
writeclipboard(getnextloc(currentpath, fileobjects[res - 1].name), false, false);
|
||||
break;
|
||||
|
@ -218,8 +218,8 @@ void filemenu(const char *startpath){
|
|||
case DELETE:
|
||||
msleep(100);
|
||||
sprintf(temp, "Do you want to delete:\n%s\n\nPress Power to confirm\nPress Vol+/- to cancel", fileobjects[res - 1].name);
|
||||
res = message(temp, COLOR_RED);
|
||||
if (res & BTN_POWER){
|
||||
tempint = message(temp, COLOR_RED);
|
||||
if (tempint & BTN_POWER){
|
||||
f_unlink(getnextloc(currentpath, fileobjects[res - 1].name));
|
||||
amount = readfolder(currentpath);
|
||||
}
|
||||
|
|
|
@ -30,11 +30,12 @@ menu_item shutdownmenu[7] = {
|
|||
{"Reboot to Atmosphere", COLOR_GREEN, AMS, -1}
|
||||
};
|
||||
|
||||
menu_item toolsmenu[4] = {
|
||||
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}
|
||||
{"Display GPIO pins [DEV]", COLOR_RED, DISPLAY_GPIO, 1},
|
||||
{"FORMAT TEST", COLOR_RED, FORMATFAT32, 1}
|
||||
};
|
||||
|
||||
void fillmainmenu(){
|
||||
|
@ -88,7 +89,7 @@ void te_main(){
|
|||
break;
|
||||
|
||||
case TOOLS:
|
||||
res = makemenu(toolsmenu, 4);
|
||||
res = makemenu(toolsmenu, 5);
|
||||
|
||||
if (res == DISPLAY_INFO)
|
||||
displayinfo();
|
||||
|
@ -96,6 +97,9 @@ void te_main(){
|
|||
if (res == DISPLAY_GPIO)
|
||||
displaygpio();
|
||||
|
||||
if (res == FORMATFAT32)
|
||||
format();
|
||||
|
||||
break;
|
||||
|
||||
case CREDITS:
|
||||
|
|
|
@ -30,7 +30,8 @@ enum shutdownmenu_return {
|
|||
|
||||
enum toolsmenu_return {
|
||||
DISPLAY_INFO = 1,
|
||||
DISPLAY_GPIO
|
||||
DISPLAY_GPIO,
|
||||
FORMATFAT32
|
||||
};
|
||||
|
||||
//menu_item mainmenu[MAINMENU_AMOUNT];
|
||||
|
|
|
@ -5,12 +5,16 @@
|
|||
#include "../utils/btn.h"
|
||||
#include "../soc/gpio.h"
|
||||
#include "../utils/util.h"
|
||||
#include "../utils/types.h"
|
||||
|
||||
extern bool sd_mount();
|
||||
extern void sd_unmount();
|
||||
|
||||
void displayinfo(){
|
||||
clearscreen();
|
||||
|
||||
FATFS *fs;
|
||||
DWORD fre_clust, fre_sect, tot_sect;
|
||||
DWORD fre_clust, fre_sect, tot_sect, temp_sect;
|
||||
int res;
|
||||
|
||||
gfx_printf("Getting storage info: please wait...");
|
||||
|
@ -23,6 +27,11 @@ void displayinfo(){
|
|||
|
||||
gfx_printf("%d KiB total\n%d KiB free\n\nPress any key to continue\n", tot_sect / 2, fre_sect / 2);
|
||||
|
||||
temp_sect = tot_sect;
|
||||
temp_sect -= 61145088;
|
||||
|
||||
gfx_printf("\n1st part: %d\n2nd part: 61145088", temp_sect);
|
||||
|
||||
btn_wait();
|
||||
}
|
||||
|
||||
|
@ -46,3 +55,74 @@ void displaygpio(){
|
|||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void format(){
|
||||
clearscreen();
|
||||
int res;
|
||||
|
||||
u32 timer;
|
||||
FATFS *fs;
|
||||
DWORD fre_clust, tot_sect, temp_sect;
|
||||
BYTE work[FF_MAX_SS];
|
||||
DWORD plist[] = {188928257, 61145089, 0};
|
||||
DWORD sectsize = 16 * 512;
|
||||
BYTE formatoptions = 0;
|
||||
formatoptions |= (FM_FAT32);
|
||||
formatoptions |= (FM_SFD);
|
||||
|
||||
timer = get_tmr_s();
|
||||
gfx_printf("Getting free cluster info from 1st partition");
|
||||
|
||||
if (res = f_getfree("sd:", &fre_clust, &fs))
|
||||
gfx_printf("%kGetfree failed! errcode %d", COLOR_RED, res);
|
||||
else {
|
||||
tot_sect = (fs->n_fatent - 2) * fs->csize;
|
||||
temp_sect = tot_sect;
|
||||
temp_sect -= 61145089;
|
||||
gfx_printf("Total sectors: %d\nFree after emummc: %d\n\n", tot_sect, temp_sect);
|
||||
if (temp_sect < 0)
|
||||
gfx_printf("%kNot enough space free!\n", COLOR_RED);
|
||||
else {
|
||||
gfx_printf("Partitioning sd...\nPartition1 size: %d\nPartition2 size: %d\n", plist[0], plist[1]);
|
||||
plist[0] = temp_sect;
|
||||
if (res = f_fdisk(0, plist, &work))
|
||||
gfx_printf("Partitioning failed! errcode %d\n", res);
|
||||
else {
|
||||
gfx_printf("\nFormatting FAT32 Partition:\n");
|
||||
if (res = f_mkfs("0:", formatoptions, sectsize, &work, sizeof work))
|
||||
gfx_printf("%kFormat failed! errcode %d\n", res);
|
||||
else {
|
||||
gfx_printf("Smells like a formatted SD\n\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!res){
|
||||
sd_unmount();
|
||||
if (!sd_mount())
|
||||
gfx_printf("%kSd failed to mount!\n", COLOR_ORANGE);
|
||||
else {
|
||||
gfx_printf("Sd mounted!\n");
|
||||
}
|
||||
}
|
||||
|
||||
gfx_printf("\nPress any button to return%k\nTotal time taken: %ds", COLOR_WHITE, (get_tmr_s() - timer));
|
||||
btn_wait();
|
||||
|
||||
/*
|
||||
res = f_fdisk(0, plist, &work);
|
||||
gfx_printf("f_fdisk partdrive: %d\n", res);
|
||||
|
||||
if (!res){
|
||||
res = f_mkfs("0:", muhoptions, sectsize, &work, sizeof work);
|
||||
gfx_printf("f_mkfs0 res: %d\n", res);
|
||||
}
|
||||
|
||||
sd_unmount();
|
||||
res = sd_mount();
|
||||
|
||||
gfx_printf("sd_mount res: %s", (res ? "1" : "0"));
|
||||
btn_wait();
|
||||
*/
|
||||
}
|
|
@ -2,3 +2,4 @@
|
|||
|
||||
void displayinfo();
|
||||
void displaygpio();
|
||||
void format();
|
Loading…
Reference in a new issue