Skip to content

PSX3DS v0.2.1 — Fix New 3DS Startup Crash (svcBreak in __system_allocateHeaps)

Choose a tag to compare

@codescv codescv released this 10 Nov 12:30
· 14 commits to main since this release

PSX3DS v0.2.1 — Fix New 3DS Startup Crash (svcBreak in __system_allocateHeaps)

v0.2.1 is a critical hotfix for all real New Nintendo 3DS / New 3DS XL / New 2DS XL consoles running Luma3DS (both .cia and .3dsx builds).


English Release Notes

Bug Fixed: Immediate Startup Crash (prefetch abort / Debug event) on Real New 3DS Hardware

  • Symptom in v0.2.0: Launching psx3ds.cia (or psx3ds.3dsx with >= 124 MiB commit limit) on a real New 3DS running Luma3DS immediately crashed before main() with a Luma3DS exception screen:
    • Exception type: prefetch abort (Fault status: Debug event — svcBreak(USERBREAK_PANIC))
    • PC = 0x001CB108 (svcBreak), LR = 0x001CABF4 (__system_allocateHeaps + 0x1bc)
    • R3 = 0x06694000 (102.58 MiB) with New 3DS RESLIMIT_COMMIT = 0x07C00000 (124 MiB)
  • Root Cause:
    • To fit 26 MiB PsxArena + 6 MiB JIT on 64 MiB Old 3DS .cia installs, v0.2.0 set u32 __ctru_linear_heap_size = 20 MiB while leaving __ctru_heap_size = 0.
    • In libctru's __system_allocateHeaps, setting a non-zero __ctru_linear_heap_size with __ctru_heap_size == 0 bypasses libctru's default 32 MiB linear-heap branch and takes an uncapped branch: __ctru_heap_size = remaining - __ctru_linear_heap_size.
    • On a real New 3DS (124 MiB RESLIMIT_COMMIT, ~122.58 MiB remaining), __ctru_heap_size became 102.58 MiB (0x06694000). When svcControlMemory(MEMOP_ALLOC) attempted to map 0x08000000 .. 0x0E694000, it overflowed Horizon OS Kernel11's 96 MiB ([0x08000000, 0x0E000000)) application heap virtual address ceiling (OS_HEAP_AREA_END), failing and triggering svcBreak(USERBREAK_PANIC) before main(). (Azahar's HLE kernel permits a 128 MiB heap window, masking this bug in emulator-only tests.)
  • Fix in v0.2.1:
    • Custom __system_allocateHeaps Override (src/platform/3ds/main_3ds.c + include/psx3ds/ctr_heap.h): Computes normal_heap = min(remaining - 20 MiB, 80 MiB) and assigns the remaining commit budget to the linear heap:
      • New 3DS (124 MiB .cia / .cci / .3dsx): 80.00 MiB (0x05000000) normal heap (0x08000000 .. 0x0D000000, leaving a full 16 MiB VA safety margin below 0x0E000000) + ~42.58 MiB linear heap.
      • New 3DS (178 MiB extended .3dsx): 80.00 MiB normal heap + ~96.58 MiB linear heap.
      • Old 3DS (64 MiB .cia / .cci / .3dsx): ~42.58 MiB normal heap + 20.00 MiB linear heap (unchanged).
    • Resilient Kernel Fallback: If svcControlMemory ever rejects a requested heap or contiguous linear-heap allocation (e.g. fragmented FCRAM under .3dsx launchers), __system_allocateHeaps shrinks in 8 MiB steps and retries instead of panicking.
    • Accurate Old 3DS small_mem Auto-Detection: psx_system_init() now inspects envGetHeapSize() < 64 MiB (__ctru_heap_size) instead of osGetMemRegionFree(MEMREGION_APPLICATION) (which reads ~0 after startup commits RESLIMIT_COMMIT), ensuring New 3DS .cia and .3dsx always run the full 16 MiB JIT + 64-slot RGBA8 texture cache + 8-slot CHD cache profile while Old 3DS uses small_mem.
    • Startup Heap Regression Suite (tests/unit/test_ctr_heap.c): Verifies 36 MiB <= heap_size <= 80 MiB < 96 MiB across O3DS 64/80/96 MiB, N3DS 124/178 MiB, the exact crash dump registers, and a 1..256 MiB sweep across all 3 CI/test tiers.

Quick Start (SD Card Installation)

  1. Download psx3ds.cia (or extract psx3ds-v0.2.1-3ds.zip to the root of your 3DS SD card sdmc:/).
  2. Recommended (.cia): Open FBI → SD → install psx3ds.cia (overwrites v0.2.0 cleanly under TitleID 000400000F853D00), then launch PSX3DS from the Home Menu.
  3. Alternative (.3dsx): Place psx3ds.3dsx and psx3ds.smdh in sdmc:/3ds/psx3ds/ and launch from Homebrew Launcher.
  4. Put PS1 BIOS (SCPH1001.BIN or included openbios.bin) in sdmc:/psx3ds/bios/ and games (.chd, .cue/.bin, .iso, .exe) in sdmc:/psx3ds/roms/.

中文更新说明(修复 New 3DS 实机打开即崩溃问题)

修复核心问题:New 3DS / New 3DS XL / New 2DS XL(Luma3DS)启动即报 prefetch abort (svcBreak) 崩溃

  • 问题原因(v0.2.0):
    • v0.2.0 为了兼容老三(Old 3DS 64 MiB)的内存预算,设置了 __ctru_linear_heap_size = 20 MiB 且保留 __ctru_heap_size = 0。
    • 在 libctru 的 __system_allocateHeaps 中,当仅指定线性堆大小而未指定普通堆上限时,会跳过默认的 32 MiB 线性堆分支,直接按 remaining - 20 MiB 无上限计算普通堆。
    • 在 New 3DS(RESLIMIT_COMMIT = 124 MiB,剩余约 122.58 MiB)实机上,普通堆请求大小变成了 102.58 MiB(R3 = 0x06694000),映射范围 0x08000000 .. 0x0E694000 超出了 3DS Kernel11 应用普通堆的 96 MiB 虚拟地址上限 [0x08000000, 0x0E000000),导致 svcControlMemory 失败并在进入 main() 前触发 svcBreak(USERBREAK_PANIC)(Luma3DS 显示 prefetch abort / Debug event)。
  • v0.2.1 修复方案:
    • 接管并重写 __system_allocateHeaps:通过 psx_ctr_compute_heap_split() 精确划分普通堆与线性堆:普通堆上限严格封顶为 80 MiB(0x05000000,最高至 0x0D000000),彻底杜绝越过 0x0E000000 内核虚拟地址边界:
      • New 3DS (124 MiB .cia / .3dsx):80.00 MiB 普通堆 + 42.58 MiB 线性堆(完整启用 16 MiB ARM11 W^X JIT 缓存、64 槽位硬件纹理缓存与 8 槽位 CHD 缓存)。
      • Old 3DS (64 MiB .cia / .3dsx):42.58 MiB 普通堆 + 20.00 MiB 线性堆(自动启用 small_mem 配置)。
    • 内核分配自适应退避重试:若在内存碎片化的自制软件启动器环境下单次分配被内核拒绝,自动按 8 MiB 步进收缩重试,避免直接崩溃。
    • 修复 small_mem 自动识别逻辑:改用 envGetHeapSize() < 64 MiB 判定老三/新三内存配置,并新增 test_ctr_heap 单元测试覆盖全部机型内存布局。

安装/升级方法

  • .cia 桌面安装版(推荐):下载 psx3ds.cia(或解压 psx3ds-v0.2.1-3ds.zip 到 SD 卡根目录),使用 FBI 直接覆盖安装即可(相同 TitleID 000400000F853D00,存档与记忆卡完全保留)。
  • .3dsx 自制系统启动版:下载 psx3ds.3dsx(及 psx3ds.smdh)覆盖 sdmc:/3ds/psx3ds/ 目录后从 Homebrew Launcher 启动。
  • 所有发布文件均可通过 SHA256SUMS.txt 校验完整性。