Skip to content

Commit

Permalink
emummc: Fix emupath folder and add more checks
Browse files Browse the repository at this point in the history
The checks are checking if the emuMMC was found. If it didn't  and error will be show.
  • Loading branch information
CTCaer committed May 5, 2020
1 parent 5b91c54 commit 7543234
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 14 deletions.
34 changes: 23 additions & 11 deletions bootloader/main.c
Expand Up @@ -465,8 +465,11 @@ void ini_list_launcher()
}
}

if (emummc_path)
emummc_set_path(emummc_path);
if (emummc_path && !emummc_set_path(emummc_path))
{
EPRINTF("emupath is wrong!");
goto wrong_emupath;
}

if (cfg_sec && !payload_path)
check_sept(cfg_sec);
Expand Down Expand Up @@ -497,15 +500,13 @@ void ini_list_launcher()
}
else if (!hos_launch(cfg_sec))
{
EPRINTF("Failed to launch firmware.");

wrong_emupath:
EPRINTF("Failed to launch HOS.");
if (emummc_path)
{
sd_mount();
emummc_load_cfg();
}

btn_wait();
}

out:
Expand Down Expand Up @@ -605,8 +606,11 @@ void launch_firmware()
}
}

if (emummc_path)
emummc_set_path(emummc_path);
if (emummc_path && !emummc_set_path(emummc_path))
{
EPRINTF("emupath is wrong!");
goto wrong_emupath;
}

if (cfg_sec && !payload_path)
check_sept(cfg_sec);
Expand Down Expand Up @@ -642,7 +646,8 @@ void launch_firmware()
}
else if (!hos_launch(cfg_sec))
{
EPRINTF("Failed to launch firmware.");
wrong_emupath:
EPRINTF("Failed to launch HOS.");
if (emummc_path)
{
sd_mount();
Expand Down Expand Up @@ -1034,8 +1039,13 @@ static void _auto_launch_firmware()
{
if (b_cfg.boot_cfg & BOOT_CFG_TO_EMUMMC)
emummc_set_path(b_cfg.emummc_path);
else if (emummc_path)
emummc_set_path(emummc_path);
else if (emummc_path && !emummc_set_path(emummc_path))
{
gfx_con.mute = false;
EPRINTF("emupath is wrong!");
goto wrong_emupath;
}

check_sept(cfg_sec);
hos_launch(cfg_sec);

Expand All @@ -1045,6 +1055,8 @@ static void _auto_launch_firmware()
emummc_load_cfg();
}

wrong_emupath:
display_backlight_brightness(h_cfg.backlight, 1000);
EPRINTF("\nFailed to launch HOS!");
gfx_printf("\nPress any key...\n");
msleep(500);
Expand Down
6 changes: 4 additions & 2 deletions bootloader/storage/emummc.c
Expand Up @@ -72,7 +72,7 @@ void emummc_load_cfg()
}
}

void emummc_set_path(char *path)
bool emummc_set_path(char *path)
{
FIL fp;
bool found = false;
Expand Down Expand Up @@ -105,8 +105,10 @@ void emummc_set_path(char *path)
emu_cfg.enabled = 1;
emu_cfg.id = 0;
strcpy(emu_cfg.nintendo_path, path);
strcpy(emu_cfg.nintendo_path, "/Nintendo");
strcat(emu_cfg.nintendo_path, "/Nintendo");
}

return found;
}

static int emummc_raw_get_part_off(int part_idx)
Expand Down
2 changes: 1 addition & 1 deletion bootloader/storage/emummc.h
Expand Up @@ -50,7 +50,7 @@ typedef struct _emummc_cfg_t
emummc_cfg_t emu_cfg;

void emummc_load_cfg();
void emummc_set_path(char *path);
bool emummc_set_path(char *path);
int emummc_storage_init_mmc(sdmmc_storage_t *storage, sdmmc_t *sdmmc);
int emummc_storage_end(sdmmc_storage_t *storage);
int emummc_storage_read(sdmmc_storage_t *storage, u32 sector, u32 num_sectors, void *buf);
Expand Down

0 comments on commit 7543234

Please sign in to comment.