mirror of
https://github.com/suchmememanyskill/TegraExplorer.git
synced 2024-11-09 13:41:45 +00:00
Make the user able to format without a valid partition
This commit is contained in:
parent
d1678be654
commit
12802bf371
2 changed files with 19 additions and 12 deletions
|
@ -45,11 +45,20 @@
|
||||||
sdmmc_t sd_sdmmc;
|
sdmmc_t sd_sdmmc;
|
||||||
sdmmc_storage_t sd_storage;
|
sdmmc_storage_t sd_storage;
|
||||||
__attribute__ ((aligned (16))) FATFS sd_fs;
|
__attribute__ ((aligned (16))) FATFS sd_fs;
|
||||||
static bool sd_mounted;
|
static bool sd_mounted, sd_inited;
|
||||||
volatile nyx_storage_t *nyx_str = (nyx_storage_t *)NYX_STORAGE_ADDR;
|
volatile nyx_storage_t *nyx_str = (nyx_storage_t *)NYX_STORAGE_ADDR;
|
||||||
hekate_config h_cfg;
|
hekate_config h_cfg;
|
||||||
boot_cfg_t __attribute__((section ("._boot_cfg"))) b_cfg;
|
boot_cfg_t __attribute__((section ("._boot_cfg"))) b_cfg;
|
||||||
|
|
||||||
|
bool return_sd_mounted(int value){
|
||||||
|
switch(value){
|
||||||
|
case 1:
|
||||||
|
return sd_mounted;
|
||||||
|
case 5:
|
||||||
|
return sd_inited;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bool sd_mount()
|
bool sd_mount()
|
||||||
{
|
{
|
||||||
if (sd_mounted)
|
if (sd_mounted)
|
||||||
|
@ -58,9 +67,11 @@ bool sd_mount()
|
||||||
if (!sdmmc_storage_init_sd(&sd_storage, &sd_sdmmc, SDMMC_1, SDMMC_BUS_WIDTH_4, 11))
|
if (!sdmmc_storage_init_sd(&sd_storage, &sd_sdmmc, SDMMC_1, SDMMC_BUS_WIDTH_4, 11))
|
||||||
{
|
{
|
||||||
EPRINTF("Failed to init SD card.\nMake sure that it is inserted.\nOr that SD reader is properly seated!");
|
EPRINTF("Failed to init SD card.\nMake sure that it is inserted.\nOr that SD reader is properly seated!");
|
||||||
|
sd_inited = false;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
sd_inited = true;
|
||||||
int res = 0;
|
int res = 0;
|
||||||
res = f_mount(&sd_fs, "sd:", 1);
|
res = f_mount(&sd_fs, "sd:", 1);
|
||||||
if (res == FR_OK)
|
if (res == FR_OK)
|
||||||
|
@ -84,6 +95,7 @@ void sd_unmount()
|
||||||
f_mount(NULL, "sd:", 1);
|
f_mount(NULL, "sd:", 1);
|
||||||
sdmmc_storage_end(&sd_storage);
|
sdmmc_storage_end(&sd_storage);
|
||||||
sd_mounted = false;
|
sd_mounted = false;
|
||||||
|
sd_inited = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -10,8 +10,8 @@
|
||||||
|
|
||||||
extern bool sd_mount();
|
extern bool sd_mount();
|
||||||
extern void sd_unmount();
|
extern void sd_unmount();
|
||||||
|
extern bool return_sd_mounted(int value);
|
||||||
extern int launch_payload(char *path);
|
extern int launch_payload(char *path);
|
||||||
bool sd_mounted;
|
|
||||||
|
|
||||||
menu_item mainmenu[MAINMENU_AMOUNT] = {
|
menu_item mainmenu[MAINMENU_AMOUNT] = {
|
||||||
{"[SD:/] SD CARD", COLOR_GREEN, SD_CARD, 1},
|
{"[SD:/] SD CARD", COLOR_GREEN, SD_CARD, 1},
|
||||||
|
@ -55,13 +55,13 @@ void fillmainmenu(){
|
||||||
switch (i + 1) {
|
switch (i + 1) {
|
||||||
case 1:
|
case 1:
|
||||||
case 5:
|
case 5:
|
||||||
if (sd_mounted)
|
if (return_sd_mounted(i + 1))
|
||||||
mainmenu[i].property = 1;
|
mainmenu[i].property = 1;
|
||||||
else
|
else
|
||||||
mainmenu[i].property = -1;
|
mainmenu[i].property = -1;
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
if (sd_mounted){
|
if (return_sd_mounted(1)){
|
||||||
mainmenu[i].property = 2;
|
mainmenu[i].property = 2;
|
||||||
strcpy(mainmenu[i].name, "\nUnmount SD");
|
strcpy(mainmenu[i].name, "\nUnmount SD");
|
||||||
}
|
}
|
||||||
|
@ -84,8 +84,6 @@ void te_main(){
|
||||||
else {
|
else {
|
||||||
mount_emmc("SYSTEM", 2);
|
mount_emmc("SYSTEM", 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
sd_mounted = sd_mount();
|
|
||||||
|
|
||||||
while (1){
|
while (1){
|
||||||
fillmainmenu();
|
fillmainmenu();
|
||||||
|
@ -106,12 +104,10 @@ void te_main(){
|
||||||
break;
|
break;
|
||||||
*/
|
*/
|
||||||
case MOUNT_SD:
|
case MOUNT_SD:
|
||||||
if (sd_mounted){
|
if (return_sd_mounted(1))
|
||||||
sd_mounted = false;
|
|
||||||
sd_unmount();
|
sd_unmount();
|
||||||
}
|
|
||||||
else
|
else
|
||||||
sd_mounted = sd_mount();
|
sd_mount();
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -138,7 +134,6 @@ void te_main(){
|
||||||
if(makewaitmenu("Are you sure you want to format your sd?\nThis will delete everything on your SD card\nThis action is irreversible!\n\nPress Vol+/- to cancel\n", "Press Power to continue", 10)){
|
if(makewaitmenu("Are you sure you want to format your sd?\nThis will delete everything on your SD card\nThis action is irreversible!\n\nPress Vol+/- to cancel\n", "Press Power to continue", 10)){
|
||||||
if (format(res)){
|
if (format(res)){
|
||||||
sd_unmount();
|
sd_unmount();
|
||||||
sd_mounted = false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -150,7 +145,7 @@ void te_main(){
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case EXIT:
|
case EXIT:
|
||||||
if (sd_mounted){
|
if (return_sd_mounted(1)){
|
||||||
if (checkfile("/bootloader/update.bin"))
|
if (checkfile("/bootloader/update.bin"))
|
||||||
shutdownmenu[5].property = 1;
|
shutdownmenu[5].property = 1;
|
||||||
else
|
else
|
||||||
|
|
Loading…
Reference in a new issue