diff --git a/include/arm11/menu/menu_fb3ds.h b/include/arm11/menu/menu_fb3ds.h index 6f072bc..6a92d41 100644 --- a/include/arm11/menu/menu_fb3ds.h +++ b/include/arm11/menu/menu_fb3ds.h @@ -33,8 +33,6 @@ } \ } -#define LOREM "Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata" - #define DESC_CONTINUE "Continue booting the first available boot slot.\nNo function if boot slots are not set up." #define DESC_BOOT_MENU "Display a boot menu, allowing you to select which boot slot to boot from. Also includes boot slot and boot mode setup." #define DESC_BOOT_FILE "Select a firmware file to boot." @@ -43,7 +41,7 @@ #define DESC_MISC "Enter miscellaneous submenu, including the update tool and credits section." #define DESC_BOOT_SLOT(x) "Boot the firmware in slot #" #x "." -#define DESC_BOOT_FIRM1 "Boot the firmware in FIRM1." +#define DESC_BOOT_FIRM1 "Boot the firmware in firm1:." #define DESC_BOOT_SETUP "Change boot settings." #define DESC_SLOT_SETUP(x) "Change boot settings for slot #" #x "." @@ -60,7 +58,13 @@ #define DESC_NAND_BACKUP "Backup current NAND to a file." #define DESC_NAND_RESTORE "Restore current NAND from a file.\nThis option preserves your fastboot3ds installation." #define DESC_NAND_RESTORE_F "Restore current NAND from a file.\nWARNING: This will overwrite all of your flash memory, also overwriting fastboot3ds." -#define DESC_FIRM_FLASH "Flash firmware from file to FIRM1.\nWARNING: This will allow you to flash unsigned firmware, overwriting anything previously installed in FIRM1." +#define DESC_FIRM_FLASH "Flash firmware from file to firm1:.\nWARNING: This will allow you to flash unsigned firmware, overwriting anything previously installed in firm1:." + +#define DESC_UPDATE "Update fastboot3ds. Only signed updates are allowed." +#define DESC_CREDITS "Show fastboot3ds credits." + +// unused definitions below: +#define LOREM "Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata" #define DESC_CHANGE_BRIGHT "Change fastboot3ds brightness. This may also affect firmware launched from within fastboot3ds." #define DESC_SET_CONTIG "Enable/disable contiguous NAND backups.\nContiguous NAND backups may be required on certain CFWs to be bootable from SD cards." @@ -68,9 +72,6 @@ #define DESC_ENABLE_CONTIG "Select to enable contiguous NAND backups." #define DESC_DISABLE_CONTIG "Select to disable contiguous NAND backups." -#define DESC_UPDATE "Update fastboot3ds. Only signed updates are allowed." -#define DESC_CREDITS "Show fastboot3ds credits." - MenuInfo menu_fb3ds[] = { @@ -91,7 +92,7 @@ { "Boot [slot 1]", DESC_BOOT_SLOT(1), &menuLaunchFirm, 0x00 }, { "Boot [slot 2]", DESC_BOOT_SLOT(2), &menuLaunchFirm, 0x01 }, { "Boot [slot 3]", DESC_BOOT_SLOT(3), &menuLaunchFirm, 0x02 }, - { "Boot from FIRM1", DESC_BOOT_FIRM1, &menuLaunchFirm, 0xFE }, + { "Boot from firm1:", DESC_BOOT_FIRM1, &menuLaunchFirm, 0xFE }, { "Boot setup...", DESC_BOOT_SETUP, NULL, 2 } } @@ -122,13 +123,13 @@ { "Backup NAND", DESC_NAND_BACKUP, &menuBackupNand, 0 }, { "Restore NAND", DESC_NAND_RESTORE, &menuRestoreNand, 0 }, { "Restore NAND (forced)", DESC_NAND_RESTORE_F, &menuRestoreNand, 1 }, - { "Flash firmware to FIRM1", DESC_FIRM_FLASH, &menuInstallFirm, 1 } + { "Flash firmware to firm1:", DESC_FIRM_FLASH, &menuInstallFirm, 1 } } }, { // 8 "Miscellaneous", 2, NULL, 0, { - { "Update fastboot3DS", DESC_UPDATE, &menuInstallFirm, 0 }, + { "Update fastboot3DS", DESC_UPDATE, &menuUpdateFastboot3ds, 0 }, { "Credits", DESC_CREDITS, &menuShowCredits, 0 } } }, diff --git a/include/arm11/menu/menu_func.h b/include/arm11/menu/menu_func.h index 50616e7..ec2addb 100644 --- a/include/arm11/menu/menu_func.h +++ b/include/arm11/menu/menu_func.h @@ -39,6 +39,7 @@ u32 menuBackupNand(PrintConsole* term_con, PrintConsole* menu_con, u32 param); u32 menuRestoreNand(PrintConsole* term_con, PrintConsole* menu_con, u32 param); u32 menuInstallFirm(PrintConsole* term_con, PrintConsole* menu_con, u32 param); +u32 menuUpdateFastboot3ds(PrintConsole* term_con, PrintConsole* menu_con, u32 param); u32 menuContinueBoot(PrintConsole* term_con, PrintConsole* menu_con, u32 param); u32 menuShowCredits(PrintConsole* term_con, PrintConsole* menu_con, u32 param); diff --git a/source/arm11/menu/menu_func.c b/source/arm11/menu/menu_func.c index a203107..3042d1b 100644 --- a/source/arm11/menu/menu_func.c +++ b/source/arm11/menu/menu_func.c @@ -615,7 +615,8 @@ u32 menuInstallFirm(PrintConsole* term_con, PrintConsole* menu_con, u32 param) { - bool to_firm1 = param; + char firm_drv[8] = { 'f', 'i', 'r', 'm', '0' + param, ':', '\0' }; + char firm_path[256]; u32 result = 1; @@ -629,24 +630,18 @@ goto fail; } - - char firm_path[256]; - - ee_printf_screen_center("%s\nPress [HOME] to cancel.", - to_firm1 ? "Select a firmware file to install." : - "Select fastboot3DS update file."); + // file selector + ee_printf_screen_center("Select a firmware file to install.\nPress [HOME] to cancel."); updateScreens(); - if (!menuFileSelector(firm_path, menu_con, NULL, "*.firm", true)) return 1; // cancel by user - // select & clear console + // load and install firm consoleSelect(term_con); consoleClear(); - ee_printf(ESC_SCHEME_ACCENT1 "%s:\n%s\n" ESC_RESET "\nLoading firmware... ", - (to_firm1) ? "Flashing firmware to FIRM1" : "Updating fastboot3DS from file", firm_path); + ee_printf(ESC_SCHEME_ACCENT1 "Flashing firmware to %s:\n%s\n" ESC_RESET "\nLoading firmware... ", firm_drv, firm_path); updateScreens(); s32 res = loadVerifyFirm(firm_path, false); @@ -660,7 +655,7 @@ ee_printf(ESC_SCHEME_GOOD "OK\n" ESC_RESET "Flashing firmware... "); updateScreens(); - res = writeFirmPartition(to_firm1 ? "firm1:" : "firm0:"); + res = writeFirmPartition(firm_drv); if (res != 0) { ee_printf(ESC_SCHEME_BAD "failed!\n" ESC_RESET); @@ -669,7 +664,9 @@ } ee_printf(ESC_SCHEME_GOOD "OK\n" ESC_RESET); - ee_printf(ESC_SCHEME_GOOD "\n%s was updated\n" ESC_RESET, to_firm1 ? "Firmware in FIRM1" : "fastboot3DS"); + ee_printf(ESC_SCHEME_GOOD "\nFirmware in %s was flashed.\n" ESC_RESET, firm_drv); + result = 0; + fail: @@ -683,7 +680,83 @@ u32 menuUpdateFastboot3ds(PrintConsole* term_con, PrintConsole* menu_con, u32 param) { - return menuDummyFunc(term_con, menu_con, param); + (void) param; + + char firm_path[256]; + u32 result = 1; + + + // file browser dialogue + consoleSelect(term_con); + consoleClear(); + + ee_printf_screen_center("Select fastboot3DS update file.\nPress [HOME] to cancel."); + updateScreens(); + if (!menuFileSelector(firm_path, menu_con, NULL, "*.firm", true)) + return 1; // cancel by user + + + // verify and install update + consoleSelect(term_con); + consoleClear(); + + ee_printf(ESC_SCHEME_ACCENT1 "Updating fastboot3DS from file:\n%s\n" ESC_RESET "\nLoading firmware... ", firm_path); + updateScreens(); + + u32 version = 0; + s32 res = loadVerifyUpdate(firm_path, &version); + if (res != 0) + { + ee_printf(ESC_SCHEME_BAD "failed!\n" ESC_RESET); + switch ( res ) + { + case UPDATE_ERR_INVALID_FIRM: + ee_printf("Firm validation failed.\n"); + break; + + case UPDATE_ERR_INVALID_SIG: + ee_printf("Not a fastboot3DS update firmware.\n"); + break; + + case UPDATE_ERR_DOWNGRADE: + ee_printf("A newer version is already installed.\n"); + break; + + case UPDATE_ERR_NOT_INSTALLED: + ee_printf("Update is not possible.\n"); + break; + + default: + ee_printf("Update error code %li!\n", res); + break; + } + goto fail; + } + + ee_printf(ESC_SCHEME_GOOD "v%lu.%lu\n" ESC_RESET "Flashing firmware... ", (version >> 16) & 0xFFFF, version & 0xFFFF); + updateScreens(); + + res = writeFirmPartition("firm0:"); + if (res != 0) + { + ee_printf(ESC_SCHEME_BAD "failed!\n" ESC_RESET); + ee_printf("Firm flash error code %li!\n", res); + goto fail; + } + + ee_printf(ESC_SCHEME_GOOD "OK\n" ESC_RESET); + ee_printf(ESC_SCHEME_GOOD "\nfastboot3DS was updated.\n" ESC_RESET); + result = 0; + + + fail: + + ee_printf("\nPress B or HOME to return."); + updateScreens(); + outputEndWait(); + + + return result; } u32 menuShowCredits(PrintConsole* term_con, PrintConsole* menu_con, u32 param)