Pass an uncompressed NRO directly to recompile and play, without keys or extraction:
./build/scarletnx "app.nro" -H
The .nro extension is case-insensitive. NRO launches always recompile and restage the input,
so a same-named cached executable or extraction directory cannot silently select an older program.
Embedded RomFS assets are staged by the recompiler. Compressed NROs are not supported.
This uses ScarletNX's existing guest runtime, not a complete homebrew-loader environment.
Compatibility still depends on the application's runtime and service requirements.
See NRO implementation notes for the reference and validation policy.
To run the steps separately, here in folders of the current one (--out and --outdir; without them, the data
folder's work/ and recompiled/):
./build/scarletnx -x "Game.xci" --out work/Game
./build/scarletnx -r work/Game Game --outdir recompiled
recompiled/Game/Game
.\build\scarletnx.exe -x "Game.xci" --out work/Game
.\build\scarletnx.exe -r work/Game Game --outdir games
.\games\Game\Game.exe
Remaining examples: POSIX.
# NSP + same-title update
./build/scarletnx -x Game.nsp --update update.nsp --name Game \
--keys /path/prod.keys --title-keys /path/title.keys
./build/scarletnx -r work/Game Game --outdir games --jobs 8
./build/scarletnx -r app.nro --name App --outdir games
./build/scarletnx -r -h
Keys: encrypted content uses --keys/--title-keys flags, then the data folder (Folders) → ~/.switch
(%USERPROFILE%\.switch on Windows).
Common NSP tickets supplement title keys. Fully decrypted content needs neither key file.
Extraction: defaults to the data folder's work/<dump stem>; --name/--out DIR override. Refuses existing
exefs. hactool runs inside the driver and reads each NCA where it lies in the XCI or NSP (an XCZ's or NSZ's NCZ
decompressed as it is read, ncz.c), so the ExeFS and RomFS
are written straight into the output and nothing is unpacked beside it
(key filtering and cleanup).
Sparse and compressed NCAs, updates with large relocation tables and gamecard dumps that start with the card's key
area all extract, through what storage.c ports from LibHac.
Pack plain NCAs: scarletnx --pack FOLDER [--xci] [--out FILE] packs a folder of NCAs (an NSP's files, or an
XCI's secure partition, as a tool unpacked them; .tik files in it give title keys) into an ordinary NSP (PFS0) or
XCI (HEAD) whose NCAs are plain: each header and section decrypted where it lies, everything else, the header's
signatures included, unchanged. It is not a DNSP or DXCI: the container and NCA magics are the usual ones, and a
reader tells a plain NCA by its header, with no keys. An XCI, NSP, DXCI or DNSP can be given in place of the folder.
NCAs plain already need no keys; tickets are left out. The output goes beside the input by default
(FOLDER.nsp, DUMP.decrypted.nsp). The launcher's menu has it as Pack extracted as dXCI/dNSP
(pack.c).
An extracted game's folder (exefs/ with main.npdm, romfs/, and control.nacp and icon.jpg when it has
them, as -x leaves it) has no NCAs to pack, so --pack fabricates them
(fabricate.c): a Program NCA (the ExeFS as a hashed PFS0, the RomFS
rebuilt as the runtime builds an image of romfs/, under its IVFC hashes), a Control NCA and a Meta NCA, each a
plain NCA3 whose sections are not encrypted. What the folder lacks is a stub: the headers' signatures are zero, a
missing control.nacp gets one titled --name NAME (else the folder's name) with a user required at startup and
64 MiB account and device saves, the content meta is made up, and each content ID is the SHA-256 of its NCA's
header. Each file is read once: the hashes before the data are written as zeros, and written over once the data
behind them is read. --plan says what it would make, reading only main.npdm and the files' sizes. The
.listing files that wget leaves in a mirror of an FTP folder are left out.
Recompile: AOT → module (the host's native back end) →
final runtime deployment, for this machine's CPU. Shaders compile directly to SPIR-V at runtime.
-O, LLVM's level, went with it: said once, and nothing done (Deprecations). --jobs N (--aot-threads=N) sets the threads
compiling (0 or none: the machine's cores with a quarter left free, the physical cores where it says them,
else the logical ones, at most 75%, so a recompile does not make the computer stutter). The quarter is
deliberate: a large game's recompile runs for minutes, a pass that took every core would keep the machine
unusable that long and heat a phone, while a compile thread gains little from a hyperthread. At most 75%, rounded
down, leaves one whole core free on a machine of 4, and a quarter of the largest ones. Left at 0 (Auto) that count
is the most, and the memory decides how many of them compile: every thread compiles a code unit at once, and what
a unit takes follows the game, so the recompile starts on 1 thread, measures what its own units take while they
compile, and once the first has ended opens one thread more each second while the memory the system can still
give holds what the threads already open may still take and two units more (the new thread's, and one to spare:
a unit can be larger than any seen yet). No thread opens while the system says memory is short: Linux's pressure
stall information (/proc/pressure/memory, its some avg10 at 10.00 or more: tasks waiting for memory a tenth of
the time, where the runtime's low memory watch warns), Windows' low memory notification, macOS's
memory pressure level; Android lets an app read none, so the measure alone decides there, and where the system
says neither what the process takes nor what it can still give, the cores alone do. A unit under way is never
ended: the recompile only stops opening. Its log says each thread it opens and each reason it opens none, with
the numbers. Threads given (--jobs N) are all open from the start, whatever the memory. scarletnx
--settings=recompile lists the recompile's settings. A dump played with them is recompiled with them when it has to
be, and a game made already keeps its code until -r recompiles it. A value a setting does not take
(--aot-threads=abc) stops the recompile.
--target auto|linux|win64 takes only this host's own system: modules are built for the machine that builds
them. --target ios writes <id>_code.snxobj instead, a pack of the code's objects for the iOS app to load into JIT
memory (64-bit games only, macOS and iOS); it makes no runtime copy. --runtime FILE deploys that runtime instead of the running one, or of the one a tools-only build builds in
its checkout's build/native-recomp (build/win64-recomp on Windows). -q (--quiet) prints no progress.
These and the other recompile options are the
common options, which the 3DS, Vita and GBA drivers take too.
Codegen: --no-build stages data/INI only; --jit-only omits AOT functions.
--chunk N (--unit-instructions=N) sets the instructions per code unit: 90000 by default, 20000 on Android and
iOS, where a smaller unit takes less memory at once. The x86-64 back end's units are held in memory while the
process runs, under the SHA-256 of what each is made from, so that a unit made again in it (an NRO loaded again, the
launcher's next recompile) is copied rather than made: up to 1% of the machine's memory, at most
--unit-cache-ceil-mb=N (512 by default, 0 for none), the units used longest ago going first. A unit line ends in
(cached) for one taken from memory. Nothing is kept on the disk: units/ of the cache folder, where an older
version kept them, is said with its size at each recompile while it is there, and deleting it frees that room.
--hook-direct-calls sends calls and branches between guest functions through the dispatch table too, so the
runtime's NVN handlers also take calls made by direct branch.
Data updates: ExeFS refreshes; <id>_data/romfs is reused.
Replace cached RomFS after asset changes; preserve <id>_data/save/.
With --out work/Game and --outdir games as above (without them, see Folders):
| Output | Contents |
|---|---|
work/Game/{exefs,romfs} | Extracted input |
recompiled/<id>/<id>[.exe], <id>_code.so/.dll | Runtime + AOT module |
recompiled/<id>/<id>_data/, <id>.ini | Data/saves (and control.nacp) + settings |
recompiled/<id>/shader_cache/vk_pipelines.<driver>.bin | Vulkan pipeline cache, one per driver (<driver>: d<driver ID>-<GPU vendor>-<GPU device>, and -<package> for a gpu_driver package's), so going back to a driver finds its own |
recompiled/<id>/shader_cache/<id>.<driver>.vkshaders | One per driver: translated shaders and the pipelines made, made again at the next start, compute pipelines too (before the game starts, from their programs, so a new build or driver compiles them there); held in memory while the game runs and written when it closes, packed with zstd at its highest level: a run that crashes keeps none of what it made |
recompiled/<id>/shader_cache/<id>.<driver>.vkshipped | One per driver: the shaders found in the game's own files and executables, prepared ahead of time (prepare_shaders), each read when the game first draws with it, each packed with zstd on its own (compress_prepared_shaders). Unpacked it can be large: one game's 2,700 shaders took 245 MB, another's 18,500 took 2 GB; packed, about a quarter of that |
recompiled/<id>/shader_cache/<id>.vkscan | The game's files found to hold no shaders, so that after an update of ScarletNX or the driver the files aren't all read again to look for them |
Made from docs/user/usage.md at 69237645142c. GPL-3.0-or-later.