NIM updater service "nim:u"
NIM server service "nim:s"
NIM server service "nim:aoc"
Command Header
|
Description
|
0x00030042
|
SetApplicationId
|
0x00040042
|
SetTin
|
0x000902D0
|
ListContentSetsEx
|
0x00180000
|
GetBalance
|
0x001D0000
|
GetCustomerSupportCode
|
0x00210000
|
Initialize
|
0x00240282
|
CalculateContentsRequiredSize
|
0x00250000
|
RefreshServerTime
|
NIM service "nim:ndm"
Command Header
|
Description
|
0x00010000
|
GetDaemonEventHandle
|
0x00020000
|
Does nothing, always returns 0
|
0x00030000
|
SetDaemonToWorkingState
|
0x00040040
|
SetDaemonToSuspendedState
|
0x00050000
|
GetDaemonState
|
kagiya server
The nim system module communicates with a server called kagiya (kagiya-ctr.cdn.nintendo.net or kagiya-dev-ctr.cdn.nintendo.net for development units). It provides the 9.6 crypto seed in binary form for any given title ID under (HTTPS) kagiya-ctr.cdn.nintendo.net/title/0x%16llx/ext_key?country=%s, where %16llx is the title ID and %s is a country code as used in the eShop.
New3DS
NIM module only uses CheckNew3DS for determining what heap sizes to use, in two functions. One is for the size of the 0x08000000 vmem heap, the other is probably for some buffer allocated on that heap. The New3DS version of these sizes are 0x1C000-bytes larger than the Old3DS sizes here.
HTTPS requests
Trusted RootCAs
During startup NIM-module creates two RootCertChains with HTTPC. Both of these only contain the same default cert with ID 0x3. The first RootCertChain is used with NetUpdateSOAP. Requests such as the "notifications.json" page don't use these RootCertChains(in this case just default certID 0xB is used).
SOAP
NetUpdateSOAP
There are exactly 3 types of network SOAP requests used with NetUpdateSOAP by NIM module, described below. This URL contained in NIM module itself is only used with GetSystemTitleHash. The other requests use an identical URL loaded from an ECommerceSOAP response instead.
See also here.
GetSystemUpdate
Returns the current sysupdate title-listing. This also contains the SystemTitleHash returned by GetSystemTitleHash.
GetSystemTitleHash
Returns the current SystemTitleHash for the current sysupdate title-listing.
GetSystemCommonETicket
Returns the Base64-encoded cetk for each specified TitleId entry.
This is only used when installing new titles. This means with CDN system-updates, tickets are never installed except when a title is being installed for the first time. For example, a system on the latest system-version that was only ever updated via CDN has the same NATIVE_FIRM ticket installed from the factory.
Sysupdate checking process
This section describes the process used when checking whether a sysupdate is required.
First the GetSystemTitleHash SOAP request is done. Then the SystemTitleHash in savedata hash.dat is compared with the received one. If they match and the SystemTitleHash flag is set to value 0x03, it will immediately return that no sysupdate is required. Otherwise it will start the GetSystemUpdate SOAP request handling.
The GetSystemUpdate SOAP request contains a titlelist of all NAND system-titles. For GetSystemUpdate response parsing, it compares each SOAP title_entry with the NAND system titlelist. If a SOAP titleID isn't found in the NAND titlelist, this means NAND is missing a new title and hence a sysupdate is required for installing that title. If a NAND title_entry-version is less than the SOAP title_entry-version, this means the title needs updated and hence a sysupdate is required.
At least one <TitleVersion> entry with valid data in the GetSystemUpdate response is required.
The titleIDs sent in the GetSystemUpdate SOAP request are decimal, while the titleIDs in the response are hex.
hash.dat
Offset
|
Size
|
Description
|
0x60
|
0x1
|
u8 flag used with the SystemTitleHash. 0x01 = latest sysupdate isn't installed as of last SOAP requests, 0x03 = latest sysupdate is installed as of last SOAP requests.
|
0x61
|
0x21
|
ASCII hex SystemTitleHash, including NUL-terminator. This is the latest SystemTitleHash which NIM module received from SOAP.
|
Types
SystemUpdateProgress
Offset
|
Length
|
Description
|
0x00
|
0x01
|
System Update State
|
0x01
|
0x03
|
Padding
|
0x04
|
0x04
|
Last Operation Result Code
|
0x08
|
0x08
|
Current Title Downloaded Bytes
|
0x10
|
0x08
|
Current Title Total Bytes
|
0x18
|
0x08
|
Titles Downloaded
|
0x20
|
0x08
|
Titles Total
|
SystemUpdateState
Value
|
Description
|
0
|
Not Initialized
|
1
|
Starting System Update
|
2
|
Fetching System Hash and Account Status
|
3
|
Installing New Tickets
|
4
|
Installing Titles
|
5
|
Update Complete
|
6
|
Failed - System Updates Disabled (Dev Units Only)
|
7
|
? (Only for background updates)
|
8
|
? (Only for background updates)
|
TitleDownloadProgress
Offset
|
Length
|
Description
|
0x00
|
0x01
|
Title Download State
|
0x01
|
0x03
|
Padding
|
0x04
|
0x04
|
Last Operation Result Code
|
0x08
|
0x08
|
Downloaded Bytes
|
0x10
|
0x08
|
Total Bytes
|
TitleDownloadState
Value
|
Description
|
0
|
Not Initialized
|
1
|
Starting Title Download
|
2
|
Downloading and Installing TMD
|
3
|
Committing TMD
|
4
|
Downloading and Installing Contents
|
5
|
Contents Installed
|
6
|
Committing Titles
|
7
|
Finished
|
8
|
? (Unknown error regarding title version?)
|
9
|
? (Creating the .ctx file (or error doing so)?)
|
10
|
Background Download Failed
|
TitleDownloadConfig
Offset
|
Length
|
Description
|
0x00
|
0x08
|
Title ID
|
0x08
|
0x04
|
Title version
|
0x0C
|
0x04
|
Unknown (always 0?)
|
0x10
|
0x01
|
Age Rating (for HOME Menu parental controls)
|
0x11
|
0x01
|
Media Type
|
0x12
|
0x02
|
Padding
|
0x14
|
0x04
|
Unknown (always 0?)
|
BackgroundTitleDownloadConfig
Offset
|
Length
|
Description
|
0x000
|
0x018
|
Title Download Config
|
0x018
|
0x001
|
Unknown
|
0x019
|
0x001
|
Unknown
|
0x01A
|
0x006
|
Padding
|
0x020
|
0x008
|
Requester Title ID
|
0x028
|
0x090
|
Title Name (UTF-16)
|
0x0B8
|
0x002
|
Title Name Forced NUL Terminator (always 0)
|
0x0BA
|
0x048
|
Developer Name (UTF-16)
|
0x102
|
0x002
|
Developer Name Forced NUL Terminator (always 0)
|
BackgroundTitleDownloadTaskInfo
AutoTitleDownloadTaskInfo
Offset
|
Length
|
Description
|
0x000
|
0x008
|
Task ID
|
0x008
|
0x008
|
Title ID
|
0x010
|
0x004
|
Title Version
|
0x014
|
0x014
|
Unknown
|
0x028
|
0x008
|
Required Storage Space
|
0x030
|
0x004
|
Last Operation Result code
|
0x034
|
0x004
|
Last Operation Customer Support Code
|
0x038
|
0x090
|
Title Name (UTF-16)
|
0x0C8
|
0x002
|
Title Name Forced NUL Terminator (always 0)
|
0x0CA
|
0x048
|
Developer Name (UTF-16)
|
0x112
|
0x002
|
Developer Name Forced NUL Terminator (always 0)
|
0x114
|
0x024
|
Unknown
|
InstallationMode
Value
|
Description
|
0
|
Initial Installation
|
1
|
Unknown
|
2
|
Unknown
|
3
|
Re-installation
|
Autodbg
Despite this being for debug purposes, it's used in retail if present.
Offset
|
Length
|
Description
|
0x000
|
0x004
|
Debug flags
|
0x004
|
0x004
|
Number of debug tasks in dbgtasks.dat
|
0x008
|
0x100
|
Debug URL dst.xml override
|
Autodbg flag bits
Bit
|
Description
|
0
|
Use the tasks stored in dbgtasks.dat
|
1
|
Use provided debug dtl.xml URL override
|
2
|
Disable the download of dtl.xml
|
3
|
Skip connecting to SOAP EC and download ETickets with a false success result during TSL processing
|
4
|
Fake assume always ticket is present during TSL task condition processing
|
5
|
Skip NPNS notification fetch for auto title downloads with a false success result
|
Error Results
NIM Results
Result
|
Description
|
0xE0E0D001
|
Non-null terminated string on IPC parameter for given length.
|
0xD960D004
|
Unexpected/invalid state enums. (generic)
|
0xC820D005
|
Invalid state under one managed title install manager.
|
0xD8A0D006
|
Error state enum value. (generic)
|
0xC920D009
|
Mismatch system title hash with server system title hash.
|
0xC860D00E
|
Max total size exceeded for system update pending titles. (128 MiB)
|
0xC8E0D011
|
Bad condition, title id for purpose or size under one managed title install manager.
|
0xC8A0D027
|
This occurs under certain code paths.
- Result translation of result error from:
- NIM module if description is between 100 to 299 (inclusive)
- Unexpected HTTP status, followed up also by generating error integer with 54400 + http status, result value used as a 005-xxxx error
|
0xD960D02E
|
During tsl.xml task condition check. Still unclear, type of task check
|
0xD960D030
|
During tsl.xml task condition check. Ticket missing for title when expected. Will not occur with autodbg flag bit 4 set.
|
0xD960D031
|
During tsl.xml task condition check. Title already installed when not overwrite mode.
|
0xD960D032
|
During tsl.xml task condition check. Task for title already exists with same or higher version in task.dat.
|
0xD960D033
|
During tsl.xml task condition check. Task for title already exists in task.dat.
|
0xD8E0D034
|
During tsl.xml task condition check. Unexpected task title type.
|
0xD960D035
|
During tsl.xml task condition check. Tsl.xml task will not be processed while max programmed maximum for tasks pending in task.dat is equal or exceeded. (10)
|
0xD960D037
|
Failed to load saved dtl.xml with result error of FS with description between 100 and 179, inclusive.
|
0xD960D038
|
During tsl.xml task condition check. Not enough space for target SDMC user title.
|
0xD8A0D03D
|
During tsl.xml task condition check. SDMC not inserted or non-writable for SDMC title. (bad media status)
|
0xD960D03E
|
During tsl.xml task condition check. Not enough space for target TWL user title.
|
0xD940D040
|
NIM ran into NPNS result 0xD8A15C07. Result translation.
|
0xD860D041
|
During tsl.xml task condition check. Pending task count of task.dat and installed SDMC user title count exceed programmed max. (300)
|
0xD860D042
|
During tsl.xml task condition check. Pending task count of task.dat and installed TWL user title count exceed programmed max. (40)
|
0xD880D043
|
HTTP 404 while fetching title crypto seed from kagiya.
|
0xD880D044
|
HTTP 503 while fetching title crypto seed from kagiya.
|
NPNS Results
NPNS has a module number for results, but no module exists, but can be at least in part found inside NIM.
Result
|
Description
|
0xD8615C01
|
Allocation error, insufficient memory.
|
0xD8A15C02
|
HTTP non 2xx, json message processing, default error code switch result error.
|
0xD8A15C03
|
JSON processing errors.
|
0xD8A15C04
|
Notifications array bigger than expected.
|
0xD8A15C05
|
HTTP Empty body response.
|
0xD8A15C06
|
HTTP non 2xx, json message processing, error code 1003 given in json body.
|
0xD8A15C07
|
HTTP non 2xx, json message processing, error code 1000 given in json body.
|
0xD8A15C08
|
HTTP non 2xx, json message processing, error code 1004 given in json body.
|
Other Results
Any other result that is not given by other modules as a response, but found internally in NIM.
Result
|
Module value
|
Description
|
0xD8600801
|
Util (2)
|
Encoding errors. In NIM, if error while encoding base64 for X-Authentication-Key or X-Authentication-Data HTTP parameters.
|