Heavy SYSNAND SD stuff

This commit is contained in:
Naim2000 2024-09-08 16:49:01 -05:00
parent 39d1567708
commit 4cc92f8319

View File

@ -5,9 +5,44 @@
# Credits: GM9Megascript contributors ("Scripts from Plailect's Guide"), Mr. Burguers (SD card capacity check), ihaveamac (title.db stuff)
rm -o -s 0:/luma/payloads/finalize_helper.firm
rm -o -s 0:/luma/payloads/*_finalize_helper.firm
set PREVIEW_MODE "> Checking for problems...\nAsking for permission... ---\nInstalling homebrew... ---\nCopying GodMode9 to CTRNAND... ---\nCleaning up SD card... ---\nBacking up essential.exefs... ---\nBacking up NAND... ---"
# Check for missing essentials
# BuildEssentialBackup() will return 1 (failure) if any of these files are missing. As well as nand_hdr.bin, but like lol
set MISSINGESSENTIAL ""
set SEED ""
if find -s 1:/rw/sys/SecureInfo_A NULL
elif find -s 1:/rw/sys/SecureInfo_B NULL
else set MISSINGESSENTIAL "$[MISSINGESSENTIAL]SecureInfo\n" # Does GodMode9 support \t
end
if find -s 1:/rw/sys/LocalFriendCodeSeed_B NULL
elif find -s 1:/rw/sys/LocalFriendCodeSeed_A NULL
else set MISSINGESSENTIAL "$[MISSINGESSENTIAL]LocalFriendCodeSeed\n"
end
if find -s 1:/private/movable.sed SEED
else set MISSINGESSENTIAL "$[MISSINGESSENTIAL]movable.sed\n"
end
# Check for missing essential.exefs
if not find S:/essential.exefs NULL
if chk -u $[MISSINGESSENTIAL] ""
# <IMAGE>
echo "Fatal Error: Missing console-unique files\n \nThe following files are missing from the NAND:\n$[MISSINGESSENTIAL]\n \nPlease ask for help on Discord:\nhttps://discord.gg/MWxPgEp"
poweroff
else
set PREVIEW_MODE "0:/finalize/img/error02.png"
echo "Error #02: Missing essential.exefs\n \nessential.exefs does not exist.\nClose and re-open GodMode9,\nmaking sure to say Yes to the\n'Create essential files' popup."
poweroff
end
end
# Check for missing Nintendo 3DS folder
if not find "0:/Nintendo 3DS" NULL
@ -17,9 +52,39 @@ if not find "0:/Nintendo 3DS" NULL
goto NOSPACE
end
# Check for and attempt to fix edited MSET9
# Okay, at this point, we have the Nintendo 3DS folder. But do we have A: ?
if find "0:/Nintendo 3DS/$[SYSID0]/????????????????????????????????_user-id1" CURRENT
@IS_SYSNAND_SD_OK
if isdir A:
goto SYSNAND_SD_OK
end
# We don't. Why not?
if not shaget $[SEED]@110:10 NULL # This should end up failing normally if SEED is "". I'd hope. Someone test this.
# <IMAGE>
echo "Fatal Error: Missing encryption key\n \nThe system is missing movable.sed from NAND.\n(How did this happen...?)\n \nPlease ask for help on Discord:\nhttps://discord.gg/MWxPgEp"
# At this stage, we have essential.exefs.
# I could copy it. But how do we know that this isn't like, a failed/cancelled Manual Movable Moveover? The user might have been doing something.
poweroff
end
# Okay, we have an ID0. Is it there?
if not find "0:/Nintendo 3DS/$[SYSID0]" SYSID0PATH
if find 0:/finalize/nospace NULL
goto NOSPACE
end
# <Image?>
echo "Information: Empty Nintendo 3DS folder\n \nThe Nintendo 3DS folder does not have any data for this console.\nPlease let your 3DS reach the HOME menu, then run this script again."
reboot
end
# Check for and attempt to fix edited MSET9 ID1
if find "$[SYSID0PATH]/????????????????????????????????_user-id1" CURRENT
set PREVIEW_MODE "0:/finalize/img/error18a.png"
echo "Error #18a: MSET9 detected\n \nID1 still affected by MSET9.\nAttempting to fix it.\n \nPress (A) to continue, then\nenter the key combo if prompted."
allow "0:/Nintendo 3DS"
@ -29,7 +94,7 @@ if find "0:/Nintendo 3DS/$[SYSID0]/????????????????????????????????_user-id1" CU
echo "Fatal Error #19a: Could not remove MSET9\n \nFailed to rename ID1.\nPlease remove MSET9 manually.\nIf you continue to see this prompt,\nask for help on Discord:\nhttps://discord.gg/MWxPgEp"
poweroff
end
if find "0:/Nintendo 3DS/$[SYSID0]/*sdmc*b9" MSET9ID1
if find "$[SYSID0PATH]/*sdmc*b9" MSET9ID1
if not rm -s $[MSET9ID1]
set PREVIEW_MODE "0:/finalize/img/error19b.png"
echo "Fatal Error #19b: Could not remove MSET9\n \nFailed to remove hax'd ID1.\nPlease remove MSET9 manually.\nIf you continue to see this prompt,\nask for help on Discord:\nhttps://discord.gg/MWxPgEp"
@ -41,7 +106,7 @@ end
# Check for and attempt to delete hax'd MSET9
if find "0:/Nintendo 3DS/$[SYSID0]/*sdmc*b9" MSET9ID1
if find "$[SYSID0PATH]/*sdmc*b9" MSET9ID1
set PREVIEW_MODE "0:/finalize/img/error18b.png"
echo "Error #18b: MSET9 detected\n \nMSET9 hax'd ID1 is still present.\n \nAttempting to fix it.\n \nPress (A) to continue, then\nenter the key combo if prompted."
allow "0:/Nintendo 3DS"
@ -58,15 +123,16 @@ end
if chk $[FIXEDMSET9] YES
set PREVIEW_MODE "0:/finalize/img/mset9_reinsert.png"
switchsd "MSET9 has been removed.\n \nEject and reinsert your SD card to continue."
goto IS_SYSNAND_SD_OK
end
# Check for missing essential.exefs
# SYSID0 path exists at this point, yet not SYSNAND SD. Why?
if not find S:/essential.exefs NULL
set PREVIEW_MODE "0:/finalize/img/error02.png"
echo "Error #02: Missing essential.exefs\n \nessential.exefs does not exist.\nClose and re-open GodMode9,\nmaking sure to say Yes to the\n'Create essential files' popup."
poweroff
end
# <IMAGE>
echo "Error: Nintendo 3DS folder is inaccessible\n \nGodMode9 is unable to access the Nintendo 3DS folder properly.\n(How did this happen..?)\n \nAsk for help on Discord:\nhttps://discord.gg/MWxPgEp"
poweroff
@SYSNAND_SD_OK
# Check for sufficient SD space
@ -97,6 +163,7 @@ else
goto SDFREE_NEXT
end
end
fdummy -o -s 0:/finalize/nospace 400
if chk $[ONTYPE] O3DS
set PREVIEW_MODE "0:/finalize/img/error04.png"
echo "Error #04: No space\n \nInsufficient space on SD card.\nYou need 1.0GB, but you have $[SDFREE].\nMake some space, then try again.\n \nTIP: You can temporarily remove the Nintendo 3DS\nand DCIM folders from your SD card\nto make enough space."