Make the correct FIRM type always be set and fix loading old NATIVE_FIRMs from SD

This commit is contained in:
Aurora 2016-09-02 15:05:52 +02:00
parent 62a70cfdac
commit 8fd2525cd1

View File

@ -248,15 +248,8 @@ static inline u32 loadFirm(FirmwareType *firmType, FirmwareSource firmSource)
"/luma/firmware_safe.bin" "/luma/firmware_safe.bin"
}; };
u32 firmVersion; u32 firmVersion = firmRead(firm, (u32)*firmType);
bool loadFromSd = false;
//Check that the SD FIRM is right for the console from the ARM9 section address
if(fileRead(firm, firmwareFiles[(u32)*firmType]) &&
((section[3].offset ? section[3].address : section[2].address) == (isN3DS ? (u8 *)0x8006000 : (u8 *)0x8006800)))
firmVersion = 0xFFFFFFFF;
else
{
firmVersion = firmRead(firm, (u32)*firmType);
if(!isN3DS && *firmType == NATIVE_FIRM) if(!isN3DS && *firmType == NATIVE_FIRM)
{ {
@ -271,11 +264,18 @@ static inline u32 loadFirm(FirmwareType *firmType, FirmwareSource firmSource)
*firmType = NATIVE_FIRM1X2X; *firmType = NATIVE_FIRM1X2X;
} }
//We can't boot a 3.x/4.x NATIVE_FIRM //We can't boot a 3.x/4.x NATIVE_FIRM, load it from SD
else if(firmVersion < 0x25) else if(firmVersion < 0x25) loadFromSd = true;
error("An old unsupported FIRM has been detected.\nCopy firmware.bin in /luma to boot");
} }
//Check that the SD FIRM is right for the console from the ARM9 section address
if(fileRead(firm, *firmType == NATIVE_FIRM1X2X ? firmwareFiles[0] : firmwareFiles[(u32)*firmType]) &&
((section[3].offset ? section[3].address : section[2].address) == (isN3DS ? (u8 *)0x8006000 : (u8 *)0x8006800)))
firmVersion = 0xFFFFFFFF;
else
{
if(loadFromSd) error("An old unsupported FIRM has been detected.\nCopy firmware.bin in /luma to boot");
decryptExeFs((u8 *)firm); decryptExeFs((u8 *)firm);
} }