From b3282abbf709d2a07ad12f42129f32f8e68de6eb Mon Sep 17 00:00:00 2001 From: TuxSH <1922548+TuxSH@users.noreply.github.com> Date: Mon, 4 Aug 2025 17:03:47 +0200 Subject: [PATCH] Patch lgy k11 to avoid allocating unused pages (bug) which was preventing 2 threads to be created --- arm9/source/patches.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/arm9/source/patches.c b/arm9/source/patches.c index 53f37dba..44d01926 100644 --- a/arm9/source/patches.c +++ b/arm9/source/patches.c @@ -850,6 +850,17 @@ u32 patchLgyK11(u8 *section1, u32 section1Size, u8 *section2, u32 section2Size) if ((u8 *)off3 >= section1 + section1Size) return 1; off3[2] = 0x2001; // movs r0, #1 + + // Patch kernel to avoid allocating the two "configuration memory" pages, freeing + // 0x2000 bytes of kernel "heap" (which is 0xD000 AXIWRAM bytes on LGY K11 instead + // of the entire FCRAM on NFIRM). This is indeed a bug because if prevents two of the + // 12 KThread objects from being created + u16 *off4; + for (off4 = (u16 *)section1; (u8 *)off4 <= section1 + section1Size && (off4[0] != 0xB570 || off4[1] != 0x2200); off4++); + if ((u8 *)off4 >= section1 + section1Size) + return 1; + *off4 = 0x4770; // bx lr + return 0; }