Skip to content
This repository was archived by the owner on Jan 11, 2021. It is now read-only.

Commit 90c574e

Browse files
committed
add new3ds 9.6 firmware support
add new3ds 10.2 firmware support built with ctrulib 1.0.0 update makerom.exe
1 parent eeb1d5d commit 90c574e

File tree

6 files changed

+67
-43
lines changed

6 files changed

+67
-43
lines changed

lib/ctrcommon/tools/makerom.exe

-86.9 KB
Binary file not shown.

release/BootNTR-Mode3.cia

-13.5 KB
Binary file not shown.

release/BootNTR.cia

-13.5 KB
Binary file not shown.

source/main.c

+66-12
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ void bnInitParamsByFirmware() {
171171
{
172172
u8 tmp;
173173

174-
Result ret = APT_CheckNew3DS(0, &tmp);;
174+
Result ret = APT_CheckNew3DS(&tmp);;
175175
if (ret == 0)
176176
{
177177
if (tmp) {
@@ -276,6 +276,36 @@ void bnInitParamsByFirmware() {
276276
bnConfig->FSPatchAddr = 0x0010ED64;
277277
bnConfig->SMPatchAddr = 0x00101838 ;
278278
}
279+
280+
if (kernelVersion == SYSTEM_VERSION(2, 50, 1)) {
281+
//new3ds 9.6
282+
ntrConfig->firmVersion = SYSTEM_VERSION(9, 6, 0);
283+
ntrConfig->PMSvcRunAddr = 0x001030D8;
284+
ntrConfig->ControlMemoryPatchAddr1 = 0xdff8850C;
285+
ntrConfig->ControlMemoryPatchAddr2 = 0xdff88510;
286+
287+
bnConfig->SvcPatchAddr = 0xDFF82268;
288+
bnConfig->FSPatchAddr = 0x0010EFAC;
289+
bnConfig->SMPatchAddr = 0x0010189C;
290+
}
291+
292+
if (kernelVersion == SYSTEM_VERSION(2, 50, 7)) {
293+
// new3ds 10.0
294+
//TODO: add new3ds 10.0 firmware support
295+
ntrConfig->firmVersion = SYSTEM_VERSION(10, 0, 0);
296+
}
297+
298+
if (kernelVersion == SYSTEM_VERSION(2, 50, 9)) {
299+
// new3ds 10.2
300+
ntrConfig->firmVersion = SYSTEM_VERSION(10, 2, 0);
301+
ntrConfig->PMSvcRunAddr = 0x001031E4;
302+
ntrConfig->ControlMemoryPatchAddr1 = 0xdff884E4;
303+
ntrConfig->ControlMemoryPatchAddr2 = 0xdff884E8;
304+
305+
bnConfig->SvcPatchAddr = 0xDFF82270;
306+
bnConfig->FSPatchAddr = 0x0010EED4;
307+
bnConfig->SMPatchAddr = 0x0010189C;
308+
}
279309
}
280310
bnConfig->requireKernelHax = 0;
281311
}
@@ -562,6 +592,22 @@ dbgKernelCacheInterface cacheInterface_NEW95 = {
562592
(void*)0xFFF1FCE8
563593
};
564594

595+
dbgKernelCacheInterface cacheInterface_NEW96 = {
596+
//for new3ds 9.6
597+
(void*)0xFFF25C24,
598+
(void*)0xFFF1D9D4,
599+
(void*)0xFFF1D67C,
600+
(void*)0xFFF1FD10
601+
};
602+
603+
dbgKernelCacheInterface cacheInterface_NEW102 = {
604+
//for new3ds 10.2
605+
(void*)0xFFF25BFC,
606+
(void*)0xFFF1D9AC,
607+
(void*)0xFFF1D654,
608+
(void*)0xFFF1FCE8
609+
};
610+
565611
dbgKernelCacheInterface cacheInterface_Old96 = {
566612
//for old 3ds 9.6
567613
(void*)0xFFF24FF0,
@@ -594,6 +640,10 @@ void kernelCallback() {
594640
cache = &cacheInterface_NEW92;
595641
else if (firmVersion == SYSTEM_VERSION(9, 5, 0))
596642
cache = &cacheInterface_NEW95;
643+
else if (firmVersion == SYSTEM_VERSION(9, 6, 0))
644+
cache = &cacheInterface_NEW96;
645+
else if (firmVersion == SYSTEM_VERSION(10, 2, 0))
646+
cache = &cacheInterface_NEW102;
597647
}
598648
else
599649
{
@@ -664,8 +714,8 @@ Result bnLoadAndExecuteNTR() {
664714
u32 ret;
665715

666716

667-
fsInit();
668-
FILE *file = fopen("ntr.bin","rb");
717+
// fsInit();
718+
FILE *file = fopen("sdmc:/ntr.bin","rb");
669719
if (file == 0) {
670720
printf("open ntr.bin failed\n");
671721
return RESULT_ERROR;
@@ -681,22 +731,24 @@ Result bnLoadAndExecuteNTR() {
681731
ntrConfig->arm11BinSize = rtAlignToPageSize(size);
682732
u32 outAddr;
683733
u32 totalSize = (ntrConfig->arm11BinSize) * 2;
684-
ret = svc_controlMemory((u32*)&outAddr, 0, 0, totalSize, 0x10003, 3);
685-
if (ret != 0) {
686-
printf("svc_controlMemory failed: %08x\n", ret);
734+
// use linearMemAlign instead of svc_controlMemory
735+
outAddr = (u32)linearMemAlign(totalSize, 0x1000);
736+
if (outAddr == 0) {
737+
printf("linearMemAlign failed\n");
687738
return RESULT_ERROR;
688739
}
740+
689741
ntrConfig->arm11BinStart = (outAddr + ntrConfig->arm11BinSize);
690742
rtCheckRemoteMemoryRegionSafeForWrite(getCurrentProcessHandle(), outAddr, totalSize);
691743
printf("outAddr: %08x\n", outAddr);
692744
memset((void*) outAddr, 0, totalSize);
693745
fread((void*) outAddr, size, 1, file);
694746
memcpy((void*) (outAddr +(ntrConfig->arm11BinSize)), (void*) outAddr, size);
695-
fsExit();
747+
// fsExit();
696748

697-
Handle fsUserHandle;
749+
Handle fsUserHandle = 0;
698750
ret=srvGetServiceHandle(&fsUserHandle, "fs:USER");
699-
FSUSER_Initialize(&fsUserHandle);
751+
FSUSER_Initialize(fsUserHandle);
700752
ntrConfig->fsUserHandle = fsUserHandle;
701753

702754
u32* bootArgs = outAddr + 4;
@@ -743,11 +795,13 @@ Result bnBootNTR() {
743795

744796

745797
// allocate the tmpBuffer
746-
ret = svc_controlMemory((u32*)&tmpBuffer, 0, 0, TMPBUFFER_SIZE, 0x10003, 3);
747-
if (ret != 0) {
748-
printf("svc_controlMemory failed: %08x\n", ret);
798+
// use linearMemAlign instead of svc_controlMemory
799+
tmpBuffer = (u32)linearMemAlign(TMPBUFFER_SIZE, 0x1000);
800+
if (tmpBuffer == 0) {
801+
printf("linearMemAlign failed\n");
749802
return RESULT_ERROR;
750803
}
804+
751805
printf("tmpBuffer: %08x\n", tmpBuffer);
752806

753807
bnInitParamsByFirmware();

template-cia-0.rsf

-15
Original file line numberDiff line numberDiff line change
@@ -21,21 +21,6 @@ Option:
2121
EnableCrypt : false # Enables encryption for NCCH and CIA
2222
EnableCompress : true # Compresses exefs code
2323

24-
ExeFs: # these are the program segments from the ELF, check your elf for the appropriate segment names
25-
ReadOnly:
26-
- .rodata
27-
- RO
28-
ReadWrite:
29-
- .data
30-
- RO
31-
Text:
32-
- .init
33-
- .text
34-
- STUP_ENTRY
35-
36-
PlainRegion: # only used with SDK ELFs
37-
#- .module_id
38-
3924
#Rom:
4025
# Specifies the root path of the file system to include in the ROM.
4126
# HostRoot : "romfs"

template-cia-3.rsf

+1-16
Original file line numberDiff line numberDiff line change
@@ -21,21 +21,6 @@ Option:
2121
EnableCrypt : false # Enables encryption for NCCH and CIA
2222
EnableCompress : true # Compresses exefs code
2323

24-
ExeFs: # these are the program segments from the ELF, check your elf for the appropriate segment names
25-
ReadOnly:
26-
- .rodata
27-
- RO
28-
ReadWrite:
29-
- .data
30-
- RO
31-
Text:
32-
- .init
33-
- .text
34-
- STUP_ENTRY
35-
36-
PlainRegion: # only used with SDK ELFs
37-
#- .module_id
38-
3924
#Rom:
4025
# Specifies the root path of the file system to include in the ROM.
4126
# HostRoot : "romfs"
@@ -83,7 +68,7 @@ AccessControlInfo:
8368
# - CreateSeed
8469
# - UseCardSpi
8570

86-
SystemMode: 3
71+
SystemMode: 80MB
8772
IdealProcessor : 0
8873
AffinityMask : 1
8974

0 commit comments

Comments
 (0)