diff --git a/Makefile b/Makefile index eab63ab..f6407b1 100644 --- a/Makefile +++ b/Makefile @@ -10,7 +10,7 @@ OBJCOPY = $(DEVKITARM)/bin/arm-none-eabi-objcopy name := ReiNX ver_major := 2 -ver_minor := 3 +ver_minor := 4 dir_source := src dir_data := data diff --git a/NX_Sysmodules b/NX_Sysmodules index ad6dbcb..d435873 160000 --- a/NX_Sysmodules +++ b/NX_Sysmodules @@ -1 +1 @@ -Subproject commit ad6dbcb0dd113062a6ba2d34ceaf275faf2c8acb +Subproject commit d435873fddd4a1983fd5332e38980266518f6846 diff --git a/data/es_patch.rxp b/data/es_patch.rxp index 81f3b51..0483eff 100644 Binary files a/data/es_patch.rxp and b/data/es_patch.rxp differ diff --git a/src/bootloader.h b/src/bootloader.h index e70ed0b..1fd8755 100644 --- a/src/bootloader.h +++ b/src/bootloader.h @@ -31,6 +31,7 @@ static const pk11_offs _pk11_offs[] = { { "20181218175730", KB_FIRMWARE_VERSION_700, HOS_FIRMWARE_VERSION_700, 0x0F00, 0x6FE0, { 1, 2, 0 }, 0x40030000, 0x4003E000 }, //7.0.0 { "20190208150037", KB_FIRMWARE_VERSION_701, HOS_FIRMWARE_VERSION_700, 0x0F00, 0x6FE0, { 1, 2, 0 }, 0x40030000, 0x4003E000 }, //7.0.1 { "20190314172056", KB_FIRMWARE_VERSION_800, HOS_FIRMWARE_VERSION_800, 0x0E00, 0x6FE0, { 1, 2, 0 }, 0x40030000, 0x4003E000 }, //8.0.0 + { "20190531152432", KB_FIRWAMRE_VERSION_810, HOS_FIRMWARE_VERSION_810, 0x0E00, 0x6FE0, { 1, 2, 0 }, 0x4002B000, 0x4003E000 }, //8.1.0 { NULL } // End. }; diff --git a/src/firmware.c b/src/firmware.c index 4455481..0ab3322 100644 --- a/src/firmware.c +++ b/src/firmware.c @@ -91,7 +91,7 @@ u8 loadFirm() { } else { if(!has_keygen_ran()) - reboot_to_sept(pkg1ldr + pk11Offs->tsec_off); + reboot_to_sept(pkg1ldr + pk11Offs->tsec_off, pk11Offs->hos); else se_aes_unwrap_key(8, 12, pk21_keyseed); } diff --git a/src/hwinit/se.c b/src/hwinit/se.c index 18e9d9a..1f07003 100644 --- a/src/hwinit/se.c +++ b/src/hwinit/se.c @@ -163,6 +163,7 @@ int se_aes_unwrap_key(u32 ks_dst, u32 ks_src, const void *input) { SE(SE_CONFIG_REG_OFFSET) = SE_CONFIG_DEC_ALG(ALG_AES_DEC) | SE_CONFIG_DST(DST_KEYTAB); SE(SE_CRYPTO_REG_OFFSET) = SE_CRYPTO_KEY_INDEX(ks_src) | SE_CRYPTO_CORE_SEL(CORE_DECRYPT); + SE(0x318) = 0; SE(SE_CRYPTO_KEYTABLE_DST_REG_OFFSET) = SE_CRYPTO_KEYTABLE_DST_KEY_INDEX(ks_dst); return _se_execute(OP_START, NULL, 0, input, 0x10); } diff --git a/src/hwinit/types.h b/src/hwinit/types.h index f5a432e..05bee2b 100644 --- a/src/hwinit/types.h +++ b/src/hwinit/types.h @@ -59,6 +59,7 @@ enum KB_FIRMWARE_VERSION { KB_FIRMWARE_VERSION_700 = 7, KB_FIRMWARE_VERSION_701 = 7, KB_FIRMWARE_VERSION_800 = 7, + KB_FIRWAMRE_VERSION_810 = 8, }; enum HOS_FIRMWARE_VERSION { @@ -70,7 +71,8 @@ enum HOS_FIRMWARE_VERSION { HOS_FIRMWARE_VERSION_600 = 6, HOS_FIRMWARE_VERSION_620 = 7, HOS_FIRMWARE_VERSION_700 = 8, - HOS_FIRMWARE_VERSION_800 = 9, + HOS_FIRMWARE_VERSION_800 = 9, + HOS_FIRMWARE_VERSION_810 = 10, }; #endif diff --git a/src/kippatches/fs.inc b/src/kippatches/fs.inc index 66d415e..4a83890 100644 --- a/src/kippatches/fs.inc +++ b/src/kippatches/fs.inc @@ -240,6 +240,18 @@ static kipdiff_t fs_diffs_800_exfat_nogc[3] = { { 0, 0, NULL, NULL } }; +static kipdiff_t fs_diffs_810_nosigchk[3] = { + { 0x7630C, 4, "\x51\x44\x00\x94", "\xE0\x03\x1F\x2A" }, + { 0xF49A4, 4, "\xC0\x03\x00\x36", "\x1F\x20\x03\xD5" }, + { 0, 0, NULL, NULL }, +}; + +static kipdiff_t fs_diffs_810_exfat_nosigchk[3] = { + { 0x818BC, 4, "\x51\x44\x00\x94", "\xE0\x03\x1F\x2A" }, + { 0xFFF54, 4, "\xC0\x03\x00\x36", "\x1F\x20\x03\xD5" }, + { 0, 0, NULL, NULL }, +}; + /* patches */ static kippatch_t fs_kip_patches_100[] = { @@ -351,4 +363,14 @@ static kippatch_t fs_kip_patches_800_exfat[] = { { "nosigchk", fs_diffs_800_exfat_nosigchk }, { "nogc", fs_diffs_800_exfat_nogc }, { NULL, NULL } +}; + +static kippatch_t fs_kip_patches_810[] = { + { "nosigchk", fs_diffs_810_nosigchk }, + { NULL, NULL } +}; + +static kippatch_t fs_kip_patches_810_exfat[] = { + { "nosigchk", fs_diffs_810_exfat_nosigchk }, + { NULL, NULL } }; \ No newline at end of file diff --git a/src/package.c b/src/package.c index bd2f4a6..baa39a2 100644 --- a/src/package.c +++ b/src/package.c @@ -327,6 +327,8 @@ kippatchset_t kip_patches[] = { { "FS", "\x2c\xce\x65\x9c\xec\x53\x6a\x8e\x4d\x91\xf3\xbe\x4b\x74\xbe\xd3", fs_kip_patches_700_exfat }, { "FS", "\xb2\xf5\x17\x6b\x35\x48\x36\x4d\x07\x9a\x29\xb1\x41\xa2\x3b\x06", fs_kip_patches_800 }, { "FS", "\xdb\xd9\x41\xc0\xc5\x3c\x52\xcc\xf7\x20\x2c\x84\xd8\xe0\xf7\x80", fs_kip_patches_800_exfat }, + { "FS", "\x6b\x09\xb6\x7b\x29\xc0\x20\x24\x6d\xc3\x4f\x5a\x04\xf5\xd3\x09", fs_kip_patches_810 }, + { "FS", "\xb4\xca\xe1\xf2\x49\x65\xd9\x2e\xd2\x4e\xbe\x9e\x97\xf6\x09\xc3", fs_kip_patches_810_exfat }, { NULL, NULL, NULL }, }; diff --git a/src/patches.c b/src/patches.c index 3c10350..24d6fc6 100644 --- a/src/patches.c +++ b/src/patches.c @@ -17,7 +17,6 @@ #include "patches.h" void patchFS(pkg2_kip1_info_t* ki) { - print("Patching FS\n"); u8 kipHash[0x20]; @@ -216,6 +215,7 @@ void patchSecmon(u32 secmonBase, u32 fw){ } } + void patchKernel(pkg2_hdr_t *pkg2){ //Patch Kernel if(!hasCustomKern()) { diff --git a/src/sept.c b/src/sept.c index 362c722..e971504 100644 --- a/src/sept.c +++ b/src/sept.c @@ -16,6 +16,7 @@ */ #include "sept.h" +#include "hwinit/types.h" static u8 warmboot_reboot[] = { 0x14, 0x00, 0x9F, 0xE5, // LDR R0, =0x7000E450 @@ -35,6 +36,7 @@ int has_keygen_ran() { if(keys_generated == 1) return keys_generated; int has_ran = PMC(APBDEV_PMC_SCRATCH49) == 67; + PMC(APBDEV_PMC_SCRATCH49) = 0; keys_generated = has_ran; return has_ran; } @@ -60,12 +62,12 @@ void reloc_patcher(u32 payload_dst, u32 payload_src, u32 payload_size) } } -int reboot_to_sept(const u8 *tsec_fw) +int reboot_to_sept(const u8 *tsec_fw, u32 hosver) { // Copy warmboot reboot code and TSEC fw. memcpy((u8 *)(SEPT_PK1T_ADDR - WB_RST_SIZE), (u8 *)warmboot_reboot, sizeof(warmboot_reboot)); - memcpy((void *)SEPT_PK1T_ADDR, tsec_fw, 0x3000); - *(vu32 *)SEPT_TCSZ_ADDR = 0x3000; + memcpy((void *)SEPT_PK1T_ADDR, tsec_fw, hosver == HOS_FIRMWARE_VERSION_800 ? 0x3000 : 0x3300); + *(vu32 *)SEPT_TCSZ_ADDR = hosver == HOS_FIRMWARE_VERSION_800 ? 0x3000 : 0x3300; // Copy sept-primary. fopen("/sept/sept-primary.bin", "rb"); @@ -73,7 +75,16 @@ int reboot_to_sept(const u8 *tsec_fw) fclose(); // Copy sept-secondary. - fopen("/sept/sept-secondary.enc", "rb"); + char *sec_path; + switch(hosver) { + case HOS_FIRMWARE_VERSION_800: + sec_path = "/sept/sept-secondary_00.enc"; + break; + case HOS_FIRMWARE_VERSION_810: + sec_path = "/sept/sept-secondary_01.enc"; + break; + } + fopen(sec_path, "rb"); fread((u8 *)SEPT_STG2_ADDR, fsize(), 1); fclose(); diff --git a/src/sept.h b/src/sept.h index 5e755ea..fc1c24c 100644 --- a/src/sept.h +++ b/src/sept.h @@ -40,4 +40,4 @@ int has_keygen_ran(); void reloc_patcher(u32 payload_dst, u32 payload_src, u32 payload_size); -int reboot_to_sept(const u8 *tsec_fw); \ No newline at end of file +int reboot_to_sept(const u8 *tsec_fw, u32 hosver); \ No newline at end of file