Switch homebrew team 2168-0002 releases dedbae xci2nsp: A smarter, faster XCI to NSP converter

Find xci2nsp releases here: https://gitlab.com/roothorick/dedbae/tags/

A pretty minor release for 2168, but don't ever say we hoard our creations!

This is an XCI to NSP converter that's smarter and faster than 4nxci.

  • A single, self-contained executable with no dependencies worth mentioning.
  • Reads and writes the game exe/assets -- the part that actually takes more than a few seconds -- only once, without decrypting/re-encrypting. No interstitial files. This is as fast as I can make it; the bottleneck is the throughput of your HDD.
  • Handles all known XCI/gamecard formats.
  • Produces output NSPs with the human-readable game name, title ID, and version ID in hex (much more readable than CDNSP's decimal translation).
  • Identifies and extracts embedded updates as a separate NSP.
  • No fake tickets, no recrypting with titlekey crypto, no cruft in your ticketdb. Only the update NSPs have tickets, and they're real, official tickets.

Use

An x86-64 Windows binary is provided; for non-Windows (note: little endian CPU required) you'll need to build it yourself (see below), and if you bought a Switch but your main computer doesn't have a 64bit processor you need to re-evaluate your life choices.

Place your keyfile in the correct location (this works a bit differently from most tools! See below). Put xci2nsp.exe just anywhere. Run it from the command line with file names as arguments. NSPs will be saved to the current working directory irrespective of the XCI's location.

Alternately, just drag-and-drop XCI files on top of the exe. In this case the NSPs will be saved to the same directory as the XCIs. You can select and drag multiple at once and it will batch-convert them in sequence.

When installing the produced NSPs, Tinfoil will print a warning about failing to install the ticket. This is normal; there is no ticket to install.

Keyfile location

I'm very tired of every tool expecting keys to be in a different place under a different name, usually in the current working directory so you have a dozen copies laying all around your system. So, I'm taking a step towards standardizing that by copying hactool's search paths.
You'll need your keyfile to be "~/.switch/prod.keys" (Linux) or "C:\Users\<username>\.switch\prod.keys" (Windows), unless you have a weird setup that moves the home dir/user profile dir, in which case I expect you to already know what you're doing.

I really would like current and future tools to either do the same, or adopt a different standard location for all apps to go to.

Known issues

  • File permissions related problems are handled poorly and may produce cryptic errors.
  • Disk space is not checked. If you're not paying attention, you may get most of the way through a conversion only to get a "No space left on device" error.
  • The output file names are deliberately ASCII only, to avoid a bug in Horizon. Non-ASCII characters are translated using a C++ version of Unidecode, which doesn't handle Japanese very well. Names composed mainly of kanji will be badly bastardized. (If you've used CDNSP in the past you may be familiar with what this looks like.)
  • On Windows, xci2nsp may fail to open XCI files if their filename contains "wide" characters (e.g. Japanese alphabets). Filenames with such characters tend to cause problems with a lot of things, so you really should just rename them.
  • If an English translation for a game was added in an update (e.g. Taiko), and the update is embedded in the XCI, the base game NSP's filename will have the game's name in the original language (e.g. Japanese), but the update NSP's filename will have the English name.

Building from source

If you're cloning the repository, note that there are two submodules; you will need to specify --recursive.

Dependencies are basically nonexistent; just the standard GNU toolchain and libc/libstdc++. On Windows you will need MinGW-W64 and MSYS2. Extract/clone wherever, cd into the dir and make. The binary will be copied into the bin/ folder.

OSX will probably not work without a special build environment as GCC extensions are in use. Either way, I don't intend to support OSX; don't have the hardware, don't want the hardware, and really really don't want to mess around with hackintosh.

Why?

When I first started working on this, 4nxci wasn't correctly handling a number of common cases resulting in NSPs that didn't work correctly. In addition, it was re-encrypting with titlekey crypto, something that really isn't necessary, correction: 4n informed me it was just a fake ticket to work around a bug in early Tinfoil, it still left extra cruft on the system in the form of fake tickets in the ticketdb. I think his current version has resolved most of those issues, but I've been using this instead for a while, and it is better, so I should share.

I'll fix any issues people run into, and make updates if we discover XCIs that change things up too much to not work. Beyond that, though, I'm moving on to something considerably more exciting. Expect Big Things from 2168 soon.

Changelog

1.0.0-1: libgcc and libstdc++ are now statically linked in the Windows build. There actually are no meaningful runtime dependencies now.
 

Attachments

  • 2168.png
    2168.png
    9.7 KB · Views: 3,493
Last edited by roothorick,

roothorick

Well-Known Member
OP
Newcomer
Joined
Jan 30, 2008
Messages
51
Trophies
0
XP
479
Country
United States
I will be changing the keyfile location on Windows, also searching the current one for the sake of backwards compatibility. There are motivational problems at the moment, so I can't say when.

Game updates, DLC on cart and the game itself are output as separate NSPs. System updates get discarded.

As far as I know, no gamecard has ever had addon content embedded on it. In cases like Shantae UE and XC2:TTGC what would normally be in the addon content archives are instead put in the base game archives directly, and to reflect the structural difference, the gamecard version is given its own unique title ID and a separate line of update archives.

If a gamecard with embedded addon content archives *is* found, this tool in its current form will barf on it. If you stumble across such a card please tell me what game and what version of the card, and ideally the names of all the NCAs in the secure partition.

System updates are their own beast. They cannot be packaged into a single file in a form that Horizon or any existing tools will recognize; at best, you could pack up the loose NCAs in a 7z archive or similar for storage/transfer and then extract them before actually applying the update. If you want the system update files out of an XCI for some reason (e.g. ChoiDujour) you can extract them with hactool using the "-updatedir" flag.
 
  • Like
Reactions: SaffronXL

sheg0

Member
Newcomer
Joined
Jun 5, 2018
Messages
23
Trophies
0
Age
35
XP
235
Country
Germany
Hi,
i just converted Mario Party XCI to an NSP and installed it on 4.1. Now I have one NSP showing up with pending "getting software information" and grayed out options to uninstall the nsp. dev menu also hangs on that entry.
Does anyone has an idea how I can get rid of that NSP without doing a NAND restore?
 

Draxzelex

Well-Known Member
Member
Joined
Aug 6, 2017
Messages
19,011
Trophies
2
Age
29
Location
New York City
XP
13,379
Country
United States
Hi,
i just converted Mario Party XCI to an NSP and installed it on 4.1. Now I have one NSP showing up with pending "getting software information" and grayed out options to uninstall the nsp. dev menu also hangs on that entry.
Does anyone has an idea how I can get rid of that NSP without doing a NAND restore?
Press + on the icon to delete it or go to System Settings than something like manage software to delete it manually.
 
  • Like
Reactions: sheg0

blahblah

Well-Known Member
Member
Joined
May 16, 2018
Messages
1,132
Trophies
0
Age
35
XP
1,472
Country
United States
I will be changing the keyfile location on Windows, also searching the current one for the sake of backwards compatibility. There are motivational problems at the moment, so I can't say when.



As far as I know, no gamecard has ever had addon content embedded on it. In cases like Shantae UE and XC2:TTGC what would normally be in the addon content archives are instead put in the base game archives directly, and to reflect the structural difference, the gamecard version is given its own unique title ID and a separate line of update archives.

If a gamecard with embedded addon content archives *is* found, this tool in its current form will barf on it. If you stumble across such a card please tell me what game and what version of the card, and ideally the names of all the NCAs in the secure partition.

System updates are their own beast. They cannot be packaged into a single file in a form that Horizon or any existing tools will recognize; at best, you could pack up the loose NCAs in a 7z archive or similar for storage/transfer and then extract them before actually applying the update. If you want the system update files out of an XCI for some reason (e.g. ChoiDujour) you can extract them with hactool using the "-updatedir" flag.

I was under the impression that Sonic Mania Plus does that - I remember getting a DLC package file, an update file and the base Sonic Mania game when running it through the other app. But I could be wrong.
 

roothorick

Well-Known Member
OP
Newcomer
Joined
Jan 30, 2008
Messages
51
Trophies
0
XP
479
Country
United States
Hi,
i just converted Mario Party XCI to an NSP and installed it on 4.1. Now I have one NSP showing up with pending "getting software information" and grayed out options to uninstall the nsp. dev menu also hangs on that entry.
Does anyone has an idea how I can get rid of that NSP without doing a NAND restore?

IIRC Mario Party uses the key area key introduced in 5.0.0. As such it will not work in 4.1 without re-encryption, which is beyond the scope of this tool.

I have personally tested Mario Party on my personal system (5.1.0) and it does work.
 

blahblah

Well-Known Member
Member
Joined
May 16, 2018
Messages
1,132
Trophies
0
Age
35
XP
1,472
Country
United States
IIRC Mario Party uses the key area key introduced in 5.0.0. As such it will not work in 4.1 without re-encryption, which is beyond the scope of this tool.

I have personally tested Mario Party on my personal system (5.1.0) and it does work.

This is correct.
 

Nazosan

Well-Known Member
Member
Joined
May 12, 2009
Messages
576
Trophies
1
XP
1,089
Country
United States
sucks he plans on no osx build well at least 4nxci works on mac
Looks like it uses standard build tools. GCC even I think. Surely this is available on Mac? Presumably you should be able to just grab the source, install GCC and make, then just run make in the source folder in a terminal.

System updates are their own beast. They cannot be packaged into a single file in a form that Horizon or any existing tools will recognize; at best, you could pack up the loose NCAs in a 7z archive or similar for storage/transfer and then extract them before actually applying the update. If you want the system update files out of an XCI for some reason (e.g. ChoiDujour) you can extract them with hactool using the "-updatedir" flag.
On that subject I have been wondering how I should go about doing an offline update (without SX OS, so no XCI loader.) Might that be able to do it then? I won't be bothering until some game ships that actually requires 6.x though. Correction. Some game I actually want.
 

hippy dave

BBMB
Member
Joined
Apr 30, 2012
Messages
9,874
Trophies
2
XP
29,188
Country
United Kingdom

roothorick

Well-Known Member
OP
Newcomer
Joined
Jan 30, 2008
Messages
51
Trophies
0
XP
479
Country
United States
Looks like it uses standard build tools. GCC even I think. Surely this is available on Mac? Presumably you should be able to just grab the source, install GCC and make, then just run make in the source folder in a terminal.

Someone did manage to build a working OSX binary and posted it in one of the myriad Discord servers; I forget where exactly, wasn't paying much attention. For what it's worth, I don't think I got a pullreq.

I think in the OP I did touch on why I have no interest in doing it myself, but tl;dr I don't have a Mac, don't want a Mac, and definitely don't want to mess with hackintosh, or cross-compiling, or coordinating with volunteer testers over the Internet.
 
  • Like
Reactions: Nazosan

Ashura66

Well-Known Member
Member
Joined
Feb 1, 2016
Messages
1,768
Trophies
0
Age
37
Location
Under my bed
XP
1,684
Country
Portugal
Question: So this requires a folder named .switch to have the keys inside and be placed on my users folder correct? But i can't name a folder .switch so...what gives?
 

optimusxcrime

Member
Newcomer
Joined
Sep 22, 2018
Messages
12
Trophies
0
Age
49
XP
100
Country
United States
THANKS FOR THE RELEASE!!

works great for me. i'm on latest firmware 6.01 using heckate_4.2/ReiNX(latest)
love how it properly names the output .nsp file.
keep up the good work... and thanks again
 

rich333

Well-Known Member
Member
Joined
Sep 7, 2009
Messages
195
Trophies
1
XP
493
Country
Got this to work on ReiNX, but not Atmosphere (patched, via Kosmos Installer at sdsetup.com)

Has anyone got a way to get Atmosphere to load these converted nsps?
 

Sonikkua

Well-Known Member
Member
Joined
Mar 26, 2011
Messages
116
Trophies
1
XP
723
Country
United States
sucks he plans on no osx build well at least 4nxci works on mac

I got you fam!

I got it to build on MacOS, just had to install coreutils and mbedtls using brew and edit the Makefile's a bit, maybe a few other things I've already forgotten :-)

I suffered so you don't have to!

TprNWpi.png



Other than it running under the MacOS terminal, everything is the same. Make sure you have a folder named .switch in your home directory with your keys file named prod.keys inside.
 

Attachments

  • xci2nsp-MacOS.zip
    312.5 KB · Views: 1,082
Last edited by Sonikkua,

NoIdeaofAnything

Active Member
Newcomer
Joined
Nov 13, 2018
Messages
39
Trophies
0
Age
56
XP
427
Country
Austria
Anyone knows how to overgo Windows10 write protection?
When I want to make the .switch folder I am not able to even after I have changed the properties in the settings.
 

Site & Scene News

Popular threads in this forum

General chit-chat
Help Users
    Xdqwerty @ Xdqwerty: @salazarcosplay, I heard herbert stopped appearing on the show