diff --git a/BootLoader/source/main.arm9.c b/BootLoader/source/main.arm9.c index 4203bef..f8bf287 100755 --- a/BootLoader/source/main.arm9.c +++ b/BootLoader/source/main.arm9.c @@ -141,9 +141,6 @@ Written by Darkain, modified by Chishm --------------------------------------------------------------------------*/ void arm9_main (void) { - // volatile u32* SCFG_EXT = (volatile u32*)0x4004008; - // volatile u32* SCFG_CLK = (volatile u32*)0x4004004; - register int i; //set shared ram to ARM7 diff --git a/Makefile b/Makefile index e08eb88..454024e 100755 --- a/Makefile +++ b/Makefile @@ -11,7 +11,7 @@ export TARGET := NTR_Launcher export TOPDIR := $(CURDIR) export VERSION_MAJOR := 1 -export VERSION_MINOR := 96 +export VERSION_MINOR := 97 export VERSTRING := $(VERSION_MAJOR).$(VERSION_MINOR) #--------------------------------------------------------------------------------- @@ -28,7 +28,8 @@ all: $(TARGET).nds $(TARGET).nds : $(TARGET).arm7 $(TARGET).arm9 ndstool -c $(TARGET).nds -7 arm7/$(TARGET).arm7.elf -9 arm9/$(TARGET).arm9.elf \ - -b $(CURDIR)/icon.bmp "NTR Launcher;NitroHax provided by Chishm;Modified by Apache Thunder" + -b $(CURDIR)/icon.bmp "NTR Launcher;NitroHax provided by Chishm;Modified by Apache Thunder" \ + -g KKGP 01 "TWL LAUNCHER" -z 80040000 -u 00030004 #--------------------------------------------------------------------------------- $(TARGET).arm7 : arm7/$(TARGET).elf diff --git a/NTR_Launcher.pnproj b/NTR_Launcher.pnproj deleted file mode 100644 index b92660d..0000000 --- a/NTR_Launcher.pnproj +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/NTR_Launcher.pnps b/NTR_Launcher.pnps deleted file mode 100644 index 247a62a..0000000 --- a/NTR_Launcher.pnps +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/PatchSRL.cmd b/PatchSRL.cmd deleted file mode 100644 index 5f72a60..0000000 --- a/PatchSRL.cmd +++ /dev/null @@ -1,3 +0,0 @@ -@Echo off -patch_ndsheader_dsiware.py NTR_Launcher.nds --mode dsi --maker 01 --code KKGP --title "TWL LAUNCHER" --out NTR_Launcher_Release.nds -pause \ No newline at end of file diff --git a/arm7/Makefile b/arm7/Makefile index 0a85e54..ad6ed29 100755 --- a/arm7/Makefile +++ b/arm7/Makefile @@ -34,7 +34,7 @@ CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions -fno-rtti ASFLAGS := -g $(ARCH) -LDFLAGS = -specs=../ds_arm7_ram.specs -g $(ARCH) -Wl,-Map,$(notdir $*).map +LDFLAGS = -specs=ds_arm7.specs -g $(ARCH) -Wl,-Map,$(notdir $*).map LIBS := -lmm7 -lnds7 diff --git a/arm7/ds_arm7_ram.ld b/arm7/ds_arm7_ram.ld deleted file mode 100644 index 52d6a5e..0000000 --- a/arm7/ds_arm7_ram.ld +++ /dev/null @@ -1,176 +0,0 @@ -OUTPUT_FORMAT("elf32-littlearm", "elf32-bigarm", "elf32-littlearm") -OUTPUT_ARCH(arm) -ENTRY(_start) - -MEMORY { - rom : ORIGIN = 0x08000000, LENGTH = 32M - ram : ORIGIN = 0x2380000, LENGTH = 128K - iwram : ORIGIN = 0x037f8000, LENGTH = 96K -} - -__iwram_start = ORIGIN(iwram); -__iwram_top = ORIGIN(iwram)+ LENGTH(iwram); - -__sp_irq = __iwram_top - 0x100; -__sp_svc = __sp_irq - 0x100; -__sp_usr = __sp_svc - 0x100; - -__irq_flags = 0x04000000 - 8; -__irq_flagsaux = 0x04000000 - 0x40; -__irq_vector = 0x04000000 - 4; - -SECTIONS -{ - .init : - { - __text_start = . ; - KEEP (*(.init)) - . = ALIGN(4); /* REQUIRED. LD is flaky without it. */ - } >ram = 0xff - .plt : { *(.plt) } >ram = 0xff - - .text : /* ALIGN (4): */ - { - *(.text .stub .text.* .gnu.linkonce.t.*) - KEEP (*(.text.*personality*)) - /* .gnu.warning sections are handled specially by elf32.em. */ - *(.gnu.warning) - *(.glue_7t) *(.glue_7) *(.vfp11_veneer) - . = ALIGN(4); /* REQUIRED. LD is flaky without it. */ - } >ram = 0xff - - .fini : - { - KEEP (*(.fini)) - } >ram =0xff - - __text_end = . ; - - .rodata : - { - *(.rodata) - *all.rodata*(*) - *(.roda) - *(.rodata.*) - *(.gnu.linkonce.r*) - SORT(CONSTRUCTORS) - . = ALIGN(4); /* REQUIRED. LD is flaky without it. */ - } >ram = 0xff - - .ARM.extab : { *(.ARM.extab* .gnu.linkonce.armextab.*) } >ram - __exidx_start = .; - .ARM.exidx : { *(.ARM.exidx* .gnu.linkonce.armexidx.*) } >ram - __exidx_end = .; - -/* Ensure the __preinit_array_start label is properly aligned. We - could instead move the label definition inside the section, but - the linker would then create the section even if it turns out to - be empty, which isn't pretty. */ - . = ALIGN(32 / 8); - PROVIDE (__preinit_array_start = .); - .preinit_array : { KEEP (*(.preinit_array)) } >ram = 0xff - PROVIDE (__preinit_array_end = .); - PROVIDE (__init_array_start = .); - .init_array : { KEEP (*(.init_array)) } >ram = 0xff - PROVIDE (__init_array_end = .); - PROVIDE (__fini_array_start = .); - .fini_array : { KEEP (*(.fini_array)) } >ram = 0xff - PROVIDE (__fini_array_end = .); - - .ctors : - { - /* gcc uses crtbegin.o to find the start of the constructors, so - we make sure it is first. Because this is a wildcard, it - doesn't matter if the user does not actually link against - crtbegin.o; the linker won't look for a file to match a - wildcard. The wildcard also means that it doesn't matter which - directory crtbegin.o is in. */ - KEEP (*crtbegin.o(.ctors)) - KEEP (*(EXCLUDE_FILE (*crtend.o) .ctors)) - KEEP (*(SORT(.ctors.*))) - KEEP (*(.ctors)) - . = ALIGN(4); /* REQUIRED. LD is flaky without it. */ - } >ram = 0xff - - .dtors : - { - KEEP (*crtbegin.o(.dtors)) - KEEP (*(EXCLUDE_FILE (*crtend.o) .dtors)) - KEEP (*(SORT(.dtors.*))) - KEEP (*(.dtors)) - . = ALIGN(4); /* REQUIRED. LD is flaky without it. */ - } >ram = 0xff - - .eh_frame : - { - KEEP (*(.eh_frame)) - . = ALIGN(4); /* REQUIRED. LD is flaky without it. */ - } >ram = 0xff - - .gcc_except_table : - { - *(.gcc_except_table) - . = ALIGN(4); /* REQUIRED. LD is flaky without it. */ - } >ram = 0xff - .jcr : { KEEP (*(.jcr)) } >ram = 0 - .got : { *(.got.plt) *(.got) } >ram = 0 - - .data ALIGN(4) : { - __data_start = ABSOLUTE(.); - *(.data) - *(.data.*) - *(.gnu.linkonce.d*) - CONSTRUCTORS - . = ALIGN(4); - __data_end = ABSOLUTE(.) ; - } >ram = 0xff - - .bss ALIGN(4) : - { - __bss_start = ABSOLUTE(.); - __bss_start__ = ABSOLUTE(.); - *(.dynbss) - *(.gnu.linkonce.b*) - *(.bss*) - *(COMMON) - . = ALIGN(4); /* REQUIRED. LD is flaky without it. */ - __bss_end__ = ABSOLUTE(.); - __end__ = ABSOLUTE(.); - } >ram - - /* Stabs debugging sections. */ - .stab 0 : { *(.stab) } - .stabstr 0 : { *(.stabstr) } - .stab.excl 0 : { *(.stab.excl) } - .stab.exclstr 0 : { *(.stab.exclstr) } - .stab.index 0 : { *(.stab.index) } - .stab.indexstr 0 : { *(.stab.indexstr) } - .comment 0 : { *(.comment) } - /* DWARF debug sections. - Symbols in the DWARF debugging sections are relative to the beginning - of the section so we begin them at 0. */ - /* DWARF 1 */ - .debug 0 : { *(.debug) } - .line 0 : { *(.line) } - /* GNU DWARF 1 extensions */ - .debug_srcinfo 0 : { *(.debug_srcinfo) } - .debug_sfnames 0 : { *(.debug_sfnames) } - /* DWARF 1.1 and DWARF 2 */ - .debug_aranges 0 : { *(.debug_aranges) } - .debug_pubnames 0 : { *(.debug_pubnames) } - /* DWARF 2 */ - .debug_info 0 : { *(.debug_info) } - .debug_abbrev 0 : { *(.debug_abbrev) } - .debug_line 0 : { *(.debug_line) } - .debug_frame 0 : { *(.debug_frame) } - .debug_str 0 : { *(.debug_str) } - .debug_loc 0 : { *(.debug_loc) } - .debug_macinfo 0 : { *(.debug_macinfo) } - /* SGI/MIPS DWARF 2 extensions */ - .debug_weaknames 0 : { *(.debug_weaknames) } - .debug_funcnames 0 : { *(.debug_funcnames) } - .debug_typenames 0 : { *(.debug_typenames) } - .debug_varnames 0 : { *(.debug_varnames) } - .stack 0x80000 : { _stack = .; *(.stack) } - /* These must appear regardless of . */ -} diff --git a/arm7/ds_arm7_ram.specs b/arm7/ds_arm7_ram.specs deleted file mode 100644 index c82aa96..0000000 --- a/arm7/ds_arm7_ram.specs +++ /dev/null @@ -1,8 +0,0 @@ -%rename link old_link - -*link: -%(old_link) -T ../ds_arm7_ram.ld%s --gc-sections - -*startfile: -ds_arm7_crt0%O%s crti%O%s crtbegin%O%s - diff --git a/arm7/source/bios.s b/arm7/source/bios.s deleted file mode 100644 index 7b14333..0000000 --- a/arm7/source/bios.s +++ /dev/null @@ -1,61 +0,0 @@ -#define ARM7 - -/*--------------------------------------------------------------------------------- - - Copyright (C) 2009 - Dave Murphy (WinterMute) - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any - damages arising from the use of this software. - - Permission is granted to anyone to use this software for any - purpose, including commercial applications, and to alter it and - redistribute it freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you - must not claim that you wrote the original software. If you use - this software in a product, an acknowledgment in the product - documentation would be appreciated but is not required. - 2. Altered source versions must be plainly marked as such, and - must not be misrepresented as being the original software. - 3. This notice may not be removed or altered from any source - distribution. - ----------------------------------------------------------------------------------*/ - - .text - .align 4 - - .arm -@--------------------------------------------------------------------------------- - .global swiSoftReset2 - .type swiSoftReset2 STT_FUNC -@--------------------------------------------------------------------------------- -swiSoftReset2: -@--------------------------------------------------------------------------------- - REG_IME = 0; -#ifdef ARM7 - ldr r0,=0x2FFFE34 -#endif - -#ifdef ARM9 - .arch armv5te - .cpu arm946e-s - ldr r1, =0x00002078 @ disable TCM and protection unit - mcr p15, 0, r1, c1, c0 - @ Disable cache - mov r0, #0 - mcr p15, 0, r0, c7, c5, 0 @ Instruction cache - mcr p15, 0, r0, c7, c6, 0 @ Data cache - - @ Wait for write buffer to empty - mcr p15, 0, r0, c7, c10, 4 - - ldr r0,=0x2FFFE24 -#endif - - ldr r0,[r0] - bx r0 - - .pool \ No newline at end of file diff --git a/arm7/source/launch_engine_arm7.c b/arm7/source/launch_engine_arm7.c index cc1b530..17d8ee2 100644 --- a/arm7/source/launch_engine_arm7.c +++ b/arm7/source/launch_engine_arm7.c @@ -19,9 +19,9 @@ #include // #define REG_ROMCTRL (*(vu32*)0x40001A4) -#define REG_SCFG_ROM (*(vu32*)0x4004000) -#define REG_SCFG_CLK (*(vu32*)0x4004004) -#define REG_SCFG_EXT (*(vu32*)0x4004008) +// #define REG_SCFG_ROM (*(vu32*)0x4004000) +// #define REG_SCFG_CLK (*(vu32*)0x4004004) +// #define REG_SCFG_EXT (*(vu32*)0x4004008) // #define REG_SCFG_MC (*(vu32*)0x4004010) void runLaunchEngineCheck (void) diff --git a/arm7/source/main.c b/arm7/source/main.c index 1fabe0a..6dc007b 100755 --- a/arm7/source/main.c +++ b/arm7/source/main.c @@ -24,12 +24,6 @@ #include "launch_engine_arm7.h" -#define REG_ROMCTRL (*(vu32*)0x40001A4) -#define REG_SCFG_ROM (*(vu32*)0x4004000) -#define REG_SCFG_CLK (*(vu32*)0x4004004) -#define REG_SCFG_EXT (*(vu32*)0x4004008) -#define REG_SCFG_MC (*(vu32*)0x4004010) - void VcountHandler() { inputGetAndSend(); } diff --git a/arm9/source/bios.s b/arm9/source/bios.s deleted file mode 100644 index 901a831..0000000 --- a/arm9/source/bios.s +++ /dev/null @@ -1,61 +0,0 @@ -#define ARM9 - -/*--------------------------------------------------------------------------------- - - Copyright (C) 2009 - Dave Murphy (WinterMute) - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any - damages arising from the use of this software. - - Permission is granted to anyone to use this software for any - purpose, including commercial applications, and to alter it and - redistribute it freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you - must not claim that you wrote the original software. If you use - this software in a product, an acknowledgment in the product - documentation would be appreciated but is not required. - 2. Altered source versions must be plainly marked as such, and - must not be misrepresented as being the original software. - 3. This notice may not be removed or altered from any source - distribution. - ----------------------------------------------------------------------------------*/ - - .text - .align 4 - - .arm -@--------------------------------------------------------------------------------- - .global swiSoftReset2 - .type swiSoftReset2 STT_FUNC -@--------------------------------------------------------------------------------- -swiSoftReset2: -@--------------------------------------------------------------------------------- - REG_IME = 0; -#ifdef ARM7 - ldr r0,=0x2FFFE34 -#endif - -#ifdef ARM9 - .arch armv5te - .cpu arm946e-s - ldr r1, =0x00002078 @ disable TCM and protection unit - mcr p15, 0, r1, c1, c0 - @ Disable cache - mov r0, #0 - mcr p15, 0, r0, c7, c5, 0 @ Instruction cache - mcr p15, 0, r0, c7, c6, 0 @ Data cache - - @ Wait for write buffer to empty - mcr p15, 0, r0, c7, c10, 4 - - ldr r0,=0x2FFFE24 -#endif - - ldr r0,[r0] - bx r0 - - .pool \ No newline at end of file diff --git a/arm9/source/bootsplash.cpp b/arm9/source/bootsplash.cpp index d4dd4c9..3d760d9 100644 --- a/arm9/source/bootsplash.cpp +++ b/arm9/source/bootsplash.cpp @@ -141,8 +141,6 @@ #define CONSOLE_SCREEN_WIDTH 32 #define CONSOLE_SCREEN_HEIGHT 24 -#define REG_SCFG_MC (*(vu32*)0x4004010) - void vramcpy_ui (void* dest, const void* src, int size) { u16* destination = (u16*)dest; diff --git a/arm9/source/launch_engine.c b/arm9/source/launch_engine.c index 3a0b947..d4a5fa1 100644 --- a/arm9/source/launch_engine.c +++ b/arm9/source/launch_engine.c @@ -24,8 +24,6 @@ #define LCDC_BANK_C (u16*)0x06840000 -#define REG_SCFG_EXT (*(vu32*)0x4004008) - void vramcpy (void* dst, const void* src, int len) { u16* dst16 = (u16*)dst; diff --git a/arm9/source/main.cpp b/arm9/source/main.cpp index ec780b6..7a549ff 100755 --- a/arm9/source/main.cpp +++ b/arm9/source/main.cpp @@ -34,18 +34,13 @@ // #define REG_ROMCTRL (*(vu32*)0x40001A4) // #define REG_SCFG_ROM (*(vu32*)0x4004000) -#define REG_SCFG_CLK (*(vu32*)0x4004004) -#define REG_SCFG_EXT (*(vu32*)0x4004008) -#define REG_SCFG_MC (*(vu32*)0x4004010) +// #define REG_SCFG_CLK (*(vu32*)0x4004004) +// #define REG_SCFG_EXT (*(vu32*)0x4004008) +// #define REG_SCFG_MC (*(vu32*)0x4004010) int main(int argc, const char* argv[]) { - // volatile u32* REG_SCFG_EXT = (volatile u32*)0x4004008; - // volatile u32* REG_SCFG_CLK = (volatile u32*)0x4004004; - // volatile u32* REG_SCFG_MC = (volatile u32*)0x4004010; - // volatile u32* REG_SCFG_ROM = (volatile u32*)0x4004000; - // REG_SCFG_EXT = 0x8307F100; // NTR Mode/Splash used by default diff --git a/ds_arm7_ram.ld b/ds_arm7_ram.ld deleted file mode 100644 index 216ff0e..0000000 --- a/ds_arm7_ram.ld +++ /dev/null @@ -1,176 +0,0 @@ -OUTPUT_FORMAT("elf32-littlearm", "elf32-bigarm", "elf32-littlearm") -OUTPUT_ARCH(arm) -ENTRY(_start) - -MEMORY { - rom : ORIGIN = 0x08000000, LENGTH = 32M - ram : ORIGIN = 0x2380000, LENGTH = 96K - iwram : ORIGIN = 0x037f8000, LENGTH = 96K -} - -__iwram_start = ORIGIN(iwram); -__iwram_top = ORIGIN(iwram)+ LENGTH(iwram); - -__sp_irq = __iwram_top - 0x100; -__sp_svc = __sp_irq - 0x100; -__sp_usr = __sp_svc - 0x100; - -__irq_flags = 0x04000000 - 8; -__irq_flagsaux = 0x04000000 - 0x40; -__irq_vector = 0x04000000 - 4; - -SECTIONS -{ - .init : - { - __text_start = . ; - KEEP (*(.init)) - . = ALIGN(4); /* REQUIRED. LD is flaky without it. */ - } >ram = 0xff - .plt : { *(.plt) } >ram = 0xff - - .text : /* ALIGN (4): */ - { - *(.text .stub .text.* .gnu.linkonce.t.*) - KEEP (*(.text.*personality*)) - /* .gnu.warning sections are handled specially by elf32.em. */ - *(.gnu.warning) - *(.glue_7t) *(.glue_7) *(.vfp11_veneer) - . = ALIGN(4); /* REQUIRED. LD is flaky without it. */ - } >ram = 0xff - - .fini : - { - KEEP (*(.fini)) - } >ram =0xff - - __text_end = . ; - - .rodata : - { - *(.rodata) - *all.rodata*(*) - *(.roda) - *(.rodata.*) - *(.gnu.linkonce.r*) - SORT(CONSTRUCTORS) - . = ALIGN(4); /* REQUIRED. LD is flaky without it. */ - } >ram = 0xff - - .ARM.extab : { *(.ARM.extab* .gnu.linkonce.armextab.*) } >ram - __exidx_start = .; - .ARM.exidx : { *(.ARM.exidx* .gnu.linkonce.armexidx.*) } >ram - __exidx_end = .; - -/* Ensure the __preinit_array_start label is properly aligned. We - could instead move the label definition inside the section, but - the linker would then create the section even if it turns out to - be empty, which isn't pretty. */ - . = ALIGN(32 / 8); - PROVIDE (__preinit_array_start = .); - .preinit_array : { KEEP (*(.preinit_array)) } >ram = 0xff - PROVIDE (__preinit_array_end = .); - PROVIDE (__init_array_start = .); - .init_array : { KEEP (*(.init_array)) } >ram = 0xff - PROVIDE (__init_array_end = .); - PROVIDE (__fini_array_start = .); - .fini_array : { KEEP (*(.fini_array)) } >ram = 0xff - PROVIDE (__fini_array_end = .); - - .ctors : - { - /* gcc uses crtbegin.o to find the start of the constructors, so - we make sure it is first. Because this is a wildcard, it - doesn't matter if the user does not actually link against - crtbegin.o; the linker won't look for a file to match a - wildcard. The wildcard also means that it doesn't matter which - directory crtbegin.o is in. */ - KEEP (*crtbegin.o(.ctors)) - KEEP (*(EXCLUDE_FILE (*crtend.o) .ctors)) - KEEP (*(SORT(.ctors.*))) - KEEP (*(.ctors)) - . = ALIGN(4); /* REQUIRED. LD is flaky without it. */ - } >ram = 0xff - - .dtors : - { - KEEP (*crtbegin.o(.dtors)) - KEEP (*(EXCLUDE_FILE (*crtend.o) .dtors)) - KEEP (*(SORT(.dtors.*))) - KEEP (*(.dtors)) - . = ALIGN(4); /* REQUIRED. LD is flaky without it. */ - } >ram = 0xff - - .eh_frame : - { - KEEP (*(.eh_frame)) - . = ALIGN(4); /* REQUIRED. LD is flaky without it. */ - } >ram = 0xff - - .gcc_except_table : - { - *(.gcc_except_table) - . = ALIGN(4); /* REQUIRED. LD is flaky without it. */ - } >ram = 0xff - .jcr : { KEEP (*(.jcr)) } >ram = 0 - .got : { *(.got.plt) *(.got) } >ram = 0 - - .data ALIGN(4) : { - __data_start = ABSOLUTE(.); - *(.data) - *(.data.*) - *(.gnu.linkonce.d*) - CONSTRUCTORS - . = ALIGN(4); - __data_end = ABSOLUTE(.) ; - } >ram = 0xff - - .bss ALIGN(4) : - { - __bss_start = ABSOLUTE(.); - __bss_start__ = ABSOLUTE(.); - *(.dynbss) - *(.gnu.linkonce.b*) - *(.bss*) - *(COMMON) - . = ALIGN(4); /* REQUIRED. LD is flaky without it. */ - __bss_end__ = ABSOLUTE(.); - __end__ = ABSOLUTE(.); - } >ram - - /* Stabs debugging sections. */ - .stab 0 : { *(.stab) } - .stabstr 0 : { *(.stabstr) } - .stab.excl 0 : { *(.stab.excl) } - .stab.exclstr 0 : { *(.stab.exclstr) } - .stab.index 0 : { *(.stab.index) } - .stab.indexstr 0 : { *(.stab.indexstr) } - .comment 0 : { *(.comment) } - /* DWARF debug sections. - Symbols in the DWARF debugging sections are relative to the beginning - of the section so we begin them at 0. */ - /* DWARF 1 */ - .debug 0 : { *(.debug) } - .line 0 : { *(.line) } - /* GNU DWARF 1 extensions */ - .debug_srcinfo 0 : { *(.debug_srcinfo) } - .debug_sfnames 0 : { *(.debug_sfnames) } - /* DWARF 1.1 and DWARF 2 */ - .debug_aranges 0 : { *(.debug_aranges) } - .debug_pubnames 0 : { *(.debug_pubnames) } - /* DWARF 2 */ - .debug_info 0 : { *(.debug_info) } - .debug_abbrev 0 : { *(.debug_abbrev) } - .debug_line 0 : { *(.debug_line) } - .debug_frame 0 : { *(.debug_frame) } - .debug_str 0 : { *(.debug_str) } - .debug_loc 0 : { *(.debug_loc) } - .debug_macinfo 0 : { *(.debug_macinfo) } - /* SGI/MIPS DWARF 2 extensions */ - .debug_weaknames 0 : { *(.debug_weaknames) } - .debug_funcnames 0 : { *(.debug_funcnames) } - .debug_typenames 0 : { *(.debug_typenames) } - .debug_varnames 0 : { *(.debug_varnames) } - .stack 0x80000 : { _stack = .; *(.stack) } - /* These must appear regardless of . */ -} diff --git a/ds_arm7_ram.specs b/ds_arm7_ram.specs deleted file mode 100644 index 205a47a..0000000 --- a/ds_arm7_ram.specs +++ /dev/null @@ -1,8 +0,0 @@ -%rename link old_link - -*link: -%(old_link) -T ../../ds_arm7_ram.ld%s --gc-sections - -*startfile: -ds_arm7_crt0%O%s crti%O%s crtbegin%O%s - diff --git a/patch_ndsheader_dsiware.py b/patch_ndsheader_dsiware.py deleted file mode 100644 index d53fae9..0000000 --- a/patch_ndsheader_dsiware.py +++ /dev/null @@ -1,554 +0,0 @@ -# -*- coding: utf8 -*- -# Patch an .nds (works with homebrew and ds demo only) to make it ready for make_cia -# -# 2016-02-28, Ahezard -# -# inspired by -# Apache Thunder .nds edited files and comments -# https://github.com/Relys/Project_CTR/blob/master/makerom/srl.h -# https://dsibrew.org/wiki/DSi_Cartridge_Header -# if the header size of the input nds file is 0x200 (homebrew) -# the header size of the output nds file will be patched to 0x4000 (normal ds/dsi header), 0x3E00 offset - -from struct import * -from collections import namedtuple -from collections import OrderedDict -from pprint import pprint -import os, sys -import binascii -import argparse - - -parser = argparse.ArgumentParser(description='Patch an nds in order to be ready cia conversion via make_cia --srl=.') -parser.add_argument('file', metavar='file.nds', type=file, help='nds file to patch') -parser.add_argument('--verbose', help='verbose mode', action="store_true") -parser.add_argument('--out', help='output file [optionnal]') -parser.add_argument('--read', help='print only the header content, do not patch', action="store_true") -parser.add_argument('--extract', help='extract the content of the rom : header.bin,arm9.bin,arm7.bin,icon.bin,arm9i.bin,arm7i.bin, do not patch', action="store_true") #Not yet implemented -parser.add_argument('--title', help='Game title') -parser.add_argument('--code', help='Game code') -parser.add_argument('--maker', help='Maker code') -parser.add_argument('--mode', help='target mode, default mode is ds [ds|dsi|dsinogba]') -parser.add_argument('--arm7', type=file, help='swap the ds arm7 binary by the one provided') -parser.add_argument('--arm7EntryAddress', help='arm7 ram address of the binary provided') -parser.add_argument('--arm9i', type=file, help='add a dsi arm9i binary to the file, not needed for homebrew so far') -parser.add_argument('--arm7i', type=file, help='add a dsi arm7i binary to the file, not needed for homebrew so far') -parser.add_argument('--digest-block', type=file, help='dsi digest block table') #Not yet implemented -parser.add_argument('--digest-sector', type=file, help='dsi digest sector table') #Not yet implemented -args = parser.parse_args() - -if args.mode is None: - args.mode = "ds" - -# -# CRC16 MODULE -# -# includes CRC16 and CRC16 MODBUS -# - -from ctypes import c_ushort - -# from https://github.com/cristianav/PyCRC/blob/master/demo.py -class CRC16(object): - crc16_tab = [] - - # The CRC's are computed using polynomials. Here is the most used - # coefficient for CRC16 - crc16_constant = 0xA001 # 40961 - - def __init__(self, modbus_flag=False): - # initialize the precalculated tables - if not len(self.crc16_tab): - self.init_crc16() - self.mdflag = bool(modbus_flag) - - def calculate(self, input_data=None): - try: - is_string = isinstance(input_data, str) - is_bytes = isinstance(input_data, (bytes, bytearray)) - - if not is_string and not is_bytes: - raise Exception("Please provide a string or a byte sequence " - "as argument for calculation.") - - crc_value = 0x0000 if not self.mdflag else 0xffff - - for c in input_data: - d = ord(c) if is_string else c - tmp = crc_value ^ d - rotated = crc_value >> 8 - crc_value = rotated ^ self.crc16_tab[(tmp & 0x00ff)] - - return crc_value - except Exception as e: - print("EXCEPTION(calculate): {}".format(e)) - - def init_crc16(self): - """The algorithm uses tables with precalculated values""" - for i in range(0, 256): - crc = c_ushort(i).value - for j in range(0, 8): - if crc & 0x0001: - crc = c_ushort(crc >> 1).value ^ self.crc16_constant - else: - crc = c_ushort(crc >> 1).value - self.crc16_tab.append(crc) - -def getSize(fileobject): - current = fileobject.tell() - fileobject.seek(0,2) # move the cursor to the end of the file - size = fileobject.tell() - fileobject.seek(current,0) - return size - -def skipUntilAddress(f_in,f_out, caddr, taddr): - chunk = f_in.read(taddr-caddr) - f_out.write(chunk) - -def writeBlankuntilAddress(f_out, caddr, taddr): - f_out.write("\x00"*(taddr-caddr)) - -fname=args.file.name -args.file.close() - -if not args.read: - print "Patching file : "+fname -else: - print "Reading header of file : "+fname - -#offset of 0x4600 created - -# File size compute -file = open(fname, 'rb') -fsize=getSize(file) -file.close() - -#CRC header compute "CRC-16 (Modbus)" -file = open(fname, 'rb') -#0x15E from https://github.com/devkitPro/ndstool/ ... source/header.cpp -hdr = file.read(0x15E) -hdrCrc=CRC16(modbus_flag=True).calculate(hdr) -if args.verbose: - print("{:10s} {:20X}".format('HDR CRC-16 ModBus', hdrCrc)) -#print "origin header cr c"+hdr[0x15E:0x15F] -#filew = open(fname+".hdr", "wb") -#filew.write(hdr); -#filew.close() -file.close() - -if args.arm7 is not None: - arm7Fname=args.arm7.name - args.arm7.close() - arm7File = open(arm7Fname, 'rb') - arm7FileSize=getSize(arm7File) - dataArm7=arm7File.read(arm7FileSize) - arm7File.close() - -filer = open(fname, 'rb') -data = filer.read(0x180) -caddr=0x180 - -#DS Data 180 bytes -SrlHeader = namedtuple('SrlHeader', - "gameTitle " - "gameCode " - "makerCode " - "unitCode " - "encryptionSeedSelect " - "deviceCapacity " - "reserved0 " - "dsiflags " - "romVersion " - "internalFlag " - "arm9RomOffset " - "arm9EntryAddress " - "arm9RamAddress " - "arm9Size " - "arm7RomOffset " - "arm7EntryAddress " - "arm7RamAddress " - "arm7Size " - "fntOffset " - "fntSize " - "fatOffset " - "fatSize " - "arm9OverlayOffset " - "arm9OverlaySize " - "arm7OverlayOffset " - "arm7OverlaySize " - "normalCardControlRegSettings " - "secureCardControlRegSettings " - "icon_bannerOffset " - "secureAreaCrc " - "secure_transfer_timeout " - "arm9Autoload " - "arm7Autoload " - "secureDisable " - "ntrRomSize " - "headerSize " - "reserved1 " - "nintendoLogo " - "nintendoLogoCrc " - "headerCrc " - "debugReserved ") -srlHeaderFormat='<12s4s2scbb7s2sbcIIIIIIIIIIIIIIIIIIIHHII8sII56s156s2sH32s' -srlHeader=SrlHeader._make(unpack_from(srlHeaderFormat, data)) -if args.verbose: - print "origin header crc "+hex(srlHeader.headerCrc) - print "origin secure crc "+hex(srlHeader.secureAreaCrc) - -#SecureArea CRC compute "CRC-16 (Modbus)" -file = open(fname, 'rb') -#0x15E from https://github.com/devkitPro/ndstool/ ... source/header.cpp -file.read(0x200) -sec = file.read(0x4000) -secCrc=CRC16(modbus_flag=True).calculate(sec) -if args.verbose: - print("{:10s} {:20X}".format('SEC CRC-16 ModBus', secCrc)) -file.close() - -if srlHeader.arm7EntryAddress>0x2400000 and not args.read and args.arm7 is None: - print "WARNING: .nds arm7EntryAddress greater than 0x2400000 will not boot as cia" - print "you need to recompile or swap the arm7 binary with a precompiled one with --arm7 and --arm7EntryAddress" - -# Fix srlHeader -srlHeaderPatched=srlHeader._replace( - secureCardControlRegSettings= 1575160, - normalCardControlRegSettings= 5791744, - internalFlag= '\x00', - arm9RomOffset= srlHeader.arm9RomOffset+0x3E00, - arm7RomOffset= srlHeader.arm7RomOffset+0x3E00, - fntOffset= srlHeader.fntOffset+0x4640, - fatOffset= srlHeader.fatOffset+0x444C, - icon_bannerOffset= srlHeader.icon_bannerOffset+0x3E00-0x200, - ntrRomSize= srlHeader.ntrRomSize+0x3E00-0x200, - headerSize= 0x4000, - nintendoLogo= "$\xff\xaeQi\x9a\xa2!=\x84\x82\n\x84\xe4\t\xad\x11$\x8b\x98\xc0\x81\x7f!\xa3R\xbe\x19\x93\t\xce \x10FJJ\xf8'1\xecX\xc7\xe83\x82\xe3\xce\xbf\x85\xf4\xdf\x94\xceK\t\xc1\x94V\x8a\xc0\x13r\xa7\xfc\x9f\x84Ms\xa3\xca\x9aaX\x97\xa3'\xfc\x03\x98v#\x1d\xc7a\x03\x04\xaeV\xbf8\x84\x00@\xa7\x0e\xfd\xffR\xfe\x03o\x950\xf1\x97\xfb\xc0\x85`\xd6\x80%\xa9c\xbe\x03\x01N8\xe2\xf9\xa24\xff\xbb>\x03Dx\x00\x90\xcb\x88\x11:\x94e\xc0|c\x87\xf0<\xaf\xd6%\xe4\x8b8\n\xacr!\xd4\xf8\x07", - nintendoLogoCrc= 'V\xcf', - secureAreaCrc= secCrc, - reserved1= '\x00'*156, - # better to recompile or swap the arm7 binary if this is needed - #arm7EntryAddress= 0x2380000, - #arm7RamAddress= 0x2380000, - #arm7Autoload= 0x2380118, - #arm9EntryAddress= 0x2000000, - #arm9RamAddress= 0x2000000, - #arm9Autoload= 0x2000A60, - ) - -if args.arm7 is not None: - if args.arm7EntryAddress is None: - print "WARNING : you may need to provide the ARM7 binary entry address via --arm7EntryAddress, default value 0x2380000 used" - args.arm7EntryAddress="0x2380000" - - srlHeaderPatched=srlHeaderPatched._replace( - arm7RamAddress= int(args.arm7EntryAddress, 0), - arm7EntryAddress= int(args.arm7EntryAddress, 0), - arm7Size= arm7FileSize, - ntrRomSize= srlHeaderPatched.ntrRomSize-srlHeader.arm7Size+arm7FileSize, - fntOffset= srlHeaderPatched.fntOffset-srlHeader.arm7Size+arm7FileSize, - fatOffset= srlHeaderPatched.fatOffset-srlHeader.arm7Size+arm7FileSize, - icon_bannerOffset= srlHeaderPatched.icon_bannerOffset-srlHeader.arm7Size+arm7FileSize, - deviceCapacity= srlHeader.deviceCapacity+1 - ) - -if "dsi" in args.mode : - srlHeaderPatched=srlHeaderPatched._replace( - deviceCapacity= srlHeaderPatched.deviceCapacity+2, - dsiflags= '\x01\x00', #disable modcrypt but enable twl - unitCode= '\x03', - #arm7Autoload= 0, - #arm9Autoload= 0, - ) - -if args.title is not None: - srlHeaderPatched=srlHeaderPatched._replace(gameTitle=args.title) -if args.code is not None: - srlHeaderPatched=srlHeaderPatched._replace(gameCode=args.code) -if args.maker is not None: - srlHeaderPatched=srlHeaderPatched._replace(makerCode=args.maker) - -data1=pack(*[srlHeaderFormat]+srlHeaderPatched._asdict().values()) -newHdrCrc=CRC16(modbus_flag=True).calculate(data1[0:0x15E]) -srlHeaderPatched=srlHeaderPatched._replace(headerCrc=newHdrCrc) - -if args.verbose: - print "new header crc "+hex(newHdrCrc) -if not args.read : - if args.verbose: - pprint(dict(srlHeaderPatched._asdict())) -else: - pprint(dict(srlHeader._asdict())) - -data1=pack(*[srlHeaderFormat]+srlHeaderPatched._asdict().values()) - -arm9isize=0 -arm7isize=0 - -#TWL Only Data 384 bytes -SrlTwlExtHeader = namedtuple('SrlTwlExtHeader', - "MBK_1_5_Settings " - "MBK_6_8_Settings_ARM9 " - "MBK_6_8_Settings_ARM7 " - "global_MBK_9_Setting " - "regionFlags " - "accessControl " - "arm7ScfgExtMask " - "reserved_flags " - "arm9iRomOffset " - "reserved2 " - "arm9iLoadAddress " - "arm9iSize " - "arm7iRomOffset " - "struct_param_baseAddress " - "arm7iLoadAddress " - "arm7iSize " - "digest_ntrRegionOffset " - "digest_ntrRegionSize " - "digest_twlRegionOffset " - "digest_twlRegionSize " - "digestSectorHashtableOffset " - "digestSectorHashtableSize " - "digest_blockHashtableOffset " - "digest_blockHashtableSize " - "digestSectorSize " - "digest_blockSectorcount " - "iconSize " #usually 0x23C0 or 2112 in homebrew - "unknown1 " - "twlRomSize " - "unknown2 " - "modcryptArea1Offset " - "modcryptArea1Size " - "modcryptArea2Offset " - "modcryptArea2Size " - "title_id " - "pubSaveDataSize " - "privSaveDataSize " - "reserved4 " - "parentalControl ") -srlTwlExtHeaderFormat="<20s12s12s4s4sIIII4sIIIIIIIIIIIIIIIII4sI12sIIII8sII176s16s" -if srlHeader.headerSize<0x300: - #homebrew - srlTwlExtHeader=SrlTwlExtHeader._make(unpack_from(srlTwlExtHeaderFormat, "\x00" * (0x300-0x180))) -else: - data = filer.read(0x300-0x180) - srlTwlExtHeader=SrlTwlExtHeader._make(unpack_from(srlTwlExtHeaderFormat, data)) - caddr=0x300 - -#pprint(dict(srlTwlExtHeader._asdict())) - -if not args.read: - # Fix srlTwlExtHeader - srlTwlExtHeader=srlTwlExtHeader._replace( - title_id= srlHeaderPatched.gameCode[::-1]+"\x04\x00\x03\x00", - regionFlags= '\xff\xff\xff\xff', - iconSize= 2112, - unknown1= '\x00\x00\x01\x00', - reserved_flags= 0x01000000 - ) - if "dsi" in args.mode: - arm7iRomOffset=srlHeaderPatched.arm7RomOffset - arm9iRomOffset=srlHeaderPatched.arm9RomOffset - arm7isize=srlHeaderPatched.arm7Size - arm9isize=srlHeaderPatched.arm9Size - totaldsisize=0 - arm7iname = None - arm9iname = None - - if args.arm9i is not None: - arm9iname = args.arm9i.name - arm9isize = getSize(args.arm9i) - arm9iRomOffset=srlHeaderPatched.ntrRomSize - if args.verbose: - print "arm9isize : "+hex(arm9isize) - print "arm9ioffset : "+hex(srlHeaderPatched.ntrRomSize) - args.arm9i.close() - totaldsisize=arm9isize - - if args.arm7i is not None: - arm7iname = args.arm7i.name - arm7isize = getSize(args.arm7i) - arm7iRomOffset=srlHeaderPatched.ntrRomSize+arm9isize - if args.verbose: - print "arm7isize : "+hex(arm7isize) - print "arm9ioffset : "+hex(srlHeaderPatched.ntrRomSize+arm9isize) - args.arm7i.close() - totaldsisize=arm9isize+arm7isize - - srlTwlExtHeader=srlTwlExtHeader._replace( - MBK_1_5_Settings= '\x81\x85\x89\x8d\x80\x84\x88\x8c\x90\x94\x98\x9c\x80\x84\x88\x8c\x90\x94\x98\x9c', - MBK_6_8_Settings_ARM7= '\xc07\x00\x08@7\xc0\x07\x007@\x07', - MBK_6_8_Settings_ARM9= '\x00\x00\x00\x00@7\xc0\x07\x007@\x07', - accessControl= 0x00000038, - arm7ScfgExtMask= 0x80040000, - reserved_flags= 0x00000000, - arm7iLoadAddress= 0x2E80000, - arm7iRomOffset= arm7iRomOffset, - arm7iSize= arm7isize, - arm9iLoadAddress= 0x2400000, - arm9iRomOffset= arm9iRomOffset, - arm9iSize= arm9isize, - global_MBK_9_Setting= '\x0f\x00\x00\x03', - iconSize= 2112, - pubSaveDataSize= 00000, - regionFlags= '\xff\xff\xff\xff', - title_id= srlHeaderPatched.gameCode[::-1]+"\x04\x00\x03\x00", - twlRomSize= srlHeaderPatched.ntrRomSize+totaldsisize, - unknown1= '\x00\x00\x01\x00', - unknown2= '\x00\x00\x00\x00|\x0f\x00\x00 \x05\x00\x00', - parentalControl= '\x80'*16 - ) - - if "dsinogba" in args.mode : - # Fix for no$gba 2.8d - srlTwlExtHeader=srlTwlExtHeader._replace( - arm7iLoadAddress= srlHeaderPatched.arm7EntryAddress, - arm9iLoadAddress= srlHeaderPatched.arm9EntryAddress - ) - -if args.verbose or args.read: - pprint(dict(srlTwlExtHeader._asdict())) - -data2=pack(*[srlTwlExtHeaderFormat]+srlTwlExtHeader._asdict().values()) - -#TWL and Signed NTR 3328 bytes -SrlSignedHeader = namedtuple('SrlSignedHeader', - "arm9WithSecAreaSha1Hmac " - "arm7Sha1Hmac " - "digestMasterSha1Hmac " - "bannerSha1Hmac " - "arm9iSha1Hmac " - "arm7iSha1Hmac " - "reserved5 " - "arm9Sha1Hmac " - "reserved6 " - "reserved7 " - "signature " - ) -srlSignedHeaderFormat="<20s20s20s20s20s20s40s20s2636s384s128s" -if srlHeader.headerSize<0x1100: - #homebrew - srlSignedHeader=SrlSignedHeader._make(unpack_from(srlSignedHeaderFormat, "\x00" * (3328))) -else: - data = filer.read(3328) - srlSignedHeader=SrlSignedHeader._make(unpack_from(srlSignedHeaderFormat, data)) - caddr=0x300+3328 - -#pprint(dict(srlSignedHeader._asdict())) - -# Fix srlSignedHeader -if not args.read: - srlSignedHeader=srlSignedHeader._replace( - arm7Sha1Hmac= '\xff'*20, - arm9WithSecAreaSha1Hmac= '\xff'*20, - bannerSha1Hmac= '\xff'*20, - signature= '\xff'*128 - ) - if "dsi" in args.mode : - srlSignedHeader=srlSignedHeader._replace( - arm7Sha1Hmac= '\xff'*20, - arm7iSha1Hmac= '\xff'*20, - arm9Sha1Hmac= '\xff'*20, - arm9WithSecAreaSha1Hmac= '\xff'*20, - arm9iSha1Hmac= '\xff'*20, - bannerSha1Hmac= '\xff'*20, - digestMasterSha1Hmac= '\xff'*20, - signature= '\xff'*128 - ) -if args.verbose or args.read: - pprint(dict(srlSignedHeader._asdict())) - -data3=pack(*[srlSignedHeaderFormat]+srlSignedHeader._asdict().values()) - -# ARM9 footer -# from https://github.com/devkitPro/ndstool/ ... source/header.cpp -# ARM9 footer size = 3*4 -ARM9Footer = namedtuple('ARM9Footer', - "nitrocode " #0xDEC00621 - "versionInfo " - "reserved " - ) -ARM9FooterFormat="