NIM Services

NIM Services

NIM updater service “nim:u” #

Command HeaderDescription
0x00010000StartNetworkUpdate
0x00020000GetProgress
0x00030000Cancel
0x00040000CommitSystemTitles
0x00050000GetBackgroundEventForMenu
0x00060000GetBackgroundEventForNews
0x00070000FormatSaveData
0x00080000GetCustomerSupportCode
0x00090000IsCommittableAllSystemTitles
0x000A0000GetBackgroundProgress
0x000B0000GetSavedHash
0x000C0082UnregisterTask
0x000D0080IsRegistered
0x000E0080FindTaskInfo
0x000F0042GetTaskInfos
0x00100000DeleteUnmanagedContexts
0x00110000UpdateAutoTitleDownloadTasksAsync
0x00120000StartPendingAutoTitleDownloadTasksAsync
0x00130000GetAsyncResult
0x00140000CancelAsyncCall
0x00150000IsPendingAutoTitleDownloadTasks
0x00160000GetNumAutoTitleDownloadTasks
0x00170042GetAutoTitleDownloadTaskInfos
0x00180080CancelAutoTitleDownloadTask
0x00190002SetAutoDbgDat
0x001A0002GetAutoDbgDat
0x001B0042SetDbgTasks
0x001C0042GetDbgTasks
0x001D0000DeleteDbgData
0x001E0042SetTslXml
0x001F0000GetTslXmlSize
0x00200042GetTslXml
0x00210000DeleteTslXml
0x00220042SetDtlXml
0x00230000GetDtlXmlSize
0x00240042GetDtlXml
0x00250000UpdateAccountStatus
0x00260180StartTitleDownload
0x00270000StopTitleDownload
0x00280000GetTitleDownloadProgress
0x00290246RegisterTask
0x002A0000IsSystemUpdateAvailable
0x002B0000? (Response: 0 = 0x002B0040, 1 = Result Code)
0x002C0000UpdateTickets
0x002D00C0DownloadTitleSeedAsync
0x002E0000DownloadMissingTitleSeedsAsync

NIM shop service “nim:s” #

Command HeaderDescription
0x00010200StartDownloadSimple
0x00020000CancelDownload
0x00030000GetProgress
0x00050082UnregisterTask
0x00060080IsTaskRegistered
0x00070080GetTaskInfoFromTitleId
0x00080042GetTaskList
0x0009xxxxReturns 0xE0C0D3F4, not implemented.
0x000A0000CheckSysupdateAvailableSOAP
0x000B0084SetAttribute
0x000C0082SetAttributeInt32
0x000D0082Connect
0x000E0000UnregisterSOAP, aka soap account delete
0x000F0042SetCountrySOAP, change effective country registry
0x00100080Returns 0xE0C0D3F4, not implemented, reads for an int64 in IPC.
0x001100C4Returns 0xE0C0D3F4, not implemented, reads for IPC parameters.
0x00120084SetExternalAccountSOAP
0x00130042DeleteExternalAccountSOAP
0x00140000DeleteSavedCardSOAP
0x00150082ListCashReplenishAmountsSOAP
0x0016020AListTitles
0x0017020AListContentSetsExSOAP
0x0018020AListItemsSOAP
0x0019028CListContentSetGroupsSOAP
0x001E0104GetTaxesSOAP
0x001F0106GetTaxLocationSOAP
0x00220080AccountDeleteTitleETicketsSOAP. The SOAP request is sent only after the ticket for the specified titleID has been successfully deleted.
0x00290000AccountCheckBalanceSOAP
0x002D0042DownloadTickets
0x0036xxxxReturns 0xE0C0D3F4, not implemented.
0x003C0002RegisterSelf
0x003F0000GetInitializeResult. Checks whether nim is properly initialized or not. If it is not, the result code returned is non-zero.
0x00420240StartDownload
0x00550246RegisterTask
0x00570082ConnectNoTicketDownload
0x005B0000DeleteInitAccSavedData
0x005C0000DeleteAccountSavedData
0x005F00C0DownloadTitleSeed

NIM server service “nim:aoc” #

Command HeaderDescription
0x00030042SetApplicationId
0x00040042SetTin
0x000902D0ListContentSetsEx
0x00180000GetBalance
0x001D0000GetCustomerSupportCode
0x00210000Initialize
0x00240282CalculateContentsRequiredSize
0x00250000RefreshServerTime

NIM service “nim:ndm” #

Command HeaderDescription
0x00010000GetDaemonEventHandle
0x00020000Does nothing, always returns 0
0x00030000SetDaemonToWorkingState
0x00040040SetDaemonToSuspendedState
0x00050000GetDaemonState

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 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.

NIM System_SaveData #

hash.dat #

OffsetSizeDescription
0x600x1u8 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.
0x610x21ASCII hex SystemTitleHash, including NUL-terminator. This is the latest SystemTitleHash which NIM module received from SOAP.

Types #

SystemUpdateProgress #

OffsetLengthDescription
0x000x01System Update State
0x010x03Padding
0x040x04Last Operation Result Code
0x080x08Current Title Downloaded Bytes
0x100x08Current Title Total Bytes
0x180x08Titles Downloaded
0x200x08Titles Total

SystemUpdateState #

ValueDescription
0Not Initialized
1Starting System Update
2Fetching System Hash and Account Status
3Installing New Tickets
4Installing Titles
5Update Complete
6Failed - System Updates Disabled (Dev Units Only)
7? (Only for background updates)
8? (Only for background updates)

TitleDownloadProgress #

OffsetLengthDescription
0x000x01Title Download State
0x010x03Padding
0x040x04Last Operation Result Code
0x080x08Downloaded Bytes
0x100x08Total Bytes

TitleDownloadState #

ValueDescription
0Not Initialized
1Starting Title Download
2Downloading and Installing TMD
3Committing TMD
4Downloading and Installing Contents
5Contents Installed
6Committing Titles
7Finished
8? (Unknown error regarding title version?)
9? (Creating the .ctx file (or error doing so)?)
10Background Download Failed

TitleDownloadConfig #

OffsetLengthDescription
0x000x08Title ID
0x080x04Title version
0x0C0x04Unknown (always 0?)
0x100x01Age Rating (for HOME Menu parental controls)
0x110x01Media Type
0x120x02Padding
0x140x04Unknown (always 0?)

BackgroundTitleDownloadConfig #

OffsetLengthDescription
0x0000x018Title Download Config
0x0180x001Unknown
0x0190x001Unknown
0x01A0x006Padding
0x0200x008Requester Title ID
0x0280x090Title Name (UTF-16)
0x0B80x002Title Name Forced NUL Terminator (always 0)
0x0BA0x048Developer Name (UTF-16)
0x1020x002Developer Name Forced NUL Terminator (always 0)

BackgroundTitleDownloadTaskInfo #

OffsetLengthDescription
0x0000x104Background Title Download Config
0x1040x004Padding
0x1080x018Title Download Progress

AutoTitleDownloadTaskInfo #

OffsetLengthDescription
0x0000x008Task ID
0x0080x008Title ID
0x0100x004Title Version
0x0140x014Unknown
0x0280x008Required Storage Space
0x0300x004Last Operation Result code
0x0340x004Last Operation Customer Support Code
0x0380x090Title Name (UTF-16)
0x0C80x002Title Name Forced NUL Terminator (always 0)
0x0CA0x048Developer Name (UTF-16)
0x1120x002Developer Name Forced NUL Terminator (always 0)
0x1140x024Unknown

InstallationMode #

ValueDescription
0Initial Installation
1Unknown
2Unknown
3Re-installation

Autodbg #

Despite this being for debug purposes, it’s used in retail if present.

OffsetLengthDescription
0x0000x004Debug flags
0x0040x004Number of debug tasks in dbgtasks.dat
0x0080x100Debug URL dst.xml override

Autodbg flag bits #

BitDescription
0Use the tasks stored in dbgtasks.dat
1Use provided debug dtl.xml URL override
2Disable the download of dtl.xml
3Skip connecting to SOAP EC and download ETickets with a false success result during TSL processing
4Fake assume always ticket is present during TSL task condition processing
5Skip NPNS notification fetch for auto title downloads with a false success result

Error Results #

NIM Results #

ResultDescription
0xE0E0D001Non-null terminated string on IPC parameter for given length.
0xD960D003SOAP EC/NUP manager internal error number translation of unhandled values or -4199.
0xD960D004Unexpected/invalid state enums. (generic)
0xC820D005Invalid state under one title install manager.
0xD8A0D006Error state enum value. (generic)
0xC920D008When content downloading, HTTP Status was not 200 or 206 when connecting, and when status is 206, the Content-Range values failed sanity check.
0xC920D009Mismatch system title hash with server system title hash.
0xC960D00CFailed to convert country enum value in CFG save block 0xB0000 to country ISO 3166-1 Alpha-2 code.
0xC960D00DCFG didn't reply any serial number or dummy serial number "000000000000000" was given.
0xC860D00EMax total size exceeded for system update pending titles. (128 MiB)
0xC880D00F*to be filled*
0xC8E0D011Bad condition, title id for purpose or size under one title install manager.
0xC960D012Invalid .dat or less than expected size of buffer length read from .dat save files during raw data load.
0xC960D013Daemon service is suspended.
0xC8A0D014*to be filled*
0xC960D015Version mismatch for reinstall condition.
0xC960D016Used in a few contexts where length does not match expected or the limit. Example, seed data size from HTTP is not 16 bytes.
0xC920D017SetIVSData will not perform, conditions are not adequate to set IVS. In Service Standby mode or not registered successfully in IAS.
0xC920D019Certain EC connect flows disallowed to continue while IVS is waiting to be synced from servers. System Transfer has previously occurred and IVS is pending.
0xC920D01AFor nim:s IPC cmd id 0x40, IVS not flagged for synchronization on target console on EC connect after system transfer.
0xC960D01BFailed to convert language enum value in CFG save block 0xA0002 to language ISO 639-1 code.
0xE0E0D01CInvalid installation mode for some IPC contexts.
0xE0C0D01EMay be either:

  • Trying to set autodbg or dbgtasks with too many tasks on nim:u IPC cmd ids 0x19 and 0x1B, respectively.
  • Non debug ENVINFO when calling debug version of get balance nim:s IPC cmd id 0x56.
  • A boolean parameter for nim:s IPC cmd id 0x58 was set false.
0xD860D020May be either:

  • Result translation of 0xC860D06E if returned by the early attributes filter handler.
  • If the internal Work-only heap fails to initialize with buffer length lesser than 32 bytes. This buffer is given over IPC.
0xC860D021Task manager has run out of task slots.
0xC920D022Buffer size too small for ticket length on nim:aoc IPC cmd id 0x1B.
0xD880D023When Account Id missing for nim:aoc IPC cmd id 0x1B and 0x20 or when Account Id or Token are missing for nim:s IPC cmd id 0x53.
0xD860D024Failed to initialize Data Heap using buffer given over IPC.
0xD920D025SOAP reply implied that Service Standby mode is enabled. Certain EC flows cancelled.
0xC8A0D026May be either:

  • Result translation, NIM ran into NPNS result 0xD8A15C06 or NIM result 0xD960D02B.
  • System updates pending while trying to SOAP EC connect with ETicket download while processing auto downloads.
0xC8A0D027This occurs under certain code paths.

  1. Result translation of result error from:
  • HTTP module
  • SSL module
  • NIM module if description is between 100 to 299 (inclusive), 200 descriptions to fit the reserved range of the SOAP manager internal error range of -4000 to -4199
  • Unexpected HTTP status, followed up also by generating error integer with 54400 + http status, result value used as a 005-xxxx error

  • 0xD960D028Generic XML parsing error. Not related to SOAP XML.
    0xD960D029XML processor stub function called. Not related to SOAP XML.
    0xD960D02AGeneric XML data processing error: bad length or insufficient memory. Not related to SOAP XML.
    0xD960D02BResult translation of 0xD960D028.
    0xD960D02CAuto download programmed max task count exceeded trying to add more to list. (64)
    0xD960D02Dtsl.xml or tsl.xml.tmp couldn't be opened. FS result translation of description between 100 and 179, inclusive.
    0xD960D02EDuring tsl.xml task condition check. Still unclear, type of task check
    0xD960D030During tsl.xml task condition check. Ticket missing for title when expected. Will not occur with autodbg flag bit 4 set.
    0xD960D031During tsl.xml task condition check. Title already installed when not overwrite mode.
    0xD960D032During tsl.xml task condition check. Task for title already exists with same or higher version in task.dat.
    0xD960D033During tsl.xml task condition check. Task for title already exists in task.dat.
    0xD8E0D034During tsl.xml task condition check. Unexpected task title type.
    0xD960D035During 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)
    0xD960D037Failed to load saved dtl.xml with result error of FS with description between 100 and 179, inclusive.
    0xD960D038During tsl.xml task condition check. Not enough space for target SDMC user title.
    0xD8A0D03ANo valid NPNS X-Device-Token was available while trying to fetch it from CFG save block 0xF0006.
    0xD940D03BSelected tsl.xml task was cancelled with nim:u IPC cmd id 0x18.
    0xD960D03CResult translation for 0xD960D028 while trying to read XML. Not related to SOAP XML.
    0xD8A0D03DDuring tsl.xml task condition check. SDMC not inserted or non-writable for SDMC title. (bad media status)
    0xD960D03EDuring tsl.xml task condition check. Not enough space for target TWL user title.
    0xD940D03FNPNS notification url is not HTTPS.
    0xD940D040NIM ran into NPNS result 0xD8A15C07. Result translation.
    0xD860D041During tsl.xml task condition check. Pending task count of task.dat and installed SDMC user title count exceed programmed max. (300)
    0xD860D042During tsl.xml task condition check. Pending task count of task.dat and installed TWL user title count exceed programmed max. (40)
    0xD880D043HTTP 404 while fetching title crypto seed from kagiya.
    0xD880D044HTTP 503 while fetching title crypto seed from kagiya.
    0xC960D065SOAP EC/NUP manager internal error number translation of value -4001
    0xE0C0D066SOAP EC/NUP manager internal error number translation of value -4002
    0xE0E0D068SOAP EC/NUP manager internal error number translation of value -4004
    0xC860D069SOAP EC/NUP manager internal error number translation of value -4005
    0xC880D06ASOAP EC/NUP manager internal error number translation of value -4006
    0xC8A0D06BSOAP EC/NUP manager internal error number translation of value -4007
    0xC8A0D06CSOAP EC/NUP manager internal error number translation of value -4008
    0xC860D06ESOAP EC/NUP manager internal error number translation of value -4010
    0xC920D073SOAP EC/NUP manager internal error number translation of value -4015
    0xC900D075SOAP EC/NUP manager internal error number translation of value -4017
    0xC860D076SOAP EC/NUP manager internal error number translation of value -4018
    0xC920D077SOAP EC/NUP manager internal error number translation of value -4019
    0xC900D084SOAP EC/NUP manager internal error number translation of value -4032
    0xC900D085SOAP EC/NUP manager internal error number translation of value -4033
    0xC920D086SOAP EC/NUP manager internal error number translation of value -4034
    0xC920D08ASOAP EC/NUP manager internal error number translation of value -4038
    0xC900D08BSOAP EC/NUP manager internal error number translation of value -4039
    0xC920D08CSOAP EC/NUP manager internal error number translation of value -4040
    0xE0A0D08DSOAP EC/NUP manager internal error number translation of value -4041
    0xC920D08FSOAP EC/NUP manager internal error number translation of value -4043
    0xC920D095SOAP EC/NUP manager internal error number translation of value -4049
    0xE0E0D099SOAP EC/NUP manager internal error number translation of value -4053
    0xC900D09FSOAP EC/NUP manager internal error number translation of value -4059
    0xE100D0A0SOAP EC/NUP manager internal error number translation of value -4060
    0xE100D0A1SOAP EC/NUP manager internal error number translation of value -4061
    0xC920D0A4SOAP EC/NUP manager internal error number translation of value -4064
    0xC920D0A7SOAP EC/NUP manager internal error number translation of value -4067
    0xC920D0A8SOAP EC/NUP manager internal error number translation of value -4068
    0xE0A0D0A9SOAP EC/NUP manager internal error number translation of value -4069
    0xC920D0ADSOAP EC/NUP manager internal error number translation of value -4073
    0xC920D0B1SOAP EC/NUP manager internal error number translation of value -4077
    0xC920D0B3SOAP EC/NUP manager internal error number translation of value -4079
    0xC920D0B5SOAP EC/NUP manager internal error number translation of value -4081

    NPNS Results #

    NPNS has a module number for results, but no module exists, but can be at least in part found inside NIM.

    ResultDescription
    0xC9215C00Result translation, HTTP result 0xD8A0A018.
    0xD8615C01Allocation error, insufficient memory.
    0xD8A15C02HTTP non 2xx, json message processing, default error code switch result error.
    0xD8A15C03JSON processing errors.
    0xD8A15C04Notifications array bigger than expected.
    0xD8A15C05HTTP Empty body response.
    0xD8A15C06HTTP non 2xx, json message processing, error code 1003 given in json body.
    0xD8A15C07HTTP non 2xx, json message processing, error code 1000 given in json body.
    0xD8A15C08HTTP 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.

    ResultModule valueDescription
    0xD8600801Util (2)Encoding errors. In NIM, if error while encoding base64 for X-Authentication-Key or X-Authentication-Data HTTP parameters.

    Category:Services