Skip to content
This repository has been archived by the owner on Oct 17, 2020. It is now read-only.

Commit

Permalink
8.1 support
Browse files Browse the repository at this point in the history
  • Loading branch information
EliseZeroTwo committed Jun 21, 2019
1 parent 2a9b9e2 commit c2f4645
Show file tree
Hide file tree
Showing 12 changed files with 49 additions and 10 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Binary file modified data/es_patch.rxp
Binary file not shown.
1 change: 1 addition & 0 deletions src/bootloader.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
};

Expand Down
2 changes: 1 addition & 1 deletion src/firmware.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
1 change: 1 addition & 0 deletions src/hwinit/se.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
4 changes: 3 additions & 1 deletion src/hwinit/types.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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
22 changes: 22 additions & 0 deletions src/kippatches/fs.inc
Original file line number Diff line number Diff line change
Expand Up @@ -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[] = {
Expand Down Expand Up @@ -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 }
};
2 changes: 2 additions & 0 deletions src/package.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 },
};

Expand Down
2 changes: 1 addition & 1 deletion src/patches.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
#include "patches.h"

void patchFS(pkg2_kip1_info_t* ki) {

print("Patching FS\n");

u8 kipHash[0x20];
Expand Down Expand Up @@ -216,6 +215,7 @@ void patchSecmon(u32 secmonBase, u32 fw){
}
}


void patchKernel(pkg2_hdr_t *pkg2){
//Patch Kernel
if(!hasCustomKern()) {
Expand Down
19 changes: 15 additions & 4 deletions src/sept.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
*/

#include "sept.h"
#include "hwinit/types.h"

static u8 warmboot_reboot[] = {
0x14, 0x00, 0x9F, 0xE5, // LDR R0, =0x7000E450
Expand All @@ -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;
}
Expand All @@ -60,20 +62,29 @@ 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");
fread((u8 *)SEPT_STG1_ADDR, fsize(), 1);
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();

Expand Down
2 changes: 1 addition & 1 deletion src/sept.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
int reboot_to_sept(const u8 *tsec_fw, u32 hosver);

0 comments on commit c2f4645

Please # to comment.