<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://www.3dbrew.org/w/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=AriA99</id>
	<title>3dbrew - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://www.3dbrew.org/w/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=AriA99"/>
	<link rel="alternate" type="text/html" href="https://www.3dbrew.org/wiki/Special:Contributions/AriA99"/>
	<updated>2026-04-03T20:42:19Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.43.1</generator>
	<entry>
		<id>https://www.3dbrew.org/w/index.php?title=Gamecards&amp;diff=22569</id>
		<title>Gamecards</title>
		<link rel="alternate" type="text/html" href="https://www.3dbrew.org/w/index.php?title=Gamecards&amp;diff=22569"/>
		<updated>2024-06-01T11:11:43Z</updated>

		<summary type="html">&lt;p&gt;AriA99: Link to where the 0x200 InitialData comes from, I noticed the pattern looking at the Lotus3 page at Switchbrew&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[File:Gamecard.jpg|thumb|right|A 3DS gamecard]] &lt;br /&gt;
[[File:GamecardPhy.jpg|thumb|right|Close-up of PCB]] &lt;br /&gt;
&lt;br /&gt;
===Physical interface===&lt;br /&gt;
The 3DS gamecards have the same physical interface as regular DS and DSi gamecards. There is only a minor cosmetic difference in the plastic case, which has a small extruding notch on the top-right side. As such, it prevents insertion of the gamecard into old Nintendo DS or DSi systems. &lt;br /&gt;
&lt;br /&gt;
When modifying the case so that the 3DS gamecard fits in a DS or DSi system, those systems will refuse to detect the gamecard and show no banner icon.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
!  Pin&lt;br /&gt;
!  Name&lt;br /&gt;
!colspan=&amp;quot;2&amp;quot;| Description&lt;br /&gt;
|-&lt;br /&gt;
|  1&lt;br /&gt;
|  GND&lt;br /&gt;
|colspan=&amp;quot;2&amp;quot;| Ground&lt;br /&gt;
|-&lt;br /&gt;
|  2&lt;br /&gt;
|  CLK&lt;br /&gt;
|colspan=&amp;quot;2&amp;quot;| Clock. Frequencies 6.7MHz and 4.2MHz for DS/DSi gamecards, up to 16.6MHz for 3DS gamecards (for both SPI and ROM transfers).&lt;br /&gt;
|-&lt;br /&gt;
|  3&lt;br /&gt;
|  NC&lt;br /&gt;
|colspan=&amp;quot;2&amp;quot;| Not connected. Possibly used to program cards.&lt;br /&gt;
|-&lt;br /&gt;
|  4&lt;br /&gt;
|  RCS&lt;br /&gt;
|colspan=&amp;quot;2&amp;quot;| ROM select, active low. Pulled low to start a ROM transfer.&lt;br /&gt;
|-&lt;br /&gt;
|  5&lt;br /&gt;
|  RST&lt;br /&gt;
|colspan=&amp;quot;2&amp;quot;| Reset, active low. &lt;br /&gt;
|-&lt;br /&gt;
|  6&lt;br /&gt;
|  ECS&lt;br /&gt;
|colspan=&amp;quot;2&amp;quot;| Savegame chip select, active low. Pulled low to start a savegame SPI transfer.&lt;br /&gt;
|-&lt;br /&gt;
|  7&lt;br /&gt;
|  IRQ&lt;br /&gt;
|colspan=&amp;quot;2&amp;quot;| Removal detection.&lt;br /&gt;
|-&lt;br /&gt;
|  8&lt;br /&gt;
|  VCC&lt;br /&gt;
|colspan=&amp;quot;2&amp;quot;| Powersupply 3.3V.&lt;br /&gt;
|-&lt;br /&gt;
!&lt;br /&gt;
!&lt;br /&gt;
! ROM bus (selected by RCS)&lt;br /&gt;
! Savegame bus (selected by ECS)&lt;br /&gt;
|-&lt;br /&gt;
|  9&lt;br /&gt;
|  DAT0&lt;br /&gt;
|rowspan=&amp;quot;8&amp;quot;| Bidirectional data bus.&lt;br /&gt;
|rowspan=&amp;quot;4&amp;quot;| NC&lt;br /&gt;
|-&lt;br /&gt;
|  10&lt;br /&gt;
|  DAT1&lt;br /&gt;
|-&lt;br /&gt;
|  11&lt;br /&gt;
|  DAT2&lt;br /&gt;
|-&lt;br /&gt;
|  12&lt;br /&gt;
|  DAT3&lt;br /&gt;
|-&lt;br /&gt;
|  13&lt;br /&gt;
|  DAT4&lt;br /&gt;
|  NC/SIO3&lt;br /&gt;
|-&lt;br /&gt;
|  14&lt;br /&gt;
|  DAT5&lt;br /&gt;
|  WP#/SIO2&lt;br /&gt;
|-&lt;br /&gt;
|  15&lt;br /&gt;
|  DAT6&lt;br /&gt;
|  SO/SIO1&lt;br /&gt;
|-&lt;br /&gt;
|  16&lt;br /&gt;
|  DAT7&lt;br /&gt;
|  SI/SIO0&lt;br /&gt;
|-&lt;br /&gt;
|  17&lt;br /&gt;
|  GND&lt;br /&gt;
|colspan=&amp;quot;2&amp;quot;| Ground&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
!&lt;br /&gt;
!  3DS&lt;br /&gt;
!  DS and DSi&lt;br /&gt;
|-&lt;br /&gt;
|  VCC&lt;br /&gt;
|  Only enabled when the power supply bits of [[CONFIG9_Registers#CFG9_CARDSTATUS|CFG9_CARDSTATUS]] are set to &amp;lt;tt&amp;gt;10&amp;lt;/tt&amp;gt;&lt;br /&gt;
|  Always available when card is detected&lt;br /&gt;
|-&lt;br /&gt;
| Card-detect&lt;br /&gt;
| Physical insertion switch, readable through [[CONFIG9_Registers#CFG9_CARDSTATUS|CFG9_CARDSTATUS]] bit 0&lt;br /&gt;
| IRQ pin&lt;br /&gt;
|-&lt;br /&gt;
| Time to first clock pulse&lt;br /&gt;
| ~280ms&lt;br /&gt;
| ~166ms&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===SPI flash===&lt;br /&gt;
Savegame SPI flash transfers use CPOL=1 and CPHA=1. So far, only one savegame FLASH chip has been identified. The chip identifies as &amp;lt;tt&amp;gt;0xC22211&amp;lt;/tt&amp;gt;. The JEDEC manufacturer ID is Macronix, and despite the chip label saying 25L1001, the JEDEC ID matches the MX25L1021E. Datasheet at:&amp;lt;br&amp;gt;&lt;br /&gt;
[https://www.macronix.com/Lists/Datasheet/Attachments/8796/MX25L1021E,%203V,%201Mb,%20v1.3.pdf Macronix (Rev. 1.3, nov. 11, 2013)] &amp;lt;br&amp;gt;&lt;br /&gt;
[https://web.archive.org/web/20160307235354/http://www.beilenet.com/download/MX25L1021E,%203V,%201Mb,%20v0.01.pdf Old version mirror (Rev. 0.01, apr. 07, 2010)] &amp;lt;br&amp;gt;&lt;br /&gt;
However, the MX25L1021E doesn&#039;t support the 4 bit wide transmission that the 3DS uses to talk to the SPI flash. It is thus likely that this is a custom flash chip.&lt;br /&gt;
&lt;br /&gt;
===Format===&lt;br /&gt;
Cartridges can come in several sizes and include system updates in a region reserved for this. In ROMs less than 1GB the update region can be found with:&lt;br /&gt;
CART_SIZE_MAX-( 0x280000*(CART_SIZE_MAX/CART_SIZE_128MB) )-0x2000000. The region is then 0x2000000 bytes.&lt;br /&gt;
&lt;br /&gt;
===Protocol===&lt;br /&gt;
The communication protocol between the 3DS system and the 3DS gamecard has changed almost completely in comparison with the [http://problemkaputt.de/gbatek.htm#dscartridgeprotocol DS and DSi gamecard communication protocol].&lt;br /&gt;
&lt;br /&gt;
The protocol begins in a DS-compatible 8-byte command mode (unencrypted). It switches to a 3DS-only 16-byte mode (encrypted) after the 0x3e command. When 16-byte commands are used, the data bus maintains the value 0x00 until the card signals it is ready by clocking a single byte 0x01, followed by the actual data. After each 0x200-byte block of actual data, a 4-byte standard CRC32 of the block data (before encryption, polynomial 0x82608edb and the final output is xored with 0xffffffff) follows.&lt;br /&gt;
&lt;br /&gt;
Here&#039;s a set of sample gamecard commands for the title LEGO Star Wars III The Clone Wars (EUR), title ID 0004000000038c00, that a 3DS sends to a 3DS gamecard:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
!  Size&lt;br /&gt;
!  Command&lt;br /&gt;
!  Decrypted command&lt;br /&gt;
!  Description&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;tt&amp;gt;2000&amp;lt;/tt&amp;gt;&lt;br /&gt;
|&amp;lt;tt&amp;gt;9F00000000000000&amp;lt;/tt&amp;gt;&lt;br /&gt;
|&amp;lt;tt&amp;gt;9F00000000000000&amp;lt;/tt&amp;gt;&lt;br /&gt;
|Reset&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;tt&amp;gt;0000&amp;lt;/tt&amp;gt;&lt;br /&gt;
|&amp;lt;tt&amp;gt;71C93FE9BB0A3B18&amp;lt;/tt&amp;gt;&lt;br /&gt;
|&amp;lt;tt&amp;gt;71C93FE9BB0A3B18&amp;lt;/tt&amp;gt;&lt;br /&gt;
|Signal that the gamecard should act as a 3DS gamecard&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;tt&amp;gt;0004&amp;lt;/tt&amp;gt;&lt;br /&gt;
|&amp;lt;tt&amp;gt;9000000000000000&amp;lt;/tt&amp;gt;&lt;br /&gt;
|&amp;lt;tt&amp;gt;9000000000000000&amp;lt;/tt&amp;gt;&lt;br /&gt;
|Get gamecard ID1, response=9000FEC2&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;tt&amp;gt;0004&amp;lt;/tt&amp;gt;&lt;br /&gt;
|&amp;lt;tt&amp;gt;9000000000000000&amp;lt;/tt&amp;gt;&lt;br /&gt;
|&amp;lt;tt&amp;gt;9000000000000000&amp;lt;/tt&amp;gt;&lt;br /&gt;
|Get gamecard ID1, response=9000FEC2&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;tt&amp;gt;0004&amp;lt;/tt&amp;gt;&lt;br /&gt;
|&amp;lt;tt&amp;gt;A000000000000000&amp;lt;/tt&amp;gt;&lt;br /&gt;
|&amp;lt;tt&amp;gt;A000000000000000&amp;lt;/tt&amp;gt;&lt;br /&gt;
|Get gamecard ID2, response=00000000&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;tt&amp;gt;0000&amp;lt;/tt&amp;gt;&lt;br /&gt;
|&amp;lt;tt&amp;gt;3E00000000000000&amp;lt;/tt&amp;gt;&lt;br /&gt;
|&amp;lt;tt&amp;gt;3E00000000000000&amp;lt;/tt&amp;gt;&lt;br /&gt;
|Enter 16-byte command mode&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;tt&amp;gt;0200&amp;lt;/tt&amp;gt;&lt;br /&gt;
|&amp;lt;tt&amp;gt;82000000000000000000000000000000&amp;lt;/tt&amp;gt;&lt;br /&gt;
|&amp;lt;tt&amp;gt;82000000000000000000000000000000&amp;lt;/tt&amp;gt;&lt;br /&gt;
|Get gamecard header and enable encryption&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;tt&amp;gt;0000&amp;lt;/tt&amp;gt;&lt;br /&gt;
|&amp;lt;tt&amp;gt;F32C92D85C9D44DED3E0E41DBE7C90D9&amp;lt;/tt&amp;gt;&lt;br /&gt;
|&amp;lt;tt&amp;gt;8300000000000000708DF1A731717D0B&amp;lt;/tt&amp;gt; &lt;br /&gt;
|Seed (rekey cryptography)&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;tt&amp;gt;0004&amp;lt;/tt&amp;gt;&lt;br /&gt;
|&amp;lt;tt&amp;gt;696B9D8582FB55D31B68CAFE70C74A95&amp;lt;/tt&amp;gt;&lt;br /&gt;
|&amp;lt;tt&amp;gt;A200000000000000708DF1A731717D0B&amp;lt;/tt&amp;gt;&lt;br /&gt;
|Get gamecard ID1 (using cryptography), response=9000FEC2&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;tt&amp;gt;0004&amp;lt;/tt&amp;gt;&lt;br /&gt;
|&amp;lt;tt&amp;gt;BAA4812CA0AC9C5D19399530E3ACCCAB&amp;lt;/tt&amp;gt;&lt;br /&gt;
|&amp;lt;tt&amp;gt;A300000000000000708DF1A731717D0B&amp;lt;/tt&amp;gt;&lt;br /&gt;
|Get gamecard ID2 (using cryptography)&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;tt&amp;gt;0000&amp;lt;/tt&amp;gt;&lt;br /&gt;
|&amp;lt;tt&amp;gt;178E427C22D87ADB86387249A97D321A&amp;lt;/tt&amp;gt;&lt;br /&gt;
|&amp;lt;tt&amp;gt;C500000000000000708DF1A731717D0B&amp;lt;/tt&amp;gt;&lt;br /&gt;
|Refresh cart NAND&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;tt&amp;gt;0004&amp;lt;/tt&amp;gt;&lt;br /&gt;
|&amp;lt;tt&amp;gt;E06019B1BD5C9130ED6A4D9F4A9E7193&amp;lt;/tt&amp;gt;&lt;br /&gt;
|&amp;lt;tt&amp;gt;A200000000000000708DF1A731717D0B&amp;lt;/tt&amp;gt;&lt;br /&gt;
|Get gamecard ID1 (using cryptography), response=9000FEC2&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;tt&amp;gt;0004&amp;lt;/tt&amp;gt;&lt;br /&gt;
|&amp;lt;tt&amp;gt;4E0D224862523BBFE2E6255F80E15F37&amp;lt;/tt&amp;gt;&lt;br /&gt;
|&amp;lt;tt&amp;gt;A200000000000000708DF1A731717D0B&amp;lt;/tt&amp;gt;&lt;br /&gt;
|Get gamecard ID1 (using cryptography), response=9000FEC2&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;tt&amp;gt;0004&amp;lt;/tt&amp;gt;&lt;br /&gt;
|&amp;lt;tt&amp;gt;4CDF93D319FB62D0DB632A45E3E8D84C&amp;lt;/tt&amp;gt;&lt;br /&gt;
|&amp;lt;tt&amp;gt;A200000000000000708DF1A731717D0B&amp;lt;/tt&amp;gt;&lt;br /&gt;
|Get gamecard ID1 (using cryptography), response=9000FEC2&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;tt&amp;gt;0004&amp;lt;/tt&amp;gt;&lt;br /&gt;
|&amp;lt;tt&amp;gt;9AA5D80551002F955546D296A57F0FEF&amp;lt;/tt&amp;gt;&lt;br /&gt;
|&amp;lt;tt&amp;gt;A200000000000000708DF1A731717D0B&amp;lt;/tt&amp;gt;&lt;br /&gt;
|Get gamecard ID1 (using cryptography), response=9000FEC2&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;tt&amp;gt;0004&amp;lt;/tt&amp;gt;&lt;br /&gt;
|&amp;lt;tt&amp;gt;C12BA81AEF30DDDBD93FAD5D544C6334&amp;lt;/tt&amp;gt;&lt;br /&gt;
|&amp;lt;tt&amp;gt;A200000000000000708DF1A731717D0B&amp;lt;/tt&amp;gt;&lt;br /&gt;
|Get gamecard ID1 (using cryptography), response=9000FEC2&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;tt&amp;gt;0200&amp;lt;/tt&amp;gt;&lt;br /&gt;
|&amp;lt;tt&amp;gt;62EC5FB7F420AE1DC6253AE18AFA5BB3&amp;lt;/tt&amp;gt;&lt;br /&gt;
|&amp;lt;tt&amp;gt;BF000000000000000000000000000000&amp;lt;/tt&amp;gt;&lt;br /&gt;
|Read gamecard at address 0&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;tt&amp;gt;0200&amp;lt;/tt&amp;gt;&lt;br /&gt;
|&amp;lt;tt&amp;gt;E3FA23AA016BE0C93430D1F42FF41324&amp;lt;/tt&amp;gt;&lt;br /&gt;
|&amp;lt;tt&amp;gt;BF000000000040000000000000000000&amp;lt;/tt&amp;gt;&lt;br /&gt;
|Read gamecard at address 0x4000&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The header command has some initial dummy bytes, and eventually responds with the 0x200 byte [[NCSD#InitialData|InitialData]]. Here&#039;s an example for Lego Starwars 3:&lt;br /&gt;
 0000000: 00 8c 03 00 00 00 04 00 00 00 00 00 00 00 00 00  ................&lt;br /&gt;
 0000010: b3 cf fb c6 6a b1 cb 20 32 af ce 35 d4 1c 74 c9  ....j.. 2..5..t.&lt;br /&gt;
 0000020: 8e 6b 27 2f 08 01 28 3b d4 30 de 44 37 f5 b0 46  .k&#039;/..(;.0.D7..F&lt;br /&gt;
 0000030: 91 59 d7 38 33 48 df 83 fd 71 84 2c 00 00 00 00  .Y.83H...q.,....&lt;br /&gt;
 0000040: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................&lt;br /&gt;
 0000050: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................&lt;br /&gt;
 0000060: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................&lt;br /&gt;
 0000070: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................&lt;br /&gt;
 0000080: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................&lt;br /&gt;
 0000090: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................&lt;br /&gt;
 00000a0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................&lt;br /&gt;
 00000b0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................&lt;br /&gt;
 00000c0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................&lt;br /&gt;
 00000d0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................&lt;br /&gt;
 00000e0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................&lt;br /&gt;
 00000f0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................&lt;br /&gt;
 0000100: 4e 43 43 48 7a 7f 0e 00 00 8c 03 00 00 00 04 00  NCCHz...........&lt;br /&gt;
 0000110: 36 34 02 00 00 00 00 00 00 8c 03 00 00 00 04 00  64..............&lt;br /&gt;
 0000120: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................&lt;br /&gt;
 0000130: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................&lt;br /&gt;
 0000140: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................&lt;br /&gt;
 0000150: 43 54 52 2d 50 2d 41 4c 47 50 00 00 00 00 00 00  CTR-P-ALGP......&lt;br /&gt;
 0000160: 0c 27 e3 c1 de 7b 2a e2 d3 11 4f 32 a4 ee bf 46  .&#039;...{*...O2...F&lt;br /&gt;
 0000170: 9a fd 0c f3 52 c1 1d 49 84 c2 a9 f1 d2 14 4c 63  ....R..I......Lc&lt;br /&gt;
 0000180: 00 04 00 00 00 00 00 00 00 00 00 00 01 03 00 00  ................&lt;br /&gt;
 0000190: 05 00 00 00 01 00 00 00 00 00 00 00 00 00 00 00  ................&lt;br /&gt;
 00001a0: 06 00 00 00 1c 0a 00 00 01 00 00 00 00 00 00 00  ................&lt;br /&gt;
 00001b0: 22 0a 00 00 58 75 0e 00 01 00 00 00 00 00 00 00  &amp;quot;...Xu..........&lt;br /&gt;
 00001c0: 13 0c 04 26 15 f6 47 c4 c6 32 25 ea 9e 67 f8 a2  ...&amp;amp;..G..2%..g..&lt;br /&gt;
 00001d0: 7b 15 24 6b 88 fb c7 a9 27 25 7b 84 97 7b 78 7b  {.$k....&#039;%{..{x{&lt;br /&gt;
 00001e0: a6 5b ee 10 60 bb 6a 68 21 bb ce c6 00 03 5b 7e  .[..`.jh!.....[~&lt;br /&gt;
 00001f0: 64 fb 6e ac a7 f0 96 0c fb 1f 5a 37 08 77 28 f7  d.n.......Z7.w(.&lt;br /&gt;
&lt;br /&gt;
After the 0x82 command, cryptography is initialized, which can be reproduced following this algorithm; unless noted otherwise, all operations are in big endian byte order:&lt;br /&gt;
&lt;br /&gt;
# Set the [[AES_Registers|AES keyslot 0x3b keyY]] to the values at 0x000:0x010. The corresponding keyX is set in [[Bootloader|Boot9]].&lt;br /&gt;
# Decrypt the 16 bytes at 0x010:0x020 using AES-128-CCM in keyslot 0x3b using the 12-byte nonce at 0x030:0x03c to obtain the primary seed; if the response to the 0xa0 command AND 0x00000003 equals 3, instead use slot 0x11 and set the normalkey to 0x00000000000000000000000000000000. Verify that the 16-byte tag at 0x020:0x030 is valid.&lt;br /&gt;
# Split the primary seed into two halves: left and right.&lt;br /&gt;
# Initialize a context for the SNOW 2.0 stream cipher. The 128-bit key is the primary seed. The 128-bit IV is a 128-bit static value depending on the gamecard ID2.&lt;br /&gt;
# Call the SNOW 2.0 stream cipher 32 times to obtain 1024 bits (32 words) of output. Discard them.&lt;br /&gt;
# Initialize a context for the RC4 stream cipher. The 256-bit key consists of a 128-bit static value depending on the gamecard ID2 followed by four outputs of the SNOW 2.0 stream.&lt;br /&gt;
# Call the RC4 stream cipher 256 times to obtain 2048 bits (256 bytes) of output. Discard them.&lt;br /&gt;
&lt;br /&gt;
All commands and responses are now encrypted using RC4. The gamecard controller and gamecard itself share the RC4 key and advance the state accordingly.&lt;br /&gt;
&lt;br /&gt;
If the 0x83 command is sent, the cryptography is re-keyed:&lt;br /&gt;
&lt;br /&gt;
# Initialize a new context for the SNOW 2.0 stream cipher. The 128-bit key consists of the left half of the primary seed followed by the lower 64 bytes of the decrypted 0x83 command. The 128-bit IV is the same 128-bit static value depending on the gamecard ID2 as before.&lt;br /&gt;
# Call the SNOW 2.0 stream cipher 32 times to obtain 1024 bits (32 words) of output. Discard them.&lt;br /&gt;
# Initialize a new context for the RC4 stream cipher. The 256-bit key consists of the same 128-bit static value depending on the gamecard ID2 as before followed by four outputs of the new SNOW 2.0 stream.&lt;br /&gt;
# Call the RC4 stream cipher 256 times to obtain 2048 bits (256 bytes) of output. Discard them.&lt;br /&gt;
&lt;br /&gt;
The above example commands can be decrypted in this manner.&lt;br /&gt;
&lt;br /&gt;
The static values are fixed in the gamecard controller and gamecards themselves, they are not obtained from Process9 or anywhere in NATIVE_FIRM.&lt;/div&gt;</summary>
		<author><name>AriA99</name></author>
	</entry>
	<entry>
		<id>https://www.3dbrew.org/w/index.php?title=NCSD&amp;diff=22568</id>
		<title>NCSD</title>
		<link rel="alternate" type="text/html" href="https://www.3dbrew.org/w/index.php?title=NCSD&amp;diff=22568"/>
		<updated>2024-06-01T11:07:53Z</updated>

		<summary type="html">&lt;p&gt;AriA99: InitialData at +0x1000 is not part of the development cart extension&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:File formats]]&lt;br /&gt;
This page documents the format of NCSD.&lt;br /&gt;
&lt;br /&gt;
== Overview ==&lt;br /&gt;
There are two known specialisations of the NCSD container format. The CTR Cart Image (CCI) format and the 3DS&#039; raw [[Flash Filesystem#NAND structure|NAND format]]. CCI is the format of game ROM images.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;CTR System Update (CSU)&#039;&#039;&#039; is a variant of CCI, where the only difference is in the file extension. This is used with developer System Updates and associated [[3DS Development Unit Software|Tools]].&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
NCSD images start with a NCSD header, followed by up to a maximum of 8 [[NCCH]] partitions.&lt;br /&gt;
&lt;br /&gt;
For CCI images, the partitions are reserved as follows:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
!  [[NCCH]] Index&lt;br /&gt;
!  Reserved Use&lt;br /&gt;
|-&lt;br /&gt;
| 0&lt;br /&gt;
| Executable Content ([[NCCH#CXI|CXI]])&lt;br /&gt;
|-&lt;br /&gt;
| 1&lt;br /&gt;
| E-Manual ([[NCCH#CFA|CFA]])&lt;br /&gt;
|-&lt;br /&gt;
| 2&lt;br /&gt;
| [[Download Play]] Child container ([[NCCH#CFA|CFA]])&lt;br /&gt;
|-&lt;br /&gt;
| 6&lt;br /&gt;
| New3DS [[System_Update_CFA|Update Data]] ([[NCCH#CFA|CFA]])&lt;br /&gt;
|-&lt;br /&gt;
| 7&lt;br /&gt;
| [[System_Update_CFA|Update Data]] ([[NCCH#CFA|CFA]])&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The format of partitions can be determined from the partition FS flags (normally these are zero for CCI/CSU NCSD Images).&lt;br /&gt;
&lt;br /&gt;
== NCSD header ==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
!  Offset&lt;br /&gt;
!  Size&lt;br /&gt;
!  Description&lt;br /&gt;
|-&lt;br /&gt;
|  0x000&lt;br /&gt;
|  0x100&lt;br /&gt;
|  RSA-2048 SHA-256 signature of the NCSD header&lt;br /&gt;
|-&lt;br /&gt;
|  0x100&lt;br /&gt;
|  4&lt;br /&gt;
|  Magic Number &#039;NCSD&#039;&lt;br /&gt;
|-&lt;br /&gt;
|  0x104&lt;br /&gt;
|  4&lt;br /&gt;
|  Size of the NCSD image, in media units (1 media unit = 0x200 bytes)&lt;br /&gt;
|-&lt;br /&gt;
|  0x108&lt;br /&gt;
|  8&lt;br /&gt;
|  Media ID&lt;br /&gt;
|-&lt;br /&gt;
|  0x110&lt;br /&gt;
|  8&lt;br /&gt;
|  Partitions FS type (0=None, 1=Normal, 3=FIRM, 4=AGB_FIRM save)&lt;br /&gt;
|-&lt;br /&gt;
|  0x118&lt;br /&gt;
|  8&lt;br /&gt;
|  Partitions crypt type (each byte corresponds to a partition in the partition table)&lt;br /&gt;
|-&lt;br /&gt;
|  0x120&lt;br /&gt;
|  0x40=(4+4)*8&lt;br /&gt;
|  Offset &amp;amp; Length partition table, in media units&lt;br /&gt;
|-&lt;br /&gt;
|  0x160&lt;br /&gt;
|  0xA0&lt;br /&gt;
|  ...&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
For carts,&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
!  Offset&lt;br /&gt;
!  Size&lt;br /&gt;
!  Description&lt;br /&gt;
|-&lt;br /&gt;
|  0x160&lt;br /&gt;
|  0x20&lt;br /&gt;
|  Exheader SHA-256 hash&lt;br /&gt;
|-&lt;br /&gt;
|  0x180&lt;br /&gt;
|  0x4&lt;br /&gt;
|  Additional header size&lt;br /&gt;
|-&lt;br /&gt;
|  0x184&lt;br /&gt;
|  0x4&lt;br /&gt;
|  Sector zero offset&lt;br /&gt;
|-&lt;br /&gt;
|  0x188&lt;br /&gt;
|  8&lt;br /&gt;
|  Partition Flags (See Below)&lt;br /&gt;
|-&lt;br /&gt;
|  0x190&lt;br /&gt;
|  0x40=8*8&lt;br /&gt;
|  Partition ID table &lt;br /&gt;
|-&lt;br /&gt;
|  0x1D0&lt;br /&gt;
|  0x20&lt;br /&gt;
|  Reserved&lt;br /&gt;
|-&lt;br /&gt;
| 0x1F0&lt;br /&gt;
| 0xE&lt;br /&gt;
| Reserved?&lt;br /&gt;
|-&lt;br /&gt;
| 0x1FE&lt;br /&gt;
| 0x1&lt;br /&gt;
| Support for this was implemented with [[9.6.0-24|9.6.0-X]] FIRM. Bit0=1 enables using bits 1-2, it&#039;s unknown what these two bits are actually used for(the value of these two bits get compared with some other value during NCSD verification/loading). This appears to enable a new, likely hardware-based, antipiracy check on cartridges.&lt;br /&gt;
|-&lt;br /&gt;
| 0x1FF&lt;br /&gt;
| 0x1&lt;br /&gt;
| Support for this was implemented with [[9.6.0-24|9.6.0-X]] FIRM, see below regarding save crypto.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
For NAND,&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
!  Offset&lt;br /&gt;
!  Size&lt;br /&gt;
!  Description&lt;br /&gt;
|-&lt;br /&gt;
|  0x160&lt;br /&gt;
|  0x5E&lt;br /&gt;
|  Unknown&lt;br /&gt;
|-&lt;br /&gt;
|  0x1BE&lt;br /&gt;
|  0x42&lt;br /&gt;
|  Encrypted MBR partition-table, for the TWL partitions(key-data used for this keyslot is console-unique).&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== NCSD Signature ===&lt;br /&gt;
The RSA public key used for gamecard NCSD is stored in [[Memory_layout|ITCM]]. The separate public key used for NAND NCSD is stored in Process9 .(ro)data instead of ITCM, and in [[Bootloader|boot ROM]].&lt;br /&gt;
&lt;br /&gt;
For the boot ROM check, sighax may be used to fake-sign NAND headers.  Process9&#039;s check will fail, however, unless patched.&lt;br /&gt;
&lt;br /&gt;
=== Partition Flags ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
!  Byte Index&lt;br /&gt;
!  Description&lt;br /&gt;
|-&lt;br /&gt;
| 0&lt;br /&gt;
| Backup Write Wait Time (The time to wait to write save to backup after the card is recognized (0-255 seconds)).NATIVE_FIRM loads this flag from the gamecard NCSD header starting with [[6.0.0-11]].&lt;br /&gt;
|-&lt;br /&gt;
| 3&lt;br /&gt;
| Media Card Device (1 = NOR Flash, 2 = None, 3 = BT) (SDK 3.X+)&lt;br /&gt;
|-&lt;br /&gt;
| 4&lt;br /&gt;
| Media Platform Index (1 = CTR)&lt;br /&gt;
|-&lt;br /&gt;
| 5&lt;br /&gt;
| Media Type Index (0 = Inner Device, 1 = Card1, 2 = Card2, 3 = Extended Device)&lt;br /&gt;
|-&lt;br /&gt;
| 6&lt;br /&gt;
| Media Unit Size i.e. u32 MediaUnitSize = 0x200*2^flags[6];&lt;br /&gt;
|-&lt;br /&gt;
| 7&lt;br /&gt;
| Media Card Device (1 = NOR Flash, 2 = None, 3 = BT) (Only SDK 2.X)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Partition Flags (In Terms of Save Crypto Determination) ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
!  Byte Index&lt;br /&gt;
!  Description&lt;br /&gt;
|-&lt;br /&gt;
| 1&lt;br /&gt;
| Starting with [[6.0.0-11]] NATIVE_FIRM will use this flag to determine the gamecard [[Savegames|savegame]] keyY method, when flag[3] is set. 0 = [[2.0.0-2]] hashed keyY, 1 = [[Savegames|new]] keyY method implemented with [[6.0.0-11]]. 0x0A = implemented with [[9.3.0-21|9.3.0-X]]. On Old3DS this is identical to the [[2.2.0-4]] crypto. On New3DS this is identical to the [[2.2.0-4]] crypto, except with New3DS-only gamecard savedata [[AES|keyslots]].&lt;br /&gt;
Starting with [[9.6.0-24|9.6.0-X]] FIRM, Process9 now sets &amp;lt;savecrypto_stateval&amp;gt; to partitionflag[1] + &amp;lt;the u8 value from NCSD+0x1FF&amp;gt;, instead of just setting it to partitionflag[1].&lt;br /&gt;
|-&lt;br /&gt;
| 3&lt;br /&gt;
| Support for this flag was implemented in NATIVE_FIRM with [[2.0.0-2]]. When this flag is set the hashed gamecard [[Savegames|savegame]] keyY method is used, this likely still uses the repeating-CTR however. With [[6.0.0-11]] the system will determine the gamecard savegame keyY method via flag[1], instead of just using the hashed keyY via this flag.&lt;br /&gt;
|-th&lt;br /&gt;
| 7&lt;br /&gt;
| This flag enables using the hashed gamecard [[Savegames|savegame]] keyY method, support for this flag was implemented in NATIVE_FIRM with [[2.2.0-4]]. All games with the NCSD image finalized since [[2.2.0-4]](and contains [[2.2.0-4]]+ in the system update partition) have this flag set, this flag also enables using new CTR method as well.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Starting with [[9.6.0-24|9.6.0-X]] FIRM, Process9 will just write val0 to a state field then return 0, instead of returning an error when the save crypto type isn&#039;t recognized. This was the *only* actual functionality change in the Old3DS Process9 function for gamecard savedata crypto init.&lt;br /&gt;
&lt;br /&gt;
== Card Info Header ==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
!  OFFSET&lt;br /&gt;
!  SIZE&lt;br /&gt;
!  DESCRIPTION&lt;br /&gt;
|-&lt;br /&gt;
|  0x200&lt;br /&gt;
|  4&lt;br /&gt;
|  CARD2: Writable Address In Media Units (For &#039;On-Chip&#039; Savedata). CARD1: Always 0xFFFFFFFF.&lt;br /&gt;
|-&lt;br /&gt;
|  0x204&lt;br /&gt;
|  4&lt;br /&gt;
|  Card Info Bitmask&lt;br /&gt;
|-&lt;br /&gt;
|  0x208&lt;br /&gt;
|  0xF8&lt;br /&gt;
|  Reserved&lt;br /&gt;
|-&lt;br /&gt;
|  0x300&lt;br /&gt;
|  4&lt;br /&gt;
|  Filled size of cartridge&lt;br /&gt;
|-&lt;br /&gt;
|  0x304&lt;br /&gt;
|  0xC&lt;br /&gt;
|  Reserved&lt;br /&gt;
|-&lt;br /&gt;
|  0x310&lt;br /&gt;
|  2&lt;br /&gt;
|  Title version&lt;br /&gt;
|-&lt;br /&gt;
|  0x312&lt;br /&gt;
|  2&lt;br /&gt;
|  Card revision&lt;br /&gt;
|-&lt;br /&gt;
|  0x314&lt;br /&gt;
|  0xC&lt;br /&gt;
|  Reserved&lt;br /&gt;
|-&lt;br /&gt;
|  0x320&lt;br /&gt;
|  8&lt;br /&gt;
|  Title ID of [[CVer]] in included update partition&lt;br /&gt;
|-&lt;br /&gt;
|  0x328&lt;br /&gt;
|  2&lt;br /&gt;
|  Version number of [[CVer]] in included update partition&lt;br /&gt;
|-&lt;br /&gt;
|  0x32A&lt;br /&gt;
|  0xCD6&lt;br /&gt;
|  Reserved&lt;br /&gt;
|-&lt;br /&gt;
|  0x1000&lt;br /&gt;
|  0x200&lt;br /&gt;
|  InitialData&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== InitialData ===&lt;br /&gt;
&lt;br /&gt;
This data is returned by [[Gamecards|16-byte cartridge command]] 0x82.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
!  OFFSET&lt;br /&gt;
!  SIZE&lt;br /&gt;
!  DESCRIPTION&lt;br /&gt;
|-&lt;br /&gt;
|  0x00&lt;br /&gt;
|  0x08&lt;br /&gt;
|  Title ID (little-endian)&lt;br /&gt;
|-&lt;br /&gt;
|  0x08&lt;br /&gt;
|  0x08&lt;br /&gt;
|  Reserved (normally all-zero)&lt;br /&gt;
|-&lt;br /&gt;
|  0x10&lt;br /&gt;
|  0x10&lt;br /&gt;
|  Seed (keyY used to decrypt the title key - keyX is keyslot 0x3B for production cards, or a key of all zeroes for development cards)&lt;br /&gt;
|-&lt;br /&gt;
|  0x20&lt;br /&gt;
|  0x10&lt;br /&gt;
|  TitleKey (AES-CCM encrypted)&lt;br /&gt;
|-&lt;br /&gt;
|  0x30&lt;br /&gt;
|  0x10&lt;br /&gt;
|  AES-CCM MAC&lt;br /&gt;
|-&lt;br /&gt;
|  0x40&lt;br /&gt;
|  0xC&lt;br /&gt;
|  AES-CCM nonce&lt;br /&gt;
|-&lt;br /&gt;
|  0x3C&lt;br /&gt;
|  0xC4&lt;br /&gt;
|  Reserved (normally all-zero)&lt;br /&gt;
|-&lt;br /&gt;
|  0x100&lt;br /&gt;
|  0x100&lt;br /&gt;
|  NcchHeader (copy of the first NCCH header, excluding the RSA signature)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Development Card Info Header Extension ==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
!  OFFSET&lt;br /&gt;
!  SIZE&lt;br /&gt;
!  DESCRIPTION&lt;br /&gt;
|-&lt;br /&gt;
|  0x1200&lt;br /&gt;
|  0x200&lt;br /&gt;
|  CardDeviceReserved1&lt;br /&gt;
|-&lt;br /&gt;
|  0x1400&lt;br /&gt;
|  0x10&lt;br /&gt;
|  TitleKeyData&lt;br /&gt;
|-&lt;br /&gt;
|  0x1410&lt;br /&gt;
|  0x1BF0&lt;br /&gt;
|  CardDeviceReserved2&lt;br /&gt;
|-&lt;br /&gt;
|  0x3000&lt;br /&gt;
|  0x1000&lt;br /&gt;
|  TestData&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
TitleKeyData contains the decrypted version of the title key found in the InitialData. This field appears to be what development--and maybe production?--cards read to know what card encryption seed to use in the CTR protocol.&lt;br /&gt;
&lt;br /&gt;
The CardDeviceReserved areas have random-looking data whose purpose is unknown, other than perhaps to hide the TitleKey.&lt;br /&gt;
&lt;br /&gt;
Note that a particular flashcard vendor, namely Gateway, puts what many refer to as &amp;quot;private headers&amp;quot; at CardDeviceReserved1 in place of actual development card information. This header consists of:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
!  OFFSET&lt;br /&gt;
!  SIZE&lt;br /&gt;
!  DESCRIPTION&lt;br /&gt;
|-&lt;br /&gt;
|  0x0&lt;br /&gt;
|  0x40&lt;br /&gt;
|  Unique cartridge ID; only the first 0x10 bytes are meaningful, the rest are 0xff; obtainable using encrypted [[Gamecards|16-byte cartridge command]] 0xc6; the first 0x10 bytes can also be obtained in userland via [[Process_Services_PXI|pxi:ps9::GetRomId]]&lt;br /&gt;
|-&lt;br /&gt;
|  0x40&lt;br /&gt;
|  0x4&lt;br /&gt;
|  Cartridge ID1; obtainable using 8-byte cartridge command 0x90 or 16-byte cartridge command 0xa2&lt;br /&gt;
|-&lt;br /&gt;
|  0x44&lt;br /&gt;
|  0x4&lt;br /&gt;
|  Cartridge ID2; obtainable using 8-byte cartridge command 0xa0 or 16-byte cartridge command 0xa4&lt;br /&gt;
|-&lt;br /&gt;
|  0x48&lt;br /&gt;
|  0x8&lt;br /&gt;
|  Padding (all-0xff)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The legitimacy of the unique cartridge ID can be validated by online services.&lt;br /&gt;
&lt;br /&gt;
Some dumping tools, notably GodMode9 as of 2024-05-26, erroneously always write 0x00000000 into the position of the Cartridge ID2. This is presumably because the cartridge ID2 is always zero for retail carts.&lt;br /&gt;
&lt;br /&gt;
=== TestData ===&lt;br /&gt;
The test data is the same one encountered in development DS/DSi cartridges. Its layout is as follows:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
!  OFFSET&lt;br /&gt;
!  SIZE&lt;br /&gt;
!  DESCRIPTION&lt;br /&gt;
|-&lt;br /&gt;
|  0x0&lt;br /&gt;
|  0x8&lt;br /&gt;
|  The bytes FF 00 FF 00 AA 55 AA 55.&lt;br /&gt;
|-&lt;br /&gt;
|  0x8&lt;br /&gt;
|  0x1F8&lt;br /&gt;
|  An ascending byte sequence equal to the offset mod 256 (08 09 0A ... FE FF 00 01 ... FF).&lt;br /&gt;
|-&lt;br /&gt;
|  0x200&lt;br /&gt;
|  0x200&lt;br /&gt;
|  A descending byte sequence equal to 255 minus the offset mod 256 (FF FE FD ... 00 FF DE ... 00).&lt;br /&gt;
|-&lt;br /&gt;
|  0x400&lt;br /&gt;
|  0x200&lt;br /&gt;
|  Filled with 00 (0b00000000) bytes.&lt;br /&gt;
|-&lt;br /&gt;
|  0x600&lt;br /&gt;
|  0x200&lt;br /&gt;
|  Filled with FF (0b11111111) bytes.&lt;br /&gt;
|-&lt;br /&gt;
|  0x800&lt;br /&gt;
|  0x200&lt;br /&gt;
|  Filled with 0F (0b00001111) bytes.&lt;br /&gt;
|-&lt;br /&gt;
|  0xA00&lt;br /&gt;
|  0x200&lt;br /&gt;
|  Filled with F0 (0b11110000) bytes.&lt;br /&gt;
|-&lt;br /&gt;
|  0xC00&lt;br /&gt;
|  0x200&lt;br /&gt;
|  Filled with 55 (0b01010101) bytes.&lt;br /&gt;
|-&lt;br /&gt;
|  0xE00&lt;br /&gt;
|  0x1FF&lt;br /&gt;
|  Filled with AA (0b10101010) bytes.&lt;br /&gt;
|-&lt;br /&gt;
|  0xFFF&lt;br /&gt;
|  0x1&lt;br /&gt;
|  The final byte is 00 (0b00000000).&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Production cards always return FF when attempting to read 0x1200-0x3FFF. They probably actually have the same data as development cards, but there&#039;s no way to read it.&lt;br /&gt;
&lt;br /&gt;
== Tools ==&lt;br /&gt;
&lt;br /&gt;
[https://github.com/3dshax/ctr/tree/master/ctrtool ctrtool] - (CMD)(Windows/Linux) Parsing NCSD files&lt;br /&gt;
&lt;br /&gt;
[[3DSExplorer]] - (GUI)(Windows Only) Parsing NCSD files&lt;/div&gt;</summary>
		<author><name>AriA99</name></author>
	</entry>
	<entry>
		<id>https://www.3dbrew.org/w/index.php?title=PSPXI:GenerateRandomBytes&amp;diff=22563</id>
		<title>PSPXI:GenerateRandomBytes</title>
		<link rel="alternate" type="text/html" href="https://www.3dbrew.org/w/index.php?title=PSPXI:GenerateRandomBytes&amp;diff=22563"/>
		<updated>2024-05-26T06:01:15Z</updated>

		<summary type="html">&lt;p&gt;AriA99: Add a short description how this thing works, the whole thing is too ugly to restate&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Request=&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
!  Index Word&lt;br /&gt;
!  Description&lt;br /&gt;
|-&lt;br /&gt;
| 0&lt;br /&gt;
| Header code [0x000D0042]&lt;br /&gt;
|-&lt;br /&gt;
| 1&lt;br /&gt;
| Output buffer size&lt;br /&gt;
|-&lt;br /&gt;
| 2&lt;br /&gt;
| (Size&amp;lt;&amp;lt;8) &amp;lt;nowiki&amp;gt;|&amp;lt;/nowiki&amp;gt; 0x4&lt;br /&gt;
|-&lt;br /&gt;
| 3&lt;br /&gt;
| Output buffer pointer&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=Response=&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
!  Index Word&lt;br /&gt;
!  Description&lt;br /&gt;
|-&lt;br /&gt;
| 0&lt;br /&gt;
| Header code&lt;br /&gt;
|-&lt;br /&gt;
| 1&lt;br /&gt;
| Result code&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=Description=&lt;br /&gt;
&lt;br /&gt;
Generates random bytes using the FIPS 186-2 (change notice 1) appendix 3 generator using SHA-1.&lt;/div&gt;</summary>
		<author><name>AriA99</name></author>
	</entry>
	<entry>
		<id>https://www.3dbrew.org/w/index.php?title=NCSD&amp;diff=22562</id>
		<title>NCSD</title>
		<link rel="alternate" type="text/html" href="https://www.3dbrew.org/w/index.php?title=NCSD&amp;diff=22562"/>
		<updated>2024-05-26T05:35:15Z</updated>

		<summary type="html">&lt;p&gt;AriA99: /* Development Card Info Header Extension */ ID1 is unobtainable from userland&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:File formats]]&lt;br /&gt;
This page documents the format of NCSD.&lt;br /&gt;
&lt;br /&gt;
== Overview ==&lt;br /&gt;
There are two known specialisations of the NCSD container format. The CTR Cart Image (CCI) format and the 3DS&#039; raw [[Flash Filesystem#NAND structure|NAND format]]. CCI is the format of game ROM images.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;CTR System Update (CSU)&#039;&#039;&#039; is a variant of CCI, where the only difference is in the file extension. This is used with developer System Updates and associated [[3DS Development Unit Software|Tools]].&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
NCSD images start with a NCSD header, followed by up to a maximum of 8 [[NCCH]] partitions.&lt;br /&gt;
&lt;br /&gt;
For CCI images, the partitions are reserved as follows:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
!  [[NCCH]] Index&lt;br /&gt;
!  Reserved Use&lt;br /&gt;
|-&lt;br /&gt;
| 0&lt;br /&gt;
| Executable Content ([[NCCH#CXI|CXI]])&lt;br /&gt;
|-&lt;br /&gt;
| 1&lt;br /&gt;
| E-Manual ([[NCCH#CFA|CFA]])&lt;br /&gt;
|-&lt;br /&gt;
| 2&lt;br /&gt;
| [[Download Play]] Child container ([[NCCH#CFA|CFA]])&lt;br /&gt;
|-&lt;br /&gt;
| 6&lt;br /&gt;
| New3DS [[System_Update_CFA|Update Data]] ([[NCCH#CFA|CFA]])&lt;br /&gt;
|-&lt;br /&gt;
| 7&lt;br /&gt;
| [[System_Update_CFA|Update Data]] ([[NCCH#CFA|CFA]])&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The format of partitions can be determined from the partition FS flags (normally these are zero for CCI/CSU NCSD Images).&lt;br /&gt;
&lt;br /&gt;
== NCSD header ==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
!  Offset&lt;br /&gt;
!  Size&lt;br /&gt;
!  Description&lt;br /&gt;
|-&lt;br /&gt;
|  0x000&lt;br /&gt;
|  0x100&lt;br /&gt;
|  RSA-2048 SHA-256 signature of the NCSD header&lt;br /&gt;
|-&lt;br /&gt;
|  0x100&lt;br /&gt;
|  4&lt;br /&gt;
|  Magic Number &#039;NCSD&#039;&lt;br /&gt;
|-&lt;br /&gt;
|  0x104&lt;br /&gt;
|  4&lt;br /&gt;
|  Size of the NCSD image, in media units (1 media unit = 0x200 bytes)&lt;br /&gt;
|-&lt;br /&gt;
|  0x108&lt;br /&gt;
|  8&lt;br /&gt;
|  Media ID&lt;br /&gt;
|-&lt;br /&gt;
|  0x110&lt;br /&gt;
|  8&lt;br /&gt;
|  Partitions FS type (0=None, 1=Normal, 3=FIRM, 4=AGB_FIRM save)&lt;br /&gt;
|-&lt;br /&gt;
|  0x118&lt;br /&gt;
|  8&lt;br /&gt;
|  Partitions crypt type (each byte corresponds to a partition in the partition table)&lt;br /&gt;
|-&lt;br /&gt;
|  0x120&lt;br /&gt;
|  0x40=(4+4)*8&lt;br /&gt;
|  Offset &amp;amp; Length partition table, in media units&lt;br /&gt;
|-&lt;br /&gt;
|  0x160&lt;br /&gt;
|  0xA0&lt;br /&gt;
|  ...&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
For carts,&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
!  Offset&lt;br /&gt;
!  Size&lt;br /&gt;
!  Description&lt;br /&gt;
|-&lt;br /&gt;
|  0x160&lt;br /&gt;
|  0x20&lt;br /&gt;
|  Exheader SHA-256 hash&lt;br /&gt;
|-&lt;br /&gt;
|  0x180&lt;br /&gt;
|  0x4&lt;br /&gt;
|  Additional header size&lt;br /&gt;
|-&lt;br /&gt;
|  0x184&lt;br /&gt;
|  0x4&lt;br /&gt;
|  Sector zero offset&lt;br /&gt;
|-&lt;br /&gt;
|  0x188&lt;br /&gt;
|  8&lt;br /&gt;
|  Partition Flags (See Below)&lt;br /&gt;
|-&lt;br /&gt;
|  0x190&lt;br /&gt;
|  0x40=8*8&lt;br /&gt;
|  Partition ID table &lt;br /&gt;
|-&lt;br /&gt;
|  0x1D0&lt;br /&gt;
|  0x20&lt;br /&gt;
|  Reserved&lt;br /&gt;
|-&lt;br /&gt;
| 0x1F0&lt;br /&gt;
| 0xE&lt;br /&gt;
| Reserved?&lt;br /&gt;
|-&lt;br /&gt;
| 0x1FE&lt;br /&gt;
| 0x1&lt;br /&gt;
| Support for this was implemented with [[9.6.0-24|9.6.0-X]] FIRM. Bit0=1 enables using bits 1-2, it&#039;s unknown what these two bits are actually used for(the value of these two bits get compared with some other value during NCSD verification/loading). This appears to enable a new, likely hardware-based, antipiracy check on cartridges.&lt;br /&gt;
|-&lt;br /&gt;
| 0x1FF&lt;br /&gt;
| 0x1&lt;br /&gt;
| Support for this was implemented with [[9.6.0-24|9.6.0-X]] FIRM, see below regarding save crypto.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
For NAND,&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
!  Offset&lt;br /&gt;
!  Size&lt;br /&gt;
!  Description&lt;br /&gt;
|-&lt;br /&gt;
|  0x160&lt;br /&gt;
|  0x5E&lt;br /&gt;
|  Unknown&lt;br /&gt;
|-&lt;br /&gt;
|  0x1BE&lt;br /&gt;
|  0x42&lt;br /&gt;
|  Encrypted MBR partition-table, for the TWL partitions(key-data used for this keyslot is console-unique).&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== NCSD Signature ===&lt;br /&gt;
The RSA public key used for gamecard NCSD is stored in [[Memory_layout|ITCM]]. The separate public key used for NAND NCSD is stored in Process9 .(ro)data instead of ITCM, and in [[Bootloader|boot ROM]].&lt;br /&gt;
&lt;br /&gt;
For the boot ROM check, sighax may be used to fake-sign NAND headers.  Process9&#039;s check will fail, however, unless patched.&lt;br /&gt;
&lt;br /&gt;
=== Partition Flags ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
!  Byte Index&lt;br /&gt;
!  Description&lt;br /&gt;
|-&lt;br /&gt;
| 0&lt;br /&gt;
| Backup Write Wait Time (The time to wait to write save to backup after the card is recognized (0-255 seconds)).NATIVE_FIRM loads this flag from the gamecard NCSD header starting with [[6.0.0-11]].&lt;br /&gt;
|-&lt;br /&gt;
| 3&lt;br /&gt;
| Media Card Device (1 = NOR Flash, 2 = None, 3 = BT) (SDK 3.X+)&lt;br /&gt;
|-&lt;br /&gt;
| 4&lt;br /&gt;
| Media Platform Index (1 = CTR)&lt;br /&gt;
|-&lt;br /&gt;
| 5&lt;br /&gt;
| Media Type Index (0 = Inner Device, 1 = Card1, 2 = Card2, 3 = Extended Device)&lt;br /&gt;
|-&lt;br /&gt;
| 6&lt;br /&gt;
| Media Unit Size i.e. u32 MediaUnitSize = 0x200*2^flags[6];&lt;br /&gt;
|-&lt;br /&gt;
| 7&lt;br /&gt;
| Media Card Device (1 = NOR Flash, 2 = None, 3 = BT) (Only SDK 2.X)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Partition Flags (In Terms of Save Crypto Determination) ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
!  Byte Index&lt;br /&gt;
!  Description&lt;br /&gt;
|-&lt;br /&gt;
| 1&lt;br /&gt;
| Starting with [[6.0.0-11]] NATIVE_FIRM will use this flag to determine the gamecard [[Savegames|savegame]] keyY method, when flag[3] is set. 0 = [[2.0.0-2]] hashed keyY, 1 = [[Savegames|new]] keyY method implemented with [[6.0.0-11]]. 0x0A = implemented with [[9.3.0-21|9.3.0-X]]. On Old3DS this is identical to the [[2.2.0-4]] crypto. On New3DS this is identical to the [[2.2.0-4]] crypto, except with New3DS-only gamecard savedata [[AES|keyslots]].&lt;br /&gt;
Starting with [[9.6.0-24|9.6.0-X]] FIRM, Process9 now sets &amp;lt;savecrypto_stateval&amp;gt; to partitionflag[1] + &amp;lt;the u8 value from NCSD+0x1FF&amp;gt;, instead of just setting it to partitionflag[1].&lt;br /&gt;
|-&lt;br /&gt;
| 3&lt;br /&gt;
| Support for this flag was implemented in NATIVE_FIRM with [[2.0.0-2]]. When this flag is set the hashed gamecard [[Savegames|savegame]] keyY method is used, this likely still uses the repeating-CTR however. With [[6.0.0-11]] the system will determine the gamecard savegame keyY method via flag[1], instead of just using the hashed keyY via this flag.&lt;br /&gt;
|-th&lt;br /&gt;
| 7&lt;br /&gt;
| This flag enables using the hashed gamecard [[Savegames|savegame]] keyY method, support for this flag was implemented in NATIVE_FIRM with [[2.2.0-4]]. All games with the NCSD image finalized since [[2.2.0-4]](and contains [[2.2.0-4]]+ in the system update partition) have this flag set, this flag also enables using new CTR method as well.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Starting with [[9.6.0-24|9.6.0-X]] FIRM, Process9 will just write val0 to a state field then return 0, instead of returning an error when the save crypto type isn&#039;t recognized. This was the *only* actual functionality change in the Old3DS Process9 function for gamecard savedata crypto init.&lt;br /&gt;
&lt;br /&gt;
== Card Info Header ==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
!  OFFSET&lt;br /&gt;
!  SIZE&lt;br /&gt;
!  DESCRIPTION&lt;br /&gt;
|-&lt;br /&gt;
|  0x200&lt;br /&gt;
|  4&lt;br /&gt;
|  CARD2: Writable Address In Media Units (For &#039;On-Chip&#039; Savedata). CARD1: Always 0xFFFFFFFF.&lt;br /&gt;
|-&lt;br /&gt;
|  0x204&lt;br /&gt;
|  4&lt;br /&gt;
|  Card Info Bitmask&lt;br /&gt;
|-&lt;br /&gt;
|  0x208&lt;br /&gt;
|  0xF8&lt;br /&gt;
|  Reserved&lt;br /&gt;
|-&lt;br /&gt;
|  0x300&lt;br /&gt;
|  4&lt;br /&gt;
|  Filled size of cartridge&lt;br /&gt;
|-&lt;br /&gt;
|  0x304&lt;br /&gt;
|  0xC&lt;br /&gt;
|  Reserved&lt;br /&gt;
|-&lt;br /&gt;
|  0x310&lt;br /&gt;
|  2&lt;br /&gt;
|  Title version&lt;br /&gt;
|-&lt;br /&gt;
|  0x312&lt;br /&gt;
|  2&lt;br /&gt;
|  Card revision&lt;br /&gt;
|-&lt;br /&gt;
|  0x314&lt;br /&gt;
|  0xC&lt;br /&gt;
|  Reserved&lt;br /&gt;
|-&lt;br /&gt;
|  0x320&lt;br /&gt;
|  8&lt;br /&gt;
|  Title ID of [[CVer]] in included update partition&lt;br /&gt;
|-&lt;br /&gt;
|  0x328&lt;br /&gt;
|  2&lt;br /&gt;
|  Version number of [[CVer]] in included update partition&lt;br /&gt;
|-&lt;br /&gt;
|  0x32A&lt;br /&gt;
|  0xCD6&lt;br /&gt;
|  Reserved&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Development Card Info Header Extension ==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
!  OFFSET&lt;br /&gt;
!  SIZE&lt;br /&gt;
!  DESCRIPTION&lt;br /&gt;
|-&lt;br /&gt;
|  0x1000&lt;br /&gt;
|  0x200&lt;br /&gt;
|  InitialData&lt;br /&gt;
|-&lt;br /&gt;
|  0x1200&lt;br /&gt;
|  0x200&lt;br /&gt;
|  CardDeviceReserved1&lt;br /&gt;
|-&lt;br /&gt;
|  0x1400&lt;br /&gt;
|  0x10&lt;br /&gt;
|  TitleKeyData&lt;br /&gt;
|-&lt;br /&gt;
|  0x1410&lt;br /&gt;
|  0x1BF0&lt;br /&gt;
|  CardDeviceReserved2&lt;br /&gt;
|-&lt;br /&gt;
|  0x3000&lt;br /&gt;
|  0x1000&lt;br /&gt;
|  TestData&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
TitleKeyData contains the decrypted version of the title key found in the InitialData. This field appears to be what development--and maybe production?--cards read to know what card encryption seed to use in the CTR protocol.&lt;br /&gt;
&lt;br /&gt;
The CardDeviceReserved areas have random-looking data whose purpose is unknown, other than perhaps to hide the TitleKey.&lt;br /&gt;
&lt;br /&gt;
Note that a particular flashcard vendor, namely Gateway, puts what many refer to as &amp;quot;private headers&amp;quot; at CardDeviceReserved1 in place of actual development card information. This header consists of:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
!  OFFSET&lt;br /&gt;
!  SIZE&lt;br /&gt;
!  DESCRIPTION&lt;br /&gt;
|-&lt;br /&gt;
|  0x0&lt;br /&gt;
|  0x40&lt;br /&gt;
|  Unique cartridge ID; only the first 0x10 bytes are meaningful, the rest are 0xff; obtainable using encrypted [[Gamecards|16-byte cartridge command]] 0xc6; the first 0x10 bytes can also be obtained in userland via [[Process_Services_PXI|pxi:ps9::GetRomId]]&lt;br /&gt;
|-&lt;br /&gt;
|  0x40&lt;br /&gt;
|  0x4&lt;br /&gt;
|  Cartridge ID1; obtainable using 8-byte cartridge command 0x90 or 16-byte cartridge command 0xa2&lt;br /&gt;
|-&lt;br /&gt;
|  0x44&lt;br /&gt;
|  0x4&lt;br /&gt;
|  Cartridge ID2; obtainable using 8-byte cartridge command 0xa0 or 16-byte cartridge command 0xa4&lt;br /&gt;
|-&lt;br /&gt;
|  0x48&lt;br /&gt;
|  0x8&lt;br /&gt;
|  Padding (all-0xff)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The legitimacy of the unique cartridge ID can be validated by online services.&lt;br /&gt;
&lt;br /&gt;
Some dumping tools, notably GodMode9 as of 2024-05-26, erroneously always write 0x00000000 into the position of the Cartridge ID2. This is presumably because the cartridge ID2 is always zero for retail carts.&lt;br /&gt;
&lt;br /&gt;
=== InitialData ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
!  OFFSET&lt;br /&gt;
!  SIZE&lt;br /&gt;
!  DESCRIPTION&lt;br /&gt;
|-&lt;br /&gt;
|  0x0&lt;br /&gt;
|  0x10&lt;br /&gt;
|  Seed (keyY used to decrypt the title key - keyX is keyslot 0x3B for production cards, or a key of all zeroes for development cards)&lt;br /&gt;
|-&lt;br /&gt;
|  0x10&lt;br /&gt;
|  0x10&lt;br /&gt;
|  TitleKey (AES-CCM encrypted)&lt;br /&gt;
|-&lt;br /&gt;
|  0x20&lt;br /&gt;
|  0x10&lt;br /&gt;
|  Mac&lt;br /&gt;
|-&lt;br /&gt;
|  0x30&lt;br /&gt;
|  0xC&lt;br /&gt;
|  Nonce&lt;br /&gt;
|-&lt;br /&gt;
|  0x3C&lt;br /&gt;
|  0xC4&lt;br /&gt;
|  Reserved&lt;br /&gt;
|-&lt;br /&gt;
|  0x100&lt;br /&gt;
|  0x100&lt;br /&gt;
|  NcchHeader (copy of the first NCCH header, excluding the RSA signature)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== TestData ===&lt;br /&gt;
The test data is the same one encountered in development DS/DSi cartridges. Its layout is as follows:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
!  OFFSET&lt;br /&gt;
!  SIZE&lt;br /&gt;
!  DESCRIPTION&lt;br /&gt;
|-&lt;br /&gt;
|  0x0&lt;br /&gt;
|  0x8&lt;br /&gt;
|  The bytes FF 00 FF 00 AA 55 AA 55.&lt;br /&gt;
|-&lt;br /&gt;
|  0x8&lt;br /&gt;
|  0x1F8&lt;br /&gt;
|  An ascending byte sequence equal to the offset mod 256 (08 09 0A ... FE FF 00 01 ... FF).&lt;br /&gt;
|-&lt;br /&gt;
|  0x200&lt;br /&gt;
|  0x200&lt;br /&gt;
|  A descending byte sequence equal to 255 minus the offset mod 256 (FF FE FD ... 00 FF DE ... 00).&lt;br /&gt;
|-&lt;br /&gt;
|  0x400&lt;br /&gt;
|  0x200&lt;br /&gt;
|  Filled with 00 (0b00000000) bytes.&lt;br /&gt;
|-&lt;br /&gt;
|  0x600&lt;br /&gt;
|  0x200&lt;br /&gt;
|  Filled with FF (0b11111111) bytes.&lt;br /&gt;
|-&lt;br /&gt;
|  0x800&lt;br /&gt;
|  0x200&lt;br /&gt;
|  Filled with 0F (0b00001111) bytes.&lt;br /&gt;
|-&lt;br /&gt;
|  0xA00&lt;br /&gt;
|  0x200&lt;br /&gt;
|  Filled with F0 (0b11110000) bytes.&lt;br /&gt;
|-&lt;br /&gt;
|  0xC00&lt;br /&gt;
|  0x200&lt;br /&gt;
|  Filled with 55 (0b01010101) bytes.&lt;br /&gt;
|-&lt;br /&gt;
|  0xE00&lt;br /&gt;
|  0x1FF&lt;br /&gt;
|  Filled with AA (0b10101010) bytes.&lt;br /&gt;
|-&lt;br /&gt;
|  0xFFF&lt;br /&gt;
|  0x1&lt;br /&gt;
|  The final byte is 00 (0b00000000).&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Production cards always return FF when attempting to read 0x1200-0x3FFF. They probably actually have the same data as development cards, but there&#039;s no way to read it.&lt;br /&gt;
&lt;br /&gt;
== Tools ==&lt;br /&gt;
&lt;br /&gt;
[https://github.com/3dshax/ctr/tree/master/ctrtool ctrtool] - (CMD)(Windows/Linux) Parsing NCSD files&lt;br /&gt;
&lt;br /&gt;
[[3DSExplorer]] - (GUI)(Windows Only) Parsing NCSD files&lt;/div&gt;</summary>
		<author><name>AriA99</name></author>
	</entry>
	<entry>
		<id>https://www.3dbrew.org/w/index.php?title=NCSD&amp;diff=22561</id>
		<title>NCSD</title>
		<link rel="alternate" type="text/html" href="https://www.3dbrew.org/w/index.php?title=NCSD&amp;diff=22561"/>
		<updated>2024-05-26T05:34:04Z</updated>

		<summary type="html">&lt;p&gt;AriA99: Properly specify private header&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:File formats]]&lt;br /&gt;
This page documents the format of NCSD.&lt;br /&gt;
&lt;br /&gt;
== Overview ==&lt;br /&gt;
There are two known specialisations of the NCSD container format. The CTR Cart Image (CCI) format and the 3DS&#039; raw [[Flash Filesystem#NAND structure|NAND format]]. CCI is the format of game ROM images.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;CTR System Update (CSU)&#039;&#039;&#039; is a variant of CCI, where the only difference is in the file extension. This is used with developer System Updates and associated [[3DS Development Unit Software|Tools]].&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
NCSD images start with a NCSD header, followed by up to a maximum of 8 [[NCCH]] partitions.&lt;br /&gt;
&lt;br /&gt;
For CCI images, the partitions are reserved as follows:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
!  [[NCCH]] Index&lt;br /&gt;
!  Reserved Use&lt;br /&gt;
|-&lt;br /&gt;
| 0&lt;br /&gt;
| Executable Content ([[NCCH#CXI|CXI]])&lt;br /&gt;
|-&lt;br /&gt;
| 1&lt;br /&gt;
| E-Manual ([[NCCH#CFA|CFA]])&lt;br /&gt;
|-&lt;br /&gt;
| 2&lt;br /&gt;
| [[Download Play]] Child container ([[NCCH#CFA|CFA]])&lt;br /&gt;
|-&lt;br /&gt;
| 6&lt;br /&gt;
| New3DS [[System_Update_CFA|Update Data]] ([[NCCH#CFA|CFA]])&lt;br /&gt;
|-&lt;br /&gt;
| 7&lt;br /&gt;
| [[System_Update_CFA|Update Data]] ([[NCCH#CFA|CFA]])&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The format of partitions can be determined from the partition FS flags (normally these are zero for CCI/CSU NCSD Images).&lt;br /&gt;
&lt;br /&gt;
== NCSD header ==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
!  Offset&lt;br /&gt;
!  Size&lt;br /&gt;
!  Description&lt;br /&gt;
|-&lt;br /&gt;
|  0x000&lt;br /&gt;
|  0x100&lt;br /&gt;
|  RSA-2048 SHA-256 signature of the NCSD header&lt;br /&gt;
|-&lt;br /&gt;
|  0x100&lt;br /&gt;
|  4&lt;br /&gt;
|  Magic Number &#039;NCSD&#039;&lt;br /&gt;
|-&lt;br /&gt;
|  0x104&lt;br /&gt;
|  4&lt;br /&gt;
|  Size of the NCSD image, in media units (1 media unit = 0x200 bytes)&lt;br /&gt;
|-&lt;br /&gt;
|  0x108&lt;br /&gt;
|  8&lt;br /&gt;
|  Media ID&lt;br /&gt;
|-&lt;br /&gt;
|  0x110&lt;br /&gt;
|  8&lt;br /&gt;
|  Partitions FS type (0=None, 1=Normal, 3=FIRM, 4=AGB_FIRM save)&lt;br /&gt;
|-&lt;br /&gt;
|  0x118&lt;br /&gt;
|  8&lt;br /&gt;
|  Partitions crypt type (each byte corresponds to a partition in the partition table)&lt;br /&gt;
|-&lt;br /&gt;
|  0x120&lt;br /&gt;
|  0x40=(4+4)*8&lt;br /&gt;
|  Offset &amp;amp; Length partition table, in media units&lt;br /&gt;
|-&lt;br /&gt;
|  0x160&lt;br /&gt;
|  0xA0&lt;br /&gt;
|  ...&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
For carts,&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
!  Offset&lt;br /&gt;
!  Size&lt;br /&gt;
!  Description&lt;br /&gt;
|-&lt;br /&gt;
|  0x160&lt;br /&gt;
|  0x20&lt;br /&gt;
|  Exheader SHA-256 hash&lt;br /&gt;
|-&lt;br /&gt;
|  0x180&lt;br /&gt;
|  0x4&lt;br /&gt;
|  Additional header size&lt;br /&gt;
|-&lt;br /&gt;
|  0x184&lt;br /&gt;
|  0x4&lt;br /&gt;
|  Sector zero offset&lt;br /&gt;
|-&lt;br /&gt;
|  0x188&lt;br /&gt;
|  8&lt;br /&gt;
|  Partition Flags (See Below)&lt;br /&gt;
|-&lt;br /&gt;
|  0x190&lt;br /&gt;
|  0x40=8*8&lt;br /&gt;
|  Partition ID table &lt;br /&gt;
|-&lt;br /&gt;
|  0x1D0&lt;br /&gt;
|  0x20&lt;br /&gt;
|  Reserved&lt;br /&gt;
|-&lt;br /&gt;
| 0x1F0&lt;br /&gt;
| 0xE&lt;br /&gt;
| Reserved?&lt;br /&gt;
|-&lt;br /&gt;
| 0x1FE&lt;br /&gt;
| 0x1&lt;br /&gt;
| Support for this was implemented with [[9.6.0-24|9.6.0-X]] FIRM. Bit0=1 enables using bits 1-2, it&#039;s unknown what these two bits are actually used for(the value of these two bits get compared with some other value during NCSD verification/loading). This appears to enable a new, likely hardware-based, antipiracy check on cartridges.&lt;br /&gt;
|-&lt;br /&gt;
| 0x1FF&lt;br /&gt;
| 0x1&lt;br /&gt;
| Support for this was implemented with [[9.6.0-24|9.6.0-X]] FIRM, see below regarding save crypto.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
For NAND,&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
!  Offset&lt;br /&gt;
!  Size&lt;br /&gt;
!  Description&lt;br /&gt;
|-&lt;br /&gt;
|  0x160&lt;br /&gt;
|  0x5E&lt;br /&gt;
|  Unknown&lt;br /&gt;
|-&lt;br /&gt;
|  0x1BE&lt;br /&gt;
|  0x42&lt;br /&gt;
|  Encrypted MBR partition-table, for the TWL partitions(key-data used for this keyslot is console-unique).&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== NCSD Signature ===&lt;br /&gt;
The RSA public key used for gamecard NCSD is stored in [[Memory_layout|ITCM]]. The separate public key used for NAND NCSD is stored in Process9 .(ro)data instead of ITCM, and in [[Bootloader|boot ROM]].&lt;br /&gt;
&lt;br /&gt;
For the boot ROM check, sighax may be used to fake-sign NAND headers.  Process9&#039;s check will fail, however, unless patched.&lt;br /&gt;
&lt;br /&gt;
=== Partition Flags ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
!  Byte Index&lt;br /&gt;
!  Description&lt;br /&gt;
|-&lt;br /&gt;
| 0&lt;br /&gt;
| Backup Write Wait Time (The time to wait to write save to backup after the card is recognized (0-255 seconds)).NATIVE_FIRM loads this flag from the gamecard NCSD header starting with [[6.0.0-11]].&lt;br /&gt;
|-&lt;br /&gt;
| 3&lt;br /&gt;
| Media Card Device (1 = NOR Flash, 2 = None, 3 = BT) (SDK 3.X+)&lt;br /&gt;
|-&lt;br /&gt;
| 4&lt;br /&gt;
| Media Platform Index (1 = CTR)&lt;br /&gt;
|-&lt;br /&gt;
| 5&lt;br /&gt;
| Media Type Index (0 = Inner Device, 1 = Card1, 2 = Card2, 3 = Extended Device)&lt;br /&gt;
|-&lt;br /&gt;
| 6&lt;br /&gt;
| Media Unit Size i.e. u32 MediaUnitSize = 0x200*2^flags[6];&lt;br /&gt;
|-&lt;br /&gt;
| 7&lt;br /&gt;
| Media Card Device (1 = NOR Flash, 2 = None, 3 = BT) (Only SDK 2.X)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Partition Flags (In Terms of Save Crypto Determination) ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
!  Byte Index&lt;br /&gt;
!  Description&lt;br /&gt;
|-&lt;br /&gt;
| 1&lt;br /&gt;
| Starting with [[6.0.0-11]] NATIVE_FIRM will use this flag to determine the gamecard [[Savegames|savegame]] keyY method, when flag[3] is set. 0 = [[2.0.0-2]] hashed keyY, 1 = [[Savegames|new]] keyY method implemented with [[6.0.0-11]]. 0x0A = implemented with [[9.3.0-21|9.3.0-X]]. On Old3DS this is identical to the [[2.2.0-4]] crypto. On New3DS this is identical to the [[2.2.0-4]] crypto, except with New3DS-only gamecard savedata [[AES|keyslots]].&lt;br /&gt;
Starting with [[9.6.0-24|9.6.0-X]] FIRM, Process9 now sets &amp;lt;savecrypto_stateval&amp;gt; to partitionflag[1] + &amp;lt;the u8 value from NCSD+0x1FF&amp;gt;, instead of just setting it to partitionflag[1].&lt;br /&gt;
|-&lt;br /&gt;
| 3&lt;br /&gt;
| Support for this flag was implemented in NATIVE_FIRM with [[2.0.0-2]]. When this flag is set the hashed gamecard [[Savegames|savegame]] keyY method is used, this likely still uses the repeating-CTR however. With [[6.0.0-11]] the system will determine the gamecard savegame keyY method via flag[1], instead of just using the hashed keyY via this flag.&lt;br /&gt;
|-th&lt;br /&gt;
| 7&lt;br /&gt;
| This flag enables using the hashed gamecard [[Savegames|savegame]] keyY method, support for this flag was implemented in NATIVE_FIRM with [[2.2.0-4]]. All games with the NCSD image finalized since [[2.2.0-4]](and contains [[2.2.0-4]]+ in the system update partition) have this flag set, this flag also enables using new CTR method as well.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Starting with [[9.6.0-24|9.6.0-X]] FIRM, Process9 will just write val0 to a state field then return 0, instead of returning an error when the save crypto type isn&#039;t recognized. This was the *only* actual functionality change in the Old3DS Process9 function for gamecard savedata crypto init.&lt;br /&gt;
&lt;br /&gt;
== Card Info Header ==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
!  OFFSET&lt;br /&gt;
!  SIZE&lt;br /&gt;
!  DESCRIPTION&lt;br /&gt;
|-&lt;br /&gt;
|  0x200&lt;br /&gt;
|  4&lt;br /&gt;
|  CARD2: Writable Address In Media Units (For &#039;On-Chip&#039; Savedata). CARD1: Always 0xFFFFFFFF.&lt;br /&gt;
|-&lt;br /&gt;
|  0x204&lt;br /&gt;
|  4&lt;br /&gt;
|  Card Info Bitmask&lt;br /&gt;
|-&lt;br /&gt;
|  0x208&lt;br /&gt;
|  0xF8&lt;br /&gt;
|  Reserved&lt;br /&gt;
|-&lt;br /&gt;
|  0x300&lt;br /&gt;
|  4&lt;br /&gt;
|  Filled size of cartridge&lt;br /&gt;
|-&lt;br /&gt;
|  0x304&lt;br /&gt;
|  0xC&lt;br /&gt;
|  Reserved&lt;br /&gt;
|-&lt;br /&gt;
|  0x310&lt;br /&gt;
|  2&lt;br /&gt;
|  Title version&lt;br /&gt;
|-&lt;br /&gt;
|  0x312&lt;br /&gt;
|  2&lt;br /&gt;
|  Card revision&lt;br /&gt;
|-&lt;br /&gt;
|  0x314&lt;br /&gt;
|  0xC&lt;br /&gt;
|  Reserved&lt;br /&gt;
|-&lt;br /&gt;
|  0x320&lt;br /&gt;
|  8&lt;br /&gt;
|  Title ID of [[CVer]] in included update partition&lt;br /&gt;
|-&lt;br /&gt;
|  0x328&lt;br /&gt;
|  2&lt;br /&gt;
|  Version number of [[CVer]] in included update partition&lt;br /&gt;
|-&lt;br /&gt;
|  0x32A&lt;br /&gt;
|  0xCD6&lt;br /&gt;
|  Reserved&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Development Card Info Header Extension ==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
!  OFFSET&lt;br /&gt;
!  SIZE&lt;br /&gt;
!  DESCRIPTION&lt;br /&gt;
|-&lt;br /&gt;
|  0x1000&lt;br /&gt;
|  0x200&lt;br /&gt;
|  InitialData&lt;br /&gt;
|-&lt;br /&gt;
|  0x1200&lt;br /&gt;
|  0x200&lt;br /&gt;
|  CardDeviceReserved1&lt;br /&gt;
|-&lt;br /&gt;
|  0x1400&lt;br /&gt;
|  0x10&lt;br /&gt;
|  TitleKeyData&lt;br /&gt;
|-&lt;br /&gt;
|  0x1410&lt;br /&gt;
|  0x1BF0&lt;br /&gt;
|  CardDeviceReserved2&lt;br /&gt;
|-&lt;br /&gt;
|  0x3000&lt;br /&gt;
|  0x1000&lt;br /&gt;
|  TestData&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
TitleKeyData contains the decrypted version of the title key found in the InitialData. This field appears to be what development--and maybe production?--cards read to know what card encryption seed to use in the CTR protocol.&lt;br /&gt;
&lt;br /&gt;
The CardDeviceReserved areas have random-looking data whose purpose is unknown, other than perhaps to hide the TitleKey.&lt;br /&gt;
&lt;br /&gt;
Note that a particular flashcard vendor, namely Gateway, puts what many refer to as &amp;quot;private headers&amp;quot; at CardDeviceReserved1 in place of actual development card information. This header consists of:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
!  OFFSET&lt;br /&gt;
!  SIZE&lt;br /&gt;
!  DESCRIPTION&lt;br /&gt;
|-&lt;br /&gt;
|  0x0&lt;br /&gt;
|  0x40&lt;br /&gt;
|  Unique cartridge ID; only the first 0x10 bytes are meaningful, the rest are 0xff; obtainable using encrypted [[Gamecards|16-byte cartridge command]] 0xc6; the first 0x10 bytes can also be obtained in userland via [[Process_Services_PXI|pxi:ps9::GetRomId]]&lt;br /&gt;
|-&lt;br /&gt;
|  0x40&lt;br /&gt;
|  0x4&lt;br /&gt;
|  Cartridge ID1; obtainable using 8-byte cartridge command 0x90 or 16-byte cartridge command 0xa2 or in userland via &lt;br /&gt;
|-&lt;br /&gt;
|  0x44&lt;br /&gt;
|  0x4&lt;br /&gt;
|  Cartridge ID2; obtainable using 8-byte cartridge command 0xa0 or 16-byte cartridge command 0xa4&lt;br /&gt;
|-&lt;br /&gt;
|  0x48&lt;br /&gt;
|  0x8&lt;br /&gt;
|  Padding (all-0xff)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The legitimacy of the unique cartridge ID can be validated by online services.&lt;br /&gt;
&lt;br /&gt;
Some dumping tools, notably GodMode9 as of 2024-05-26, erroneously always write 0x00000000 into the position of the Cartridge ID2. This is presumably because the cartridge ID2 is always zero for retail carts.&lt;br /&gt;
&lt;br /&gt;
=== InitialData ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
!  OFFSET&lt;br /&gt;
!  SIZE&lt;br /&gt;
!  DESCRIPTION&lt;br /&gt;
|-&lt;br /&gt;
|  0x0&lt;br /&gt;
|  0x10&lt;br /&gt;
|  Seed (keyY used to decrypt the title key - keyX is keyslot 0x3B for production cards, or a key of all zeroes for development cards)&lt;br /&gt;
|-&lt;br /&gt;
|  0x10&lt;br /&gt;
|  0x10&lt;br /&gt;
|  TitleKey (AES-CCM encrypted)&lt;br /&gt;
|-&lt;br /&gt;
|  0x20&lt;br /&gt;
|  0x10&lt;br /&gt;
|  Mac&lt;br /&gt;
|-&lt;br /&gt;
|  0x30&lt;br /&gt;
|  0xC&lt;br /&gt;
|  Nonce&lt;br /&gt;
|-&lt;br /&gt;
|  0x3C&lt;br /&gt;
|  0xC4&lt;br /&gt;
|  Reserved&lt;br /&gt;
|-&lt;br /&gt;
|  0x100&lt;br /&gt;
|  0x100&lt;br /&gt;
|  NcchHeader (copy of the first NCCH header, excluding the RSA signature)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== TestData ===&lt;br /&gt;
The test data is the same one encountered in development DS/DSi cartridges. Its layout is as follows:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
!  OFFSET&lt;br /&gt;
!  SIZE&lt;br /&gt;
!  DESCRIPTION&lt;br /&gt;
|-&lt;br /&gt;
|  0x0&lt;br /&gt;
|  0x8&lt;br /&gt;
|  The bytes FF 00 FF 00 AA 55 AA 55.&lt;br /&gt;
|-&lt;br /&gt;
|  0x8&lt;br /&gt;
|  0x1F8&lt;br /&gt;
|  An ascending byte sequence equal to the offset mod 256 (08 09 0A ... FE FF 00 01 ... FF).&lt;br /&gt;
|-&lt;br /&gt;
|  0x200&lt;br /&gt;
|  0x200&lt;br /&gt;
|  A descending byte sequence equal to 255 minus the offset mod 256 (FF FE FD ... 00 FF DE ... 00).&lt;br /&gt;
|-&lt;br /&gt;
|  0x400&lt;br /&gt;
|  0x200&lt;br /&gt;
|  Filled with 00 (0b00000000) bytes.&lt;br /&gt;
|-&lt;br /&gt;
|  0x600&lt;br /&gt;
|  0x200&lt;br /&gt;
|  Filled with FF (0b11111111) bytes.&lt;br /&gt;
|-&lt;br /&gt;
|  0x800&lt;br /&gt;
|  0x200&lt;br /&gt;
|  Filled with 0F (0b00001111) bytes.&lt;br /&gt;
|-&lt;br /&gt;
|  0xA00&lt;br /&gt;
|  0x200&lt;br /&gt;
|  Filled with F0 (0b11110000) bytes.&lt;br /&gt;
|-&lt;br /&gt;
|  0xC00&lt;br /&gt;
|  0x200&lt;br /&gt;
|  Filled with 55 (0b01010101) bytes.&lt;br /&gt;
|-&lt;br /&gt;
|  0xE00&lt;br /&gt;
|  0x1FF&lt;br /&gt;
|  Filled with AA (0b10101010) bytes.&lt;br /&gt;
|-&lt;br /&gt;
|  0xFFF&lt;br /&gt;
|  0x1&lt;br /&gt;
|  The final byte is 00 (0b00000000).&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Production cards always return FF when attempting to read 0x1200-0x3FFF. They probably actually have the same data as development cards, but there&#039;s no way to read it.&lt;br /&gt;
&lt;br /&gt;
== Tools ==&lt;br /&gt;
&lt;br /&gt;
[https://github.com/3dshax/ctr/tree/master/ctrtool ctrtool] - (CMD)(Windows/Linux) Parsing NCSD files&lt;br /&gt;
&lt;br /&gt;
[[3DSExplorer]] - (GUI)(Windows Only) Parsing NCSD files&lt;/div&gt;</summary>
		<author><name>AriA99</name></author>
	</entry>
	<entry>
		<id>https://www.3dbrew.org/w/index.php?title=Gamecards&amp;diff=22560</id>
		<title>Gamecards</title>
		<link rel="alternate" type="text/html" href="https://www.3dbrew.org/w/index.php?title=Gamecards&amp;diff=22560"/>
		<updated>2024-05-26T05:16:39Z</updated>

		<summary type="html">&lt;p&gt;AriA99: Fix formatting because MediaWiki has terrible markup rules&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[File:Gamecard.jpg|thumb|right|A 3DS gamecard]] &lt;br /&gt;
[[File:GamecardPhy.jpg|thumb|right|Close-up of PCB]] &lt;br /&gt;
&lt;br /&gt;
===Physical interface===&lt;br /&gt;
The 3DS gamecards have the same physical interface as regular DS and DSi gamecards. There is only a minor cosmetic difference in the plastic case, which has a small extruding notch on the top-right side. As such, it prevents insertion of the gamecard into old Nintendo DS or DSi systems. &lt;br /&gt;
&lt;br /&gt;
When modifying the case so that the 3DS gamecard fits in a DS or DSi system, those systems will refuse to detect the gamecard and show no banner icon.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
!  Pin&lt;br /&gt;
!  Name&lt;br /&gt;
!colspan=&amp;quot;2&amp;quot;| Description&lt;br /&gt;
|-&lt;br /&gt;
|  1&lt;br /&gt;
|  GND&lt;br /&gt;
|colspan=&amp;quot;2&amp;quot;| Ground&lt;br /&gt;
|-&lt;br /&gt;
|  2&lt;br /&gt;
|  CLK&lt;br /&gt;
|colspan=&amp;quot;2&amp;quot;| Clock. Frequencies 6.7MHz and 4.2MHz for DS/DSi gamecards, up to 16.6MHz for 3DS gamecards (for both SPI and ROM transfers).&lt;br /&gt;
|-&lt;br /&gt;
|  3&lt;br /&gt;
|  NC&lt;br /&gt;
|colspan=&amp;quot;2&amp;quot;| Not connected. Possibly used to program cards.&lt;br /&gt;
|-&lt;br /&gt;
|  4&lt;br /&gt;
|  RCS&lt;br /&gt;
|colspan=&amp;quot;2&amp;quot;| ROM select, active low. Pulled low to start a ROM transfer.&lt;br /&gt;
|-&lt;br /&gt;
|  5&lt;br /&gt;
|  RST&lt;br /&gt;
|colspan=&amp;quot;2&amp;quot;| Reset, active low. &lt;br /&gt;
|-&lt;br /&gt;
|  6&lt;br /&gt;
|  ECS&lt;br /&gt;
|colspan=&amp;quot;2&amp;quot;| Savegame chip select, active low. Pulled low to start a savegame SPI transfer.&lt;br /&gt;
|-&lt;br /&gt;
|  7&lt;br /&gt;
|  IRQ&lt;br /&gt;
|colspan=&amp;quot;2&amp;quot;| Removal detection.&lt;br /&gt;
|-&lt;br /&gt;
|  8&lt;br /&gt;
|  VCC&lt;br /&gt;
|colspan=&amp;quot;2&amp;quot;| Powersupply 3.3V.&lt;br /&gt;
|-&lt;br /&gt;
!&lt;br /&gt;
!&lt;br /&gt;
! ROM bus (selected by RCS)&lt;br /&gt;
! Savegame bus (selected by ECS)&lt;br /&gt;
|-&lt;br /&gt;
|  9&lt;br /&gt;
|  DAT0&lt;br /&gt;
|rowspan=&amp;quot;8&amp;quot;| Bidirectional data bus.&lt;br /&gt;
|rowspan=&amp;quot;4&amp;quot;| NC&lt;br /&gt;
|-&lt;br /&gt;
|  10&lt;br /&gt;
|  DAT1&lt;br /&gt;
|-&lt;br /&gt;
|  11&lt;br /&gt;
|  DAT2&lt;br /&gt;
|-&lt;br /&gt;
|  12&lt;br /&gt;
|  DAT3&lt;br /&gt;
|-&lt;br /&gt;
|  13&lt;br /&gt;
|  DAT4&lt;br /&gt;
|  NC/SIO3&lt;br /&gt;
|-&lt;br /&gt;
|  14&lt;br /&gt;
|  DAT5&lt;br /&gt;
|  WP#/SIO2&lt;br /&gt;
|-&lt;br /&gt;
|  15&lt;br /&gt;
|  DAT6&lt;br /&gt;
|  SO/SIO1&lt;br /&gt;
|-&lt;br /&gt;
|  16&lt;br /&gt;
|  DAT7&lt;br /&gt;
|  SI/SIO0&lt;br /&gt;
|-&lt;br /&gt;
|  17&lt;br /&gt;
|  GND&lt;br /&gt;
|colspan=&amp;quot;2&amp;quot;| Ground&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
!&lt;br /&gt;
!  3DS&lt;br /&gt;
!  DS and DSi&lt;br /&gt;
|-&lt;br /&gt;
|  VCC&lt;br /&gt;
|  Only enabled when the power supply bits of [[CONFIG9_Registers#CFG9_CARDSTATUS|CFG9_CARDSTATUS]] are set to &amp;lt;tt&amp;gt;10&amp;lt;/tt&amp;gt;&lt;br /&gt;
|  Always available when card is detected&lt;br /&gt;
|-&lt;br /&gt;
| Card-detect&lt;br /&gt;
| Physical insertion switch, readable through [[CONFIG9_Registers#CFG9_CARDSTATUS|CFG9_CARDSTATUS]] bit 0&lt;br /&gt;
| IRQ pin&lt;br /&gt;
|-&lt;br /&gt;
| Time to first clock pulse&lt;br /&gt;
| ~280ms&lt;br /&gt;
| ~166ms&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===SPI flash===&lt;br /&gt;
Savegame SPI flash transfers use CPOL=1 and CPHA=1. So far, only one savegame FLASH chip has been identified. The chip identifies as &amp;lt;tt&amp;gt;0xC22211&amp;lt;/tt&amp;gt;. The JEDEC manufacturer ID is Macronix, and despite the chip label saying 25L1001, the JEDEC ID matches the MX25L1021E. Datasheet at:&amp;lt;br&amp;gt;&lt;br /&gt;
[https://www.macronix.com/Lists/Datasheet/Attachments/8796/MX25L1021E,%203V,%201Mb,%20v1.3.pdf Macronix (Rev. 1.3, nov. 11, 2013)] &amp;lt;br&amp;gt;&lt;br /&gt;
[https://web.archive.org/web/20160307235354/http://www.beilenet.com/download/MX25L1021E,%203V,%201Mb,%20v0.01.pdf Old version mirror (Rev. 0.01, apr. 07, 2010)] &amp;lt;br&amp;gt;&lt;br /&gt;
However, the MX25L1021E doesn&#039;t support the 4 bit wide transmission that the 3DS uses to talk to the SPI flash. It is thus likely that this is a custom flash chip.&lt;br /&gt;
&lt;br /&gt;
===Format===&lt;br /&gt;
Cartridges can come in several sizes and include system updates in a region reserved for this. In ROMs less than 1GB the update region can be found with:&lt;br /&gt;
CART_SIZE_MAX-( 0x280000*(CART_SIZE_MAX/CART_SIZE_128MB) )-0x2000000. The region is then 0x2000000 bytes.&lt;br /&gt;
&lt;br /&gt;
===Protocol===&lt;br /&gt;
The communication protocol between the 3DS system and the 3DS gamecard has changed almost completely in comparison with the [http://problemkaputt.de/gbatek.htm#dscartridgeprotocol DS and DSi gamecard communication protocol].&lt;br /&gt;
&lt;br /&gt;
The protocol begins in a DS-compatible 8-byte command mode (unencrypted). It switches to a 3DS-only 16-byte mode (encrypted) after the 0x3e command. When 16-byte commands are used, the data bus maintains the value 0x00 until the card signals it is ready by clocking a single byte 0x01, followed by the actual data. After each 0x200-byte block of actual data, a 4-byte standard CRC32 of the block data (before encryption, polynomial 0x82608edb and the final output is xored with 0xffffffff) follows.&lt;br /&gt;
&lt;br /&gt;
Here&#039;s a set of sample gamecard commands for the title LEGO Star Wars III The Clone Wars (EUR), title ID 0004000000038c00, that a 3DS sends to a 3DS gamecard:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
!  Size&lt;br /&gt;
!  Command&lt;br /&gt;
!  Decrypted command&lt;br /&gt;
!  Description&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;tt&amp;gt;2000&amp;lt;/tt&amp;gt;&lt;br /&gt;
|&amp;lt;tt&amp;gt;9F00000000000000&amp;lt;/tt&amp;gt;&lt;br /&gt;
|&amp;lt;tt&amp;gt;9F00000000000000&amp;lt;/tt&amp;gt;&lt;br /&gt;
|Reset&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;tt&amp;gt;0000&amp;lt;/tt&amp;gt;&lt;br /&gt;
|&amp;lt;tt&amp;gt;71C93FE9BB0A3B18&amp;lt;/tt&amp;gt;&lt;br /&gt;
|&amp;lt;tt&amp;gt;71C93FE9BB0A3B18&amp;lt;/tt&amp;gt;&lt;br /&gt;
|Signal that the gamecard should act as a 3DS gamecard&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;tt&amp;gt;0004&amp;lt;/tt&amp;gt;&lt;br /&gt;
|&amp;lt;tt&amp;gt;9000000000000000&amp;lt;/tt&amp;gt;&lt;br /&gt;
|&amp;lt;tt&amp;gt;9000000000000000&amp;lt;/tt&amp;gt;&lt;br /&gt;
|Get gamecard ID1, response=9000FEC2&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;tt&amp;gt;0004&amp;lt;/tt&amp;gt;&lt;br /&gt;
|&amp;lt;tt&amp;gt;9000000000000000&amp;lt;/tt&amp;gt;&lt;br /&gt;
|&amp;lt;tt&amp;gt;9000000000000000&amp;lt;/tt&amp;gt;&lt;br /&gt;
|Get gamecard ID1, response=9000FEC2&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;tt&amp;gt;0004&amp;lt;/tt&amp;gt;&lt;br /&gt;
|&amp;lt;tt&amp;gt;A000000000000000&amp;lt;/tt&amp;gt;&lt;br /&gt;
|&amp;lt;tt&amp;gt;A000000000000000&amp;lt;/tt&amp;gt;&lt;br /&gt;
|Get gamecard ID2, response=00000000&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;tt&amp;gt;0000&amp;lt;/tt&amp;gt;&lt;br /&gt;
|&amp;lt;tt&amp;gt;3E00000000000000&amp;lt;/tt&amp;gt;&lt;br /&gt;
|&amp;lt;tt&amp;gt;3E00000000000000&amp;lt;/tt&amp;gt;&lt;br /&gt;
|Enter 16-byte command mode&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;tt&amp;gt;0200&amp;lt;/tt&amp;gt;&lt;br /&gt;
|&amp;lt;tt&amp;gt;82000000000000000000000000000000&amp;lt;/tt&amp;gt;&lt;br /&gt;
|&amp;lt;tt&amp;gt;82000000000000000000000000000000&amp;lt;/tt&amp;gt;&lt;br /&gt;
|Get gamecard header and enable encryption&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;tt&amp;gt;0000&amp;lt;/tt&amp;gt;&lt;br /&gt;
|&amp;lt;tt&amp;gt;F32C92D85C9D44DED3E0E41DBE7C90D9&amp;lt;/tt&amp;gt;&lt;br /&gt;
|&amp;lt;tt&amp;gt;8300000000000000708DF1A731717D0B&amp;lt;/tt&amp;gt; &lt;br /&gt;
|Seed (rekey cryptography)&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;tt&amp;gt;0004&amp;lt;/tt&amp;gt;&lt;br /&gt;
|&amp;lt;tt&amp;gt;696B9D8582FB55D31B68CAFE70C74A95&amp;lt;/tt&amp;gt;&lt;br /&gt;
|&amp;lt;tt&amp;gt;A200000000000000708DF1A731717D0B&amp;lt;/tt&amp;gt;&lt;br /&gt;
|Get gamecard ID1 (using cryptography), response=9000FEC2&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;tt&amp;gt;0004&amp;lt;/tt&amp;gt;&lt;br /&gt;
|&amp;lt;tt&amp;gt;BAA4812CA0AC9C5D19399530E3ACCCAB&amp;lt;/tt&amp;gt;&lt;br /&gt;
|&amp;lt;tt&amp;gt;A300000000000000708DF1A731717D0B&amp;lt;/tt&amp;gt;&lt;br /&gt;
|Get gamecard ID2 (using cryptography)&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;tt&amp;gt;0000&amp;lt;/tt&amp;gt;&lt;br /&gt;
|&amp;lt;tt&amp;gt;178E427C22D87ADB86387249A97D321A&amp;lt;/tt&amp;gt;&lt;br /&gt;
|&amp;lt;tt&amp;gt;C500000000000000708DF1A731717D0B&amp;lt;/tt&amp;gt;&lt;br /&gt;
|Refresh cart NAND&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;tt&amp;gt;0004&amp;lt;/tt&amp;gt;&lt;br /&gt;
|&amp;lt;tt&amp;gt;E06019B1BD5C9130ED6A4D9F4A9E7193&amp;lt;/tt&amp;gt;&lt;br /&gt;
|&amp;lt;tt&amp;gt;A200000000000000708DF1A731717D0B&amp;lt;/tt&amp;gt;&lt;br /&gt;
|Get gamecard ID1 (using cryptography), response=9000FEC2&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;tt&amp;gt;0004&amp;lt;/tt&amp;gt;&lt;br /&gt;
|&amp;lt;tt&amp;gt;4E0D224862523BBFE2E6255F80E15F37&amp;lt;/tt&amp;gt;&lt;br /&gt;
|&amp;lt;tt&amp;gt;A200000000000000708DF1A731717D0B&amp;lt;/tt&amp;gt;&lt;br /&gt;
|Get gamecard ID1 (using cryptography), response=9000FEC2&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;tt&amp;gt;0004&amp;lt;/tt&amp;gt;&lt;br /&gt;
|&amp;lt;tt&amp;gt;4CDF93D319FB62D0DB632A45E3E8D84C&amp;lt;/tt&amp;gt;&lt;br /&gt;
|&amp;lt;tt&amp;gt;A200000000000000708DF1A731717D0B&amp;lt;/tt&amp;gt;&lt;br /&gt;
|Get gamecard ID1 (using cryptography), response=9000FEC2&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;tt&amp;gt;0004&amp;lt;/tt&amp;gt;&lt;br /&gt;
|&amp;lt;tt&amp;gt;9AA5D80551002F955546D296A57F0FEF&amp;lt;/tt&amp;gt;&lt;br /&gt;
|&amp;lt;tt&amp;gt;A200000000000000708DF1A731717D0B&amp;lt;/tt&amp;gt;&lt;br /&gt;
|Get gamecard ID1 (using cryptography), response=9000FEC2&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;tt&amp;gt;0004&amp;lt;/tt&amp;gt;&lt;br /&gt;
|&amp;lt;tt&amp;gt;C12BA81AEF30DDDBD93FAD5D544C6334&amp;lt;/tt&amp;gt;&lt;br /&gt;
|&amp;lt;tt&amp;gt;A200000000000000708DF1A731717D0B&amp;lt;/tt&amp;gt;&lt;br /&gt;
|Get gamecard ID1 (using cryptography), response=9000FEC2&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;tt&amp;gt;0200&amp;lt;/tt&amp;gt;&lt;br /&gt;
|&amp;lt;tt&amp;gt;62EC5FB7F420AE1DC6253AE18AFA5BB3&amp;lt;/tt&amp;gt;&lt;br /&gt;
|&amp;lt;tt&amp;gt;BF000000000000000000000000000000&amp;lt;/tt&amp;gt;&lt;br /&gt;
|Read gamecard at address 0&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;tt&amp;gt;0200&amp;lt;/tt&amp;gt;&lt;br /&gt;
|&amp;lt;tt&amp;gt;E3FA23AA016BE0C93430D1F42FF41324&amp;lt;/tt&amp;gt;&lt;br /&gt;
|&amp;lt;tt&amp;gt;BF000000000040000000000000000000&amp;lt;/tt&amp;gt;&lt;br /&gt;
|Read gamecard at address 0x4000&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The header command has some initial dummy bytes, and eventually responds with a 0x200 byte header. Here&#039;s an example for Lego Starwars 3:&lt;br /&gt;
 0000000: 00 8c 03 00 00 00 04 00 00 00 00 00 00 00 00 00  ................&lt;br /&gt;
 0000010: b3 cf fb c6 6a b1 cb 20 32 af ce 35 d4 1c 74 c9  ....j.. 2..5..t.&lt;br /&gt;
 0000020: 8e 6b 27 2f 08 01 28 3b d4 30 de 44 37 f5 b0 46  .k&#039;/..(;.0.D7..F&lt;br /&gt;
 0000030: 91 59 d7 38 33 48 df 83 fd 71 84 2c 00 00 00 00  .Y.83H...q.,....&lt;br /&gt;
 0000040: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................&lt;br /&gt;
 0000050: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................&lt;br /&gt;
 0000060: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................&lt;br /&gt;
 0000070: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................&lt;br /&gt;
 0000080: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................&lt;br /&gt;
 0000090: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................&lt;br /&gt;
 00000a0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................&lt;br /&gt;
 00000b0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................&lt;br /&gt;
 00000c0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................&lt;br /&gt;
 00000d0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................&lt;br /&gt;
 00000e0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................&lt;br /&gt;
 00000f0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................&lt;br /&gt;
 0000100: 4e 43 43 48 7a 7f 0e 00 00 8c 03 00 00 00 04 00  NCCHz...........&lt;br /&gt;
 0000110: 36 34 02 00 00 00 00 00 00 8c 03 00 00 00 04 00  64..............&lt;br /&gt;
 0000120: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................&lt;br /&gt;
 0000130: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................&lt;br /&gt;
 0000140: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................&lt;br /&gt;
 0000150: 43 54 52 2d 50 2d 41 4c 47 50 00 00 00 00 00 00  CTR-P-ALGP......&lt;br /&gt;
 0000160: 0c 27 e3 c1 de 7b 2a e2 d3 11 4f 32 a4 ee bf 46  .&#039;...{*...O2...F&lt;br /&gt;
 0000170: 9a fd 0c f3 52 c1 1d 49 84 c2 a9 f1 d2 14 4c 63  ....R..I......Lc&lt;br /&gt;
 0000180: 00 04 00 00 00 00 00 00 00 00 00 00 01 03 00 00  ................&lt;br /&gt;
 0000190: 05 00 00 00 01 00 00 00 00 00 00 00 00 00 00 00  ................&lt;br /&gt;
 00001a0: 06 00 00 00 1c 0a 00 00 01 00 00 00 00 00 00 00  ................&lt;br /&gt;
 00001b0: 22 0a 00 00 58 75 0e 00 01 00 00 00 00 00 00 00  &amp;quot;...Xu..........&lt;br /&gt;
 00001c0: 13 0c 04 26 15 f6 47 c4 c6 32 25 ea 9e 67 f8 a2  ...&amp;amp;..G..2%..g..&lt;br /&gt;
 00001d0: 7b 15 24 6b 88 fb c7 a9 27 25 7b 84 97 7b 78 7b  {.$k....&#039;%{..{x{&lt;br /&gt;
 00001e0: a6 5b ee 10 60 bb 6a 68 21 bb ce c6 00 03 5b 7e  .[..`.jh!.....[~&lt;br /&gt;
 00001f0: 64 fb 6e ac a7 f0 96 0c fb 1f 5a 37 08 77 28 f7  d.n.......Z7.w(.&lt;br /&gt;
&lt;br /&gt;
After the 0x82 command, cryptography is initialized, which can be reproduced following this algorithm; unless noted otherwise, all operations are in big endian byte order:&lt;br /&gt;
&lt;br /&gt;
# Set the [[AES_Registers|AES keyslot 0x3b keyY]] to the values at 0x000:0x010. The corresponding keyX is set in [[Bootloader|Boot9]].&lt;br /&gt;
# Decrypt the 16 bytes at 0x010:0x020 using AES-128-CCM in keyslot 0x3b using the 12-byte nonce at 0x030:0x03c to obtain the primary seed; if the response to the 0xa0 command AND 0x00000003 equals 3, instead use slot 0x11 and set the normalkey to 0x00000000000000000000000000000000. Verify that the 16-byte tag at 0x020:0x030 is valid.&lt;br /&gt;
# Split the primary seed into two halves: left and right.&lt;br /&gt;
# Initialize a context for the SNOW 2.0 stream cipher. The 128-bit key is the primary seed. The 128-bit IV is a 128-bit static value depending on the gamecard ID2.&lt;br /&gt;
# Call the SNOW 2.0 stream cipher 32 times to obtain 1024 bits (32 words) of output. Discard them.&lt;br /&gt;
# Initialize a context for the RC4 stream cipher. The 256-bit key consists of a 128-bit static value depending on the gamecard ID2 followed by four outputs of the SNOW 2.0 stream.&lt;br /&gt;
# Call the RC4 stream cipher 256 times to obtain 2048 bits (256 bytes) of output. Discard them.&lt;br /&gt;
&lt;br /&gt;
All commands and responses are now encrypted using RC4. The gamecard controller and gamecard itself share the RC4 key and advance the state accordingly.&lt;br /&gt;
&lt;br /&gt;
If the 0x83 command is sent, the cryptography is re-keyed:&lt;br /&gt;
&lt;br /&gt;
# Initialize a new context for the SNOW 2.0 stream cipher. The 128-bit key consists of the left half of the primary seed followed by the lower 64 bytes of the decrypted 0x83 command. The 128-bit IV is the same 128-bit static value depending on the gamecard ID2 as before.&lt;br /&gt;
# Call the SNOW 2.0 stream cipher 32 times to obtain 1024 bits (32 words) of output. Discard them.&lt;br /&gt;
# Initialize a new context for the RC4 stream cipher. The 256-bit key consists of the same 128-bit static value depending on the gamecard ID2 as before followed by four outputs of the new SNOW 2.0 stream.&lt;br /&gt;
# Call the RC4 stream cipher 256 times to obtain 2048 bits (256 bytes) of output. Discard them.&lt;br /&gt;
&lt;br /&gt;
The above example commands can be decrypted in this manner.&lt;br /&gt;
&lt;br /&gt;
The static values are fixed in the gamecard controller and gamecards themselves, they are not obtained from Process9 or anywhere in NATIVE_FIRM.&lt;/div&gt;</summary>
		<author><name>AriA99</name></author>
	</entry>
	<entry>
		<id>https://www.3dbrew.org/w/index.php?title=Gamecards&amp;diff=22559</id>
		<title>Gamecards</title>
		<link rel="alternate" type="text/html" href="https://www.3dbrew.org/w/index.php?title=Gamecards&amp;diff=22559"/>
		<updated>2024-05-26T05:15:06Z</updated>

		<summary type="html">&lt;p&gt;AriA99: Describe cart cryptography protocol now that it is confirmed the Switch uses a different protocol&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[File:Gamecard.jpg|thumb|right|A 3DS gamecard]] &lt;br /&gt;
[[File:GamecardPhy.jpg|thumb|right|Close-up of PCB]] &lt;br /&gt;
&lt;br /&gt;
===Physical interface===&lt;br /&gt;
The 3DS gamecards have the same physical interface as regular DS and DSi gamecards. There is only a minor cosmetic difference in the plastic case, which has a small extruding notch on the top-right side. As such, it prevents insertion of the gamecard into old Nintendo DS or DSi systems. &lt;br /&gt;
&lt;br /&gt;
When modifying the case so that the 3DS gamecard fits in a DS or DSi system, those systems will refuse to detect the gamecard and show no banner icon.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
!  Pin&lt;br /&gt;
!  Name&lt;br /&gt;
!colspan=&amp;quot;2&amp;quot;| Description&lt;br /&gt;
|-&lt;br /&gt;
|  1&lt;br /&gt;
|  GND&lt;br /&gt;
|colspan=&amp;quot;2&amp;quot;| Ground&lt;br /&gt;
|-&lt;br /&gt;
|  2&lt;br /&gt;
|  CLK&lt;br /&gt;
|colspan=&amp;quot;2&amp;quot;| Clock. Frequencies 6.7MHz and 4.2MHz for DS/DSi gamecards, up to 16.6MHz for 3DS gamecards (for both SPI and ROM transfers).&lt;br /&gt;
|-&lt;br /&gt;
|  3&lt;br /&gt;
|  NC&lt;br /&gt;
|colspan=&amp;quot;2&amp;quot;| Not connected. Possibly used to program cards.&lt;br /&gt;
|-&lt;br /&gt;
|  4&lt;br /&gt;
|  RCS&lt;br /&gt;
|colspan=&amp;quot;2&amp;quot;| ROM select, active low. Pulled low to start a ROM transfer.&lt;br /&gt;
|-&lt;br /&gt;
|  5&lt;br /&gt;
|  RST&lt;br /&gt;
|colspan=&amp;quot;2&amp;quot;| Reset, active low. &lt;br /&gt;
|-&lt;br /&gt;
|  6&lt;br /&gt;
|  ECS&lt;br /&gt;
|colspan=&amp;quot;2&amp;quot;| Savegame chip select, active low. Pulled low to start a savegame SPI transfer.&lt;br /&gt;
|-&lt;br /&gt;
|  7&lt;br /&gt;
|  IRQ&lt;br /&gt;
|colspan=&amp;quot;2&amp;quot;| Removal detection.&lt;br /&gt;
|-&lt;br /&gt;
|  8&lt;br /&gt;
|  VCC&lt;br /&gt;
|colspan=&amp;quot;2&amp;quot;| Powersupply 3.3V.&lt;br /&gt;
|-&lt;br /&gt;
!&lt;br /&gt;
!&lt;br /&gt;
! ROM bus (selected by RCS)&lt;br /&gt;
! Savegame bus (selected by ECS)&lt;br /&gt;
|-&lt;br /&gt;
|  9&lt;br /&gt;
|  DAT0&lt;br /&gt;
|rowspan=&amp;quot;8&amp;quot;| Bidirectional data bus.&lt;br /&gt;
|rowspan=&amp;quot;4&amp;quot;| NC&lt;br /&gt;
|-&lt;br /&gt;
|  10&lt;br /&gt;
|  DAT1&lt;br /&gt;
|-&lt;br /&gt;
|  11&lt;br /&gt;
|  DAT2&lt;br /&gt;
|-&lt;br /&gt;
|  12&lt;br /&gt;
|  DAT3&lt;br /&gt;
|-&lt;br /&gt;
|  13&lt;br /&gt;
|  DAT4&lt;br /&gt;
|  NC/SIO3&lt;br /&gt;
|-&lt;br /&gt;
|  14&lt;br /&gt;
|  DAT5&lt;br /&gt;
|  WP#/SIO2&lt;br /&gt;
|-&lt;br /&gt;
|  15&lt;br /&gt;
|  DAT6&lt;br /&gt;
|  SO/SIO1&lt;br /&gt;
|-&lt;br /&gt;
|  16&lt;br /&gt;
|  DAT7&lt;br /&gt;
|  SI/SIO0&lt;br /&gt;
|-&lt;br /&gt;
|  17&lt;br /&gt;
|  GND&lt;br /&gt;
|colspan=&amp;quot;2&amp;quot;| Ground&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
!&lt;br /&gt;
!  3DS&lt;br /&gt;
!  DS and DSi&lt;br /&gt;
|-&lt;br /&gt;
|  VCC&lt;br /&gt;
|  Only enabled when the power supply bits of [[CONFIG9_Registers#CFG9_CARDSTATUS|CFG9_CARDSTATUS]] are set to &amp;lt;tt&amp;gt;10&amp;lt;/tt&amp;gt;&lt;br /&gt;
|  Always available when card is detected&lt;br /&gt;
|-&lt;br /&gt;
| Card-detect&lt;br /&gt;
| Physical insertion switch, readable through [[CONFIG9_Registers#CFG9_CARDSTATUS|CFG9_CARDSTATUS]] bit 0&lt;br /&gt;
| IRQ pin&lt;br /&gt;
|-&lt;br /&gt;
| Time to first clock pulse&lt;br /&gt;
| ~280ms&lt;br /&gt;
| ~166ms&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===SPI flash===&lt;br /&gt;
Savegame SPI flash transfers use CPOL=1 and CPHA=1. So far, only one savegame FLASH chip has been identified. The chip identifies as &amp;lt;tt&amp;gt;0xC22211&amp;lt;/tt&amp;gt;. The JEDEC manufacturer ID is Macronix, and despite the chip label saying 25L1001, the JEDEC ID matches the MX25L1021E. Datasheet at:&amp;lt;br&amp;gt;&lt;br /&gt;
[https://www.macronix.com/Lists/Datasheet/Attachments/8796/MX25L1021E,%203V,%201Mb,%20v1.3.pdf Macronix (Rev. 1.3, nov. 11, 2013)] &amp;lt;br&amp;gt;&lt;br /&gt;
[https://web.archive.org/web/20160307235354/http://www.beilenet.com/download/MX25L1021E,%203V,%201Mb,%20v0.01.pdf Old version mirror (Rev. 0.01, apr. 07, 2010)] &amp;lt;br&amp;gt;&lt;br /&gt;
However, the MX25L1021E doesn&#039;t support the 4 bit wide transmission that the 3DS uses to talk to the SPI flash. It is thus likely that this is a custom flash chip.&lt;br /&gt;
&lt;br /&gt;
===Format===&lt;br /&gt;
Cartridges can come in several sizes and include system updates in a region reserved for this. In ROMs less than 1GB the update region can be found with:&lt;br /&gt;
CART_SIZE_MAX-( 0x280000*(CART_SIZE_MAX/CART_SIZE_128MB) )-0x2000000. The region is then 0x2000000 bytes.&lt;br /&gt;
&lt;br /&gt;
===Protocol===&lt;br /&gt;
The communication protocol between the 3DS system and the 3DS gamecard has changed almost completely in comparison with the [http://problemkaputt.de/gbatek.htm#dscartridgeprotocol DS and DSi gamecard communication protocol].&lt;br /&gt;
&lt;br /&gt;
The protocol begins in a DS-compatible 8-byte command mode (unencrypted). It switches to a 3DS-only 16-byte mode (encrypted) after the 0x3e command. When 16-byte commands are used, the data bus maintains the value 0x00 until the card signals it is ready by clocking a single byte 0x01, followed by the actual data. After each 0x200-byte block of actual data, a 4-byte standard CRC32 of the block data (before encryption, polynomial 0x82608edb and the final output is xored with 0xffffffff) follows.&lt;br /&gt;
&lt;br /&gt;
Here&#039;s a set of sample gamecard commands for the title LEGO Star Wars III The Clone Wars (EUR), title ID 0004000000038c00, that a 3DS sends to a 3DS gamecard:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
!  Size&lt;br /&gt;
!  Command&lt;br /&gt;
!  Decrypted command&lt;br /&gt;
!  Description&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;tt&amp;gt;2000&amp;lt;/tt&amp;gt;&lt;br /&gt;
|&amp;lt;tt&amp;gt;9F00000000000000&amp;lt;/tt&amp;gt;&lt;br /&gt;
|&amp;lt;tt&amp;gt;9F00000000000000&amp;lt;/tt&amp;gt;&lt;br /&gt;
|Reset&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;tt&amp;gt;0000&amp;lt;/tt&amp;gt;&lt;br /&gt;
|&amp;lt;tt&amp;gt;71C93FE9BB0A3B18&amp;lt;/tt&amp;gt;&lt;br /&gt;
|&amp;lt;tt&amp;gt;71C93FE9BB0A3B18&amp;lt;/tt&amp;gt;&lt;br /&gt;
|Signal that the gamecard should act as a 3DS gamecard&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;tt&amp;gt;0004&amp;lt;/tt&amp;gt;&lt;br /&gt;
|&amp;lt;tt&amp;gt;9000000000000000&amp;lt;/tt&amp;gt;&lt;br /&gt;
|&amp;lt;tt&amp;gt;9000000000000000&amp;lt;/tt&amp;gt;&lt;br /&gt;
|Get gamecard ID1, response=9000FEC2&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;tt&amp;gt;0004&amp;lt;/tt&amp;gt;&lt;br /&gt;
|&amp;lt;tt&amp;gt;9000000000000000&amp;lt;/tt&amp;gt;&lt;br /&gt;
|&amp;lt;tt&amp;gt;9000000000000000&amp;lt;/tt&amp;gt;&lt;br /&gt;
|Get gamecard ID1, response=9000FEC2&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;tt&amp;gt;0004&amp;lt;/tt&amp;gt;&lt;br /&gt;
|&amp;lt;tt&amp;gt;A000000000000000&amp;lt;/tt&amp;gt;&lt;br /&gt;
|&amp;lt;tt&amp;gt;A000000000000000&amp;lt;/tt&amp;gt;&lt;br /&gt;
|Get gamecard ID2, response=00000000&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;tt&amp;gt;0000&amp;lt;/tt&amp;gt;&lt;br /&gt;
|&amp;lt;tt&amp;gt;3E00000000000000&amp;lt;/tt&amp;gt;&lt;br /&gt;
|&amp;lt;tt&amp;gt;3E00000000000000&amp;lt;/tt&amp;gt;&lt;br /&gt;
|Enter 16-byte command mode&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;tt&amp;gt;0200&amp;lt;/tt&amp;gt;&lt;br /&gt;
|&amp;lt;tt&amp;gt;82000000000000000000000000000000&amp;lt;/tt&amp;gt;&lt;br /&gt;
|&amp;lt;tt&amp;gt;82000000000000000000000000000000&amp;lt;/tt&amp;gt;&lt;br /&gt;
|Get gamecard header and enable encryption&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;tt&amp;gt;0000&amp;lt;/tt&amp;gt;&lt;br /&gt;
|&amp;lt;tt&amp;gt;F32C92D85C9D44DED3E0E41DBE7C90D9&amp;lt;/tt&amp;gt;&lt;br /&gt;
|&amp;lt;tt&amp;gt;8300000000000000708DF1A731717D0B&amp;lt;/tt&amp;gt; &lt;br /&gt;
|Seed (rekey cryptography)&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;tt&amp;gt;0004&amp;lt;/tt&amp;gt;&lt;br /&gt;
|&amp;lt;tt&amp;gt;696B9D8582FB55D31B68CAFE70C74A95&amp;lt;/tt&amp;gt;&lt;br /&gt;
|&amp;lt;tt&amp;gt;A200000000000000708DF1A731717D0B&amp;lt;/tt&amp;gt;&lt;br /&gt;
|Get gamecard ID1 (using cryptography), response=9000FEC2&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;tt&amp;gt;0004&amp;lt;/tt&amp;gt;&lt;br /&gt;
|&amp;lt;tt&amp;gt;BAA4812CA0AC9C5D19399530E3ACCCAB&amp;lt;/tt&amp;gt;&lt;br /&gt;
|&amp;lt;tt&amp;gt;A300000000000000708DF1A731717D0B&amp;lt;/tt&amp;gt;&lt;br /&gt;
|Get gamecard ID2 (using cryptography)&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;tt&amp;gt;0000&amp;lt;/tt&amp;gt;&lt;br /&gt;
|&amp;lt;tt&amp;gt;178E427C22D87ADB86387249A97D321A&amp;lt;/tt&amp;gt;&lt;br /&gt;
|&amp;lt;tt&amp;gt;C500000000000000708DF1A731717D0B&amp;lt;/tt&amp;gt;&lt;br /&gt;
|Refresh cart NAND&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;tt&amp;gt;0004&amp;lt;/tt&amp;gt;&lt;br /&gt;
|&amp;lt;tt&amp;gt;E06019B1BD5C9130ED6A4D9F4A9E7193&amp;lt;/tt&amp;gt;&lt;br /&gt;
|&amp;lt;tt&amp;gt;A200000000000000708DF1A731717D0B&amp;lt;/tt&amp;gt;&lt;br /&gt;
|Get gamecard ID1 (using cryptography), response=9000FEC2&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;tt&amp;gt;0004&amp;lt;/tt&amp;gt;&lt;br /&gt;
|&amp;lt;tt&amp;gt;4E0D224862523BBFE2E6255F80E15F37&amp;lt;/tt&amp;gt;&lt;br /&gt;
|&amp;lt;tt&amp;gt;A200000000000000708DF1A731717D0B&amp;lt;/tt&amp;gt;&lt;br /&gt;
|Get gamecard ID1 (using cryptography), response=9000FEC2&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;tt&amp;gt;0004&amp;lt;/tt&amp;gt;&lt;br /&gt;
|&amp;lt;tt&amp;gt;4CDF93D319FB62D0DB632A45E3E8D84C&amp;lt;/tt&amp;gt;&lt;br /&gt;
|&amp;lt;tt&amp;gt;A200000000000000708DF1A731717D0B&amp;lt;/tt&amp;gt;&lt;br /&gt;
|Get gamecard ID1 (using cryptography), response=9000FEC2&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;tt&amp;gt;0004&amp;lt;/tt&amp;gt;&lt;br /&gt;
|&amp;lt;tt&amp;gt;9AA5D80551002F955546D296A57F0FEF&amp;lt;/tt&amp;gt;&lt;br /&gt;
|&amp;lt;tt&amp;gt;A200000000000000708DF1A731717D0B&amp;lt;/tt&amp;gt;&lt;br /&gt;
|Get gamecard ID1 (using cryptography), response=9000FEC2&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;tt&amp;gt;0004&amp;lt;/tt&amp;gt;&lt;br /&gt;
|&amp;lt;tt&amp;gt;C12BA81AEF30DDDBD93FAD5D544C6334&amp;lt;/tt&amp;gt;&lt;br /&gt;
|&amp;lt;tt&amp;gt;A200000000000000708DF1A731717D0B&amp;lt;/tt&amp;gt;&lt;br /&gt;
|Get gamecard ID1 (using cryptography), response=9000FEC2&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;tt&amp;gt;0200&amp;lt;/tt&amp;gt;&lt;br /&gt;
|&amp;lt;tt&amp;gt;62EC5FB7F420AE1DC6253AE18AFA5BB3&amp;lt;/tt&amp;gt;&lt;br /&gt;
|&amp;lt;tt&amp;gt;BF000000000000000000000000000000&amp;lt;/tt&amp;gt;&lt;br /&gt;
|Read gamecard at address 0&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;tt&amp;gt;0200&amp;lt;/tt&amp;gt;&lt;br /&gt;
|&amp;lt;tt&amp;gt;E3FA23AA016BE0C93430D1F42FF41324&amp;lt;/tt&amp;gt;&lt;br /&gt;
|&amp;lt;tt&amp;gt;BF000000000040000000000000000000&amp;lt;/tt&amp;gt;&lt;br /&gt;
|Read gamecard at address 0x4000&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The header command has some initial dummy bytes, and eventually responds with a 0x200 byte header. Here&#039;s an example for Lego Starwars 3:&lt;br /&gt;
 0000000: 00 8c 03 00 00 00 04 00 00 00 00 00 00 00 00 00  ................&lt;br /&gt;
 0000010: b3 cf fb c6 6a b1 cb 20 32 af ce 35 d4 1c 74 c9  ....j.. 2..5..t.&lt;br /&gt;
 0000020: 8e 6b 27 2f 08 01 28 3b d4 30 de 44 37 f5 b0 46  .k&#039;/..(;.0.D7..F&lt;br /&gt;
 0000030: 91 59 d7 38 33 48 df 83 fd 71 84 2c 00 00 00 00  .Y.83H...q.,....&lt;br /&gt;
 0000040: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................&lt;br /&gt;
 0000050: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................&lt;br /&gt;
 0000060: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................&lt;br /&gt;
 0000070: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................&lt;br /&gt;
 0000080: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................&lt;br /&gt;
 0000090: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................&lt;br /&gt;
 00000a0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................&lt;br /&gt;
 00000b0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................&lt;br /&gt;
 00000c0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................&lt;br /&gt;
 00000d0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................&lt;br /&gt;
 00000e0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................&lt;br /&gt;
 00000f0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................&lt;br /&gt;
 0000100: 4e 43 43 48 7a 7f 0e 00 00 8c 03 00 00 00 04 00  NCCHz...........&lt;br /&gt;
 0000110: 36 34 02 00 00 00 00 00 00 8c 03 00 00 00 04 00  64..............&lt;br /&gt;
 0000120: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................&lt;br /&gt;
 0000130: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................&lt;br /&gt;
 0000140: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................&lt;br /&gt;
 0000150: 43 54 52 2d 50 2d 41 4c 47 50 00 00 00 00 00 00  CTR-P-ALGP......&lt;br /&gt;
 0000160: 0c 27 e3 c1 de 7b 2a e2 d3 11 4f 32 a4 ee bf 46  .&#039;...{*...O2...F&lt;br /&gt;
 0000170: 9a fd 0c f3 52 c1 1d 49 84 c2 a9 f1 d2 14 4c 63  ....R..I......Lc&lt;br /&gt;
 0000180: 00 04 00 00 00 00 00 00 00 00 00 00 01 03 00 00  ................&lt;br /&gt;
 0000190: 05 00 00 00 01 00 00 00 00 00 00 00 00 00 00 00  ................&lt;br /&gt;
 00001a0: 06 00 00 00 1c 0a 00 00 01 00 00 00 00 00 00 00  ................&lt;br /&gt;
 00001b0: 22 0a 00 00 58 75 0e 00 01 00 00 00 00 00 00 00  &amp;quot;...Xu..........&lt;br /&gt;
 00001c0: 13 0c 04 26 15 f6 47 c4 c6 32 25 ea 9e 67 f8 a2  ...&amp;amp;..G..2%..g..&lt;br /&gt;
 00001d0: 7b 15 24 6b 88 fb c7 a9 27 25 7b 84 97 7b 78 7b  {.$k....&#039;%{..{x{&lt;br /&gt;
 00001e0: a6 5b ee 10 60 bb 6a 68 21 bb ce c6 00 03 5b 7e  .[..`.jh!.....[~&lt;br /&gt;
 00001f0: 64 fb 6e ac a7 f0 96 0c fb 1f 5a 37 08 77 28 f7  d.n.......Z7.w(.&lt;br /&gt;
&lt;br /&gt;
After the 0x82 command, cryptography is initialized, which can be reproduced following this algorithm; unless noted otherwise, all operations are in big endian byte order:&lt;br /&gt;
&lt;br /&gt;
1. Set the [[AES_Registers|AES keyslot 0x3b keyY]] to the values at 0x000:0x010. The corresponding keyX is set in [[Bootloader|Boot9]].&lt;br /&gt;
2. Decrypt the 16 bytes at 0x010:0x020 using AES-128-CCM in keyslot 0x3b using the 12-byte nonce at 0x030:0x03c to obtain the primary seed; if the response to the 0xa0 command AND 0x00000003 equals 3, instead use slot 0x11 and set the normalkey to 0x00000000000000000000000000000000. Verify that the 16-byte tag at 0x020:0x030 is valid.&lt;br /&gt;
3. Split the primary seed into two halves: left and right.&lt;br /&gt;
4. Initialize a context for the SNOW 2.0 stream cipher. The 128-bit key is the primary seed. The 128-bit IV is a 128-bit static value depending on the gamecard ID2.&lt;br /&gt;
5. Call the SNOW 2.0 stream cipher 32 times to obtain 1024 bits (32 words) of output. Discard them.&lt;br /&gt;
6. Initialize a context for the RC4 stream cipher. The 256-bit key consists of a 128-bit static value depending on the gamecard ID2 followed by four outputs of the SNOW 2.0 stream.&lt;br /&gt;
7. Call the RC4 stream cipher 256 times to obtain 2048 bits (256 bytes) of output. Discard them.&lt;br /&gt;
&lt;br /&gt;
All commands and responses are now encrypted using RC4. The gamecard controller and gamecard itself share the RC4 key and advance the state accordingly.&lt;br /&gt;
&lt;br /&gt;
If the 0x83 command is sent, the cryptography is re-keyed:&lt;br /&gt;
&lt;br /&gt;
1. Initialize a new context for the SNOW 2.0 stream cipher. The 128-bit key consists of the left half of the primary seed followed by the lower 64 bytes of the decrypted 0x83 command. The 128-bit IV is the same 128-bit static value depending on the gamecard ID2 as before.&lt;br /&gt;
2. Call the SNOW 2.0 stream cipher 32 times to obtain 1024 bits (32 words) of output. Discard them.&lt;br /&gt;
3. Initialize a new context for the RC4 stream cipher. The 256-bit key consists of the same 128-bit static value depending on the gamecard ID2 as before followed by four outputs of the new SNOW 2.0 stream.&lt;br /&gt;
4. Call the RC4 stream cipher 256 times to obtain 2048 bits (256 bytes) of output. Discard them.&lt;br /&gt;
&lt;br /&gt;
The above example commands can be decrypted in this manner.&lt;br /&gt;
&lt;br /&gt;
The static values are fixed in the gamecard controller and gamecards themselves, they are not obtained from Process9 or anywhere in NATIVE_FIRM.&lt;/div&gt;</summary>
		<author><name>AriA99</name></author>
	</entry>
	<entry>
		<id>https://www.3dbrew.org/w/index.php?title=Gamecards&amp;diff=22558</id>
		<title>Gamecards</title>
		<link rel="alternate" type="text/html" href="https://www.3dbrew.org/w/index.php?title=Gamecards&amp;diff=22558"/>
		<updated>2024-05-26T04:13:24Z</updated>

		<summary type="html">&lt;p&gt;AriA99: Details on CRC-32&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[File:Gamecard.jpg|thumb|right|A 3DS gamecard]] &lt;br /&gt;
[[File:GamecardPhy.jpg|thumb|right|Close-up of PCB]] &lt;br /&gt;
&lt;br /&gt;
===Physical interface===&lt;br /&gt;
The 3DS gamecards have the same physical interface as regular DS and DSi gamecards. There is only a minor cosmetic difference in the plastic case, which has a small extruding notch on the top-right side. As such, it prevents insertion of the gamecard into old Nintendo DS or DSi systems. &lt;br /&gt;
&lt;br /&gt;
When modifying the case so that the 3DS gamecard fits in a DS or DSi system, those systems will refuse to detect the gamecard and show no banner icon.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
!  Pin&lt;br /&gt;
!  Name&lt;br /&gt;
!colspan=&amp;quot;2&amp;quot;| Description&lt;br /&gt;
|-&lt;br /&gt;
|  1&lt;br /&gt;
|  GND&lt;br /&gt;
|colspan=&amp;quot;2&amp;quot;| Ground&lt;br /&gt;
|-&lt;br /&gt;
|  2&lt;br /&gt;
|  CLK&lt;br /&gt;
|colspan=&amp;quot;2&amp;quot;| Clock. Frequencies 6.7MHz and 4.2MHz for DS/DSi gamecards, up to 16.6MHz for 3DS gamecards (for both SPI and ROM transfers).&lt;br /&gt;
|-&lt;br /&gt;
|  3&lt;br /&gt;
|  NC&lt;br /&gt;
|colspan=&amp;quot;2&amp;quot;| Not connected. Possibly used to program cards.&lt;br /&gt;
|-&lt;br /&gt;
|  4&lt;br /&gt;
|  RCS&lt;br /&gt;
|colspan=&amp;quot;2&amp;quot;| ROM select, active low. Pulled low to start a ROM transfer.&lt;br /&gt;
|-&lt;br /&gt;
|  5&lt;br /&gt;
|  RST&lt;br /&gt;
|colspan=&amp;quot;2&amp;quot;| Reset, active low. &lt;br /&gt;
|-&lt;br /&gt;
|  6&lt;br /&gt;
|  ECS&lt;br /&gt;
|colspan=&amp;quot;2&amp;quot;| Savegame chip select, active low. Pulled low to start a savegame SPI transfer.&lt;br /&gt;
|-&lt;br /&gt;
|  7&lt;br /&gt;
|  IRQ&lt;br /&gt;
|colspan=&amp;quot;2&amp;quot;| Removal detection.&lt;br /&gt;
|-&lt;br /&gt;
|  8&lt;br /&gt;
|  VCC&lt;br /&gt;
|colspan=&amp;quot;2&amp;quot;| Powersupply 3.3V.&lt;br /&gt;
|-&lt;br /&gt;
!&lt;br /&gt;
!&lt;br /&gt;
! ROM bus (selected by RCS)&lt;br /&gt;
! Savegame bus (selected by ECS)&lt;br /&gt;
|-&lt;br /&gt;
|  9&lt;br /&gt;
|  DAT0&lt;br /&gt;
|rowspan=&amp;quot;8&amp;quot;| Bidirectional data bus.&lt;br /&gt;
|rowspan=&amp;quot;4&amp;quot;| NC&lt;br /&gt;
|-&lt;br /&gt;
|  10&lt;br /&gt;
|  DAT1&lt;br /&gt;
|-&lt;br /&gt;
|  11&lt;br /&gt;
|  DAT2&lt;br /&gt;
|-&lt;br /&gt;
|  12&lt;br /&gt;
|  DAT3&lt;br /&gt;
|-&lt;br /&gt;
|  13&lt;br /&gt;
|  DAT4&lt;br /&gt;
|  NC/SIO3&lt;br /&gt;
|-&lt;br /&gt;
|  14&lt;br /&gt;
|  DAT5&lt;br /&gt;
|  WP#/SIO2&lt;br /&gt;
|-&lt;br /&gt;
|  15&lt;br /&gt;
|  DAT6&lt;br /&gt;
|  SO/SIO1&lt;br /&gt;
|-&lt;br /&gt;
|  16&lt;br /&gt;
|  DAT7&lt;br /&gt;
|  SI/SIO0&lt;br /&gt;
|-&lt;br /&gt;
|  17&lt;br /&gt;
|  GND&lt;br /&gt;
|colspan=&amp;quot;2&amp;quot;| Ground&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
!&lt;br /&gt;
!  3DS&lt;br /&gt;
!  DS and DSi&lt;br /&gt;
|-&lt;br /&gt;
|  VCC&lt;br /&gt;
|  Only enabled when the power supply bits of [[CONFIG9_Registers#CFG9_CARDSTATUS|CFG9_CARDSTATUS]] are set to &amp;lt;tt&amp;gt;10&amp;lt;/tt&amp;gt;&lt;br /&gt;
|  Always available when card is detected&lt;br /&gt;
|-&lt;br /&gt;
| Card-detect&lt;br /&gt;
| Physical insertion switch, readable through [[CONFIG9_Registers#CFG9_CARDSTATUS|CFG9_CARDSTATUS]] bit 0&lt;br /&gt;
| IRQ pin&lt;br /&gt;
|-&lt;br /&gt;
| Time to first clock pulse&lt;br /&gt;
| ~280ms&lt;br /&gt;
| ~166ms&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===SPI flash===&lt;br /&gt;
Savegame SPI flash transfers use CPOL=1 and CPHA=1. So far, only one savegame FLASH chip has been identified. The chip identifies as &amp;lt;tt&amp;gt;0xC22211&amp;lt;/tt&amp;gt;. The JEDEC manufacturer ID is Macronix, and despite the chip label saying 25L1001, the JEDEC ID matches the MX25L1021E. Datasheet at:&amp;lt;br&amp;gt;&lt;br /&gt;
[https://www.macronix.com/Lists/Datasheet/Attachments/8796/MX25L1021E,%203V,%201Mb,%20v1.3.pdf Macronix (Rev. 1.3, nov. 11, 2013)] &amp;lt;br&amp;gt;&lt;br /&gt;
[https://web.archive.org/web/20160307235354/http://www.beilenet.com/download/MX25L1021E,%203V,%201Mb,%20v0.01.pdf Old version mirror (Rev. 0.01, apr. 07, 2010)] &amp;lt;br&amp;gt;&lt;br /&gt;
However, the MX25L1021E doesn&#039;t support the 4 bit wide transmission that the 3DS uses to talk to the SPI flash. It is thus likely that this is a custom flash chip.&lt;br /&gt;
&lt;br /&gt;
===Format===&lt;br /&gt;
Cartridges can come in several sizes and include system updates in a region reserved for this. In ROMs less than 1GB the update region can be found with:&lt;br /&gt;
CART_SIZE_MAX-( 0x280000*(CART_SIZE_MAX/CART_SIZE_128MB) )-0x2000000. The region is then 0x2000000 bytes.&lt;br /&gt;
&lt;br /&gt;
===Protocol===&lt;br /&gt;
The communication protocol between the 3DS system and the 3DS gamecard has changed almost completely in comparison with the [http://problemkaputt.de/gbatek.htm#dscartridgeprotocol DS and DSi gamecard communication protocol].&lt;br /&gt;
&lt;br /&gt;
After the sixth transfer, commands change size from 8 bytes to 16 bytes. Possibly a new encryption is used, such as AES CTR.&lt;br /&gt;
When 16-byte commands are used, the data bus maintains the value 0x00 until the card signals it is ready by clocking a single byte 0x01, followed by the actual data. After each 0x200-byte block of actual data, a 4-byte standard CRC32 of the block data (before encryption, polynomial 0x82608edb and the final output is xored with 0xffffffff) follows.&lt;br /&gt;
&lt;br /&gt;
Here&#039;s a set of sample gamecard commands that a 3DS sends to a 3DS gamecard:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
!  Size&lt;br /&gt;
!  Command&lt;br /&gt;
!  Decrypted command&lt;br /&gt;
!  Description&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;tt&amp;gt;2000&amp;lt;/tt&amp;gt;&lt;br /&gt;
|&amp;lt;tt&amp;gt;9F00000000000000&amp;lt;/tt&amp;gt;&lt;br /&gt;
|?&lt;br /&gt;
|Reset&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;tt&amp;gt;0000&amp;lt;/tt&amp;gt;&lt;br /&gt;
|&amp;lt;tt&amp;gt;71C93FE9BB0A3B18&amp;lt;/tt&amp;gt;&lt;br /&gt;
|?&lt;br /&gt;
|Unknown&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;tt&amp;gt;0004&amp;lt;/tt&amp;gt;&lt;br /&gt;
|&amp;lt;tt&amp;gt;9000000000000000&amp;lt;/tt&amp;gt;&lt;br /&gt;
|?&lt;br /&gt;
|Get gamecard ID, response=9000FEC2&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;tt&amp;gt;0004&amp;lt;/tt&amp;gt;&lt;br /&gt;
|&amp;lt;tt&amp;gt;9000000000000000&amp;lt;/tt&amp;gt;&lt;br /&gt;
|?&lt;br /&gt;
| Get gamecard ID, response=9000FEC2&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;tt&amp;gt;0004&amp;lt;/tt&amp;gt;&lt;br /&gt;
|&amp;lt;tt&amp;gt;A000000000000000&amp;lt;/tt&amp;gt;&lt;br /&gt;
|?&lt;br /&gt;
| Unknown, response=00000000&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;tt&amp;gt;0000&amp;lt;/tt&amp;gt;&lt;br /&gt;
|&amp;lt;tt&amp;gt;3E00000000000000&amp;lt;/tt&amp;gt;&lt;br /&gt;
|?&lt;br /&gt;
| Enter 16-byte command mode.&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;tt&amp;gt;0200&amp;lt;/tt&amp;gt;&lt;br /&gt;
|&amp;lt;tt&amp;gt;82000000000000000000000000000000&amp;lt;/tt&amp;gt;&lt;br /&gt;
|?&lt;br /&gt;
| Get header&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;tt&amp;gt;0000&amp;lt;/tt&amp;gt;&lt;br /&gt;
|&amp;lt;tt&amp;gt;F32C92D85C9D44DED3E0E41DBE7C90D9&amp;lt;/tt&amp;gt;&lt;br /&gt;
|&amp;lt;tt&amp;gt;8300000000000000708DF1A731717D0B&amp;lt;/tt&amp;gt; &lt;br /&gt;
| Seed&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;tt&amp;gt;0004&amp;lt;/tt&amp;gt;&lt;br /&gt;
|&amp;lt;tt&amp;gt;696B9D8582FB55D31B68CAFE70C74A95&amp;lt;/tt&amp;gt;&lt;br /&gt;
|&amp;lt;tt&amp;gt;A200000000000000708DF1A731717D0B&amp;lt;/tt&amp;gt;&lt;br /&gt;
| Get secured gamecard ID, response=9000FEC2&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;tt&amp;gt;0004&amp;lt;/tt&amp;gt;&lt;br /&gt;
|&amp;lt;tt&amp;gt;BAA4812CA0AC9C5D19399530E3ACCCAB&amp;lt;/tt&amp;gt;&lt;br /&gt;
|&amp;lt;tt&amp;gt;A300000000000000708DF1A731717D0B&amp;lt;/tt&amp;gt;&lt;br /&gt;
| Unknown&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;tt&amp;gt;0000&amp;lt;/tt&amp;gt;&lt;br /&gt;
|&amp;lt;tt&amp;gt;178E427C22D87ADB86387249A97D321A&amp;lt;/tt&amp;gt;&lt;br /&gt;
|&amp;lt;tt&amp;gt;C500000000000000708DF1A731717D0B&amp;lt;/tt&amp;gt;&lt;br /&gt;
| Unknown&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;tt&amp;gt;0004&amp;lt;/tt&amp;gt;&lt;br /&gt;
|&amp;lt;tt&amp;gt;E06019B1BD5C9130ED6A4D9F4A9E7193&amp;lt;/tt&amp;gt;&lt;br /&gt;
|&amp;lt;tt&amp;gt;A200000000000000708DF1A731717D0B&amp;lt;/tt&amp;gt;&lt;br /&gt;
| Get secured gamecard ID, response=9000FEC2&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;tt&amp;gt;0004&amp;lt;/tt&amp;gt;&lt;br /&gt;
|&amp;lt;tt&amp;gt;4E0D224862523BBFE2E6255F80E15F37&amp;lt;/tt&amp;gt;&lt;br /&gt;
|&amp;lt;tt&amp;gt;A200000000000000708DF1A731717D0B&amp;lt;/tt&amp;gt;&lt;br /&gt;
| Get secured gamecard ID, response=9000FEC2&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;tt&amp;gt;0004&amp;lt;/tt&amp;gt;&lt;br /&gt;
|&amp;lt;tt&amp;gt;4CDF93D319FB62D0DB632A45E3E8D84C&amp;lt;/tt&amp;gt;&lt;br /&gt;
|&amp;lt;tt&amp;gt;A200000000000000708DF1A731717D0B&amp;lt;/tt&amp;gt;&lt;br /&gt;
| Get secured gamecard ID, response=9000FEC2&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;tt&amp;gt;0004&amp;lt;/tt&amp;gt;&lt;br /&gt;
|&amp;lt;tt&amp;gt;9AA5D80551002F955546D296A57F0FEF&amp;lt;/tt&amp;gt;&lt;br /&gt;
|&amp;lt;tt&amp;gt;A200000000000000708DF1A731717D0B&amp;lt;/tt&amp;gt;&lt;br /&gt;
| Get secured gamecard ID, response=9000FEC2&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;tt&amp;gt;0004&amp;lt;/tt&amp;gt;&lt;br /&gt;
|&amp;lt;tt&amp;gt;C12BA81AEF30DDDBD93FAD5D544C6334&amp;lt;/tt&amp;gt;&lt;br /&gt;
|&amp;lt;tt&amp;gt;A200000000000000708DF1A731717D0B&amp;lt;/tt&amp;gt;&lt;br /&gt;
| Get secured gamecard ID, response=9000FEC2&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;tt&amp;gt;0200&amp;lt;/tt&amp;gt;&lt;br /&gt;
|&amp;lt;tt&amp;gt;62EC5FB7F420AE1DC6253AE18AFA5BB3&amp;lt;/tt&amp;gt;&lt;br /&gt;
|&amp;lt;tt&amp;gt;BF000000000000000000000000000000&amp;lt;/tt&amp;gt;&lt;br /&gt;
| Read address 0&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;tt&amp;gt;0200&amp;lt;/tt&amp;gt;&lt;br /&gt;
|&amp;lt;tt&amp;gt;E3FA23AA016BE0C93430D1F42FF41324&amp;lt;/tt&amp;gt;&lt;br /&gt;
|&amp;lt;tt&amp;gt;BF000000000040000000000000000000&amp;lt;/tt&amp;gt;&lt;br /&gt;
| Read address 0x4000&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The header command has some initial dummy bytes, and eventually responds with a 0x200 byte header. Here&#039;s an example for Lego Starwars 3:&lt;br /&gt;
 0000000: 00 8c 03 00 00 00 04 00 00 00 00 00 00 00 00 00  ................&lt;br /&gt;
 0000010: b3 cf fb c6 6a b1 cb 20 32 af ce 35 d4 1c 74 c9  ....j.. 2..5..t.&lt;br /&gt;
 0000020: 8e 6b 27 2f 08 01 28 3b d4 30 de 44 37 f5 b0 46  .k&#039;/..(;.0.D7..F&lt;br /&gt;
 0000030: 91 59 d7 38 33 48 df 83 fd 71 84 2c 00 00 00 00  .Y.83H...q.,....&lt;br /&gt;
 0000040: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................&lt;br /&gt;
 0000050: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................&lt;br /&gt;
 0000060: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................&lt;br /&gt;
 0000070: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................&lt;br /&gt;
 0000080: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................&lt;br /&gt;
 0000090: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................&lt;br /&gt;
 00000a0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................&lt;br /&gt;
 00000b0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................&lt;br /&gt;
 00000c0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................&lt;br /&gt;
 00000d0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................&lt;br /&gt;
 00000e0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................&lt;br /&gt;
 00000f0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................&lt;br /&gt;
 0000100: 4e 43 43 48 7a 7f 0e 00 00 8c 03 00 00 00 04 00  NCCHz...........&lt;br /&gt;
 0000110: 36 34 02 00 00 00 00 00 00 8c 03 00 00 00 04 00  64..............&lt;br /&gt;
 0000120: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................&lt;br /&gt;
 0000130: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................&lt;br /&gt;
 0000140: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................&lt;br /&gt;
 0000150: 43 54 52 2d 50 2d 41 4c 47 50 00 00 00 00 00 00  CTR-P-ALGP......&lt;br /&gt;
 0000160: 0c 27 e3 c1 de 7b 2a e2 d3 11 4f 32 a4 ee bf 46  .&#039;...{*...O2...F&lt;br /&gt;
 0000170: 9a fd 0c f3 52 c1 1d 49 84 c2 a9 f1 d2 14 4c 63  ....R..I......Lc&lt;br /&gt;
 0000180: 00 04 00 00 00 00 00 00 00 00 00 00 01 03 00 00  ................&lt;br /&gt;
 0000190: 05 00 00 00 01 00 00 00 00 00 00 00 00 00 00 00  ................&lt;br /&gt;
 00001a0: 06 00 00 00 1c 0a 00 00 01 00 00 00 00 00 00 00  ................&lt;br /&gt;
 00001b0: 22 0a 00 00 58 75 0e 00 01 00 00 00 00 00 00 00  &amp;quot;...Xu..........&lt;br /&gt;
 00001c0: 13 0c 04 26 15 f6 47 c4 c6 32 25 ea 9e 67 f8 a2  ...&amp;amp;..G..2%..g..&lt;br /&gt;
 00001d0: 7b 15 24 6b 88 fb c7 a9 27 25 7b 84 97 7b 78 7b  {.$k....&#039;%{..{x{&lt;br /&gt;
 00001e0: a6 5b ee 10 60 bb 6a 68 21 bb ce c6 00 03 5b 7e  .[..`.jh!.....[~&lt;br /&gt;
 00001f0: 64 fb 6e ac a7 f0 96 0c fb 1f 5a 37 08 77 28 f7  d.n.......Z7.w(.&lt;/div&gt;</summary>
		<author><name>AriA99</name></author>
	</entry>
	<entry>
		<id>https://www.3dbrew.org/w/index.php?title=NIM_Services&amp;diff=19430</id>
		<title>NIM Services</title>
		<link rel="alternate" type="text/html" href="https://www.3dbrew.org/w/index.php?title=NIM_Services&amp;diff=19430"/>
		<updated>2017-01-27T18:48:14Z</updated>

		<summary type="html">&lt;p&gt;AriA99: /* NIM server service &amp;quot;nim:s&amp;quot; */ Fix cmd header for AccountDeleteTitleETicketsSOAP. This &amp;#039;&amp;#039;should&amp;#039;&amp;#039; be accurate but I am not sure. NIM sucks.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:Services]]&lt;br /&gt;
= NIM user service &amp;quot;nim:u&amp;quot; =&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
!  Command Header&lt;br /&gt;
!  Description&lt;br /&gt;
|-&lt;br /&gt;
| 0x00010000&lt;br /&gt;
| Related to starting a sysupdate?&lt;br /&gt;
|-&lt;br /&gt;
| 0x00020000&lt;br /&gt;
| [[NIMU:GetUpdateDownloadProgress|GetUpdateDownloadProgress]]&lt;br /&gt;
|-&lt;br /&gt;
| 0x0003....&lt;br /&gt;
| ?&lt;br /&gt;
|-&lt;br /&gt;
| 0x00040000&lt;br /&gt;
| [[NIMU:FinishTitlesInstall|FinishTitlesInstall]]&lt;br /&gt;
|-&lt;br /&gt;
| 0x00050000&lt;br /&gt;
| This obtains an event handle. Home Menu will check whether a system update is available when this event is triggered.&lt;br /&gt;
|-&lt;br /&gt;
| 0x0006....&lt;br /&gt;
| ?&lt;br /&gt;
|-&lt;br /&gt;
| 0x0007....&lt;br /&gt;
| ?&lt;br /&gt;
|-&lt;br /&gt;
| 0x0008....&lt;br /&gt;
| ?&lt;br /&gt;
|-&lt;br /&gt;
| 0x00090000&lt;br /&gt;
| [[NIMU:CheckSysupdateAvailable|CheckSysupdateAvailable]]&lt;br /&gt;
|-&lt;br /&gt;
| 0x000A0000&lt;br /&gt;
| GetState&lt;br /&gt;
|-&lt;br /&gt;
| 0x000B0000&lt;br /&gt;
| [[NIMU:GetSystemTitleHash|GetSystemTitleHash]]&lt;br /&gt;
|-&lt;br /&gt;
| 0x000C0082&lt;br /&gt;
| ?&lt;br /&gt;
|-&lt;br /&gt;
| 0x000E0080&lt;br /&gt;
| ?&lt;br /&gt;
|-&lt;br /&gt;
| 0x000F0042&lt;br /&gt;
| ?&lt;br /&gt;
|-&lt;br /&gt;
| 0x00110000&lt;br /&gt;
| ?&lt;br /&gt;
|-&lt;br /&gt;
| 0x00130000&lt;br /&gt;
| ?&lt;br /&gt;
|-&lt;br /&gt;
| 0x00140000&lt;br /&gt;
| ?&lt;br /&gt;
|-&lt;br /&gt;
| 0x00150000&lt;br /&gt;
| ?&lt;br /&gt;
|-&lt;br /&gt;
| 0x00170042&lt;br /&gt;
| ?&lt;br /&gt;
|-&lt;br /&gt;
| 0x00180080&lt;br /&gt;
| ?&lt;br /&gt;
|-&lt;br /&gt;
| 0x00250000&lt;br /&gt;
| ?&lt;br /&gt;
|-&lt;br /&gt;
| 0x00260200&lt;br /&gt;
| ?&lt;br /&gt;
|-&lt;br /&gt;
| 0x00270000&lt;br /&gt;
| ?&lt;br /&gt;
|-&lt;br /&gt;
| 0x00280000&lt;br /&gt;
| ?&lt;br /&gt;
|-&lt;br /&gt;
| 0x00290246&lt;br /&gt;
| ?&lt;br /&gt;
|-&lt;br /&gt;
| 0x002A0000&lt;br /&gt;
| ?&lt;br /&gt;
|-&lt;br /&gt;
| 0x002B0000&lt;br /&gt;
| ?&lt;br /&gt;
|-&lt;br /&gt;
| 0x002C0000&lt;br /&gt;
| ?&lt;br /&gt;
|-&lt;br /&gt;
| 0x002D00C0&lt;br /&gt;
| ?&lt;br /&gt;
|-&lt;br /&gt;
| 0x00480002&lt;br /&gt;
| ?&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= NIM server service &amp;quot;nim:s&amp;quot; =&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
!  Command Header&lt;br /&gt;
!  Description&lt;br /&gt;
|-&lt;br /&gt;
| 0x00010200&lt;br /&gt;
| [[NIMS:StartDownloadSimple|StartDownloadSimple]]&lt;br /&gt;
|-&lt;br /&gt;
| 0x00020000&lt;br /&gt;
| [[NIMS:CancelDownload|CancelDownload]]&lt;br /&gt;
|-&lt;br /&gt;
| 0x00030000&lt;br /&gt;
| [[NIMS:GetProgress|GetProgress]]&lt;br /&gt;
|-&lt;br /&gt;
| 0x00050082&lt;br /&gt;
| [[NIMS:UnregisterTask|UnregisterTask]]&lt;br /&gt;
|-&lt;br /&gt;
| 0x00060080&lt;br /&gt;
| [[NIMS:IsTaskRegistered|IsTaskRegistered]]&lt;br /&gt;
|-&lt;br /&gt;
| 0x000A0000&lt;br /&gt;
| [[NIMS:CheckSysupdateAvailableSOAP|CheckSysupdateAvailableSOAP]]&lt;br /&gt;
|-&lt;br /&gt;
| 0x000B0084&lt;br /&gt;
| [[NIMS:SetAttribute|SetAttribute]]&lt;br /&gt;
|-&lt;br /&gt;
| 0x0016020A&lt;br /&gt;
| [[NIMS:ListTitles|ListTitles]]&lt;br /&gt;
|-&lt;br /&gt;
| 0x00220080&lt;br /&gt;
| AccountDeleteTitleETicketsSOAP. The SOAP request is sent only after the ticket for the specified titleID has been successfully deleted.&lt;br /&gt;
|-&lt;br /&gt;
| 0x00290000&lt;br /&gt;
| [[NIMS:AccountCheckBalanceSOAP|AccountCheckBalanceSOAP]]&lt;br /&gt;
|-&lt;br /&gt;
| 0x002D0042&lt;br /&gt;
| [[NIMS:DownloadTickets|DownloadTickets]]&lt;br /&gt;
|-&lt;br /&gt;
| 0x003C0002&lt;br /&gt;
| [[NIMS:RegisterSelf|RegisterSelf]]&lt;br /&gt;
|-&lt;br /&gt;
| 0x003F0000&lt;br /&gt;
| GetInitializeResult. Checks whether nim is properly initialized or not. If it is not, the result code returned is non-zero.&lt;br /&gt;
|-&lt;br /&gt;
| 0x00420240&lt;br /&gt;
| [[NIMS:StartDownload|StartDownload]]&lt;br /&gt;
|-&lt;br /&gt;
| 0x00550246&lt;br /&gt;
| [[NIMS:RegisterTask|RegisterTask]]&lt;br /&gt;
|-&lt;br /&gt;
| 0x00570082&lt;br /&gt;
| [[NIMS:ConnectNoTicketDownload|ConnectNoTicketDownload]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= NIM server service &amp;quot;nim:aoc&amp;quot; =&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
!  Command Header&lt;br /&gt;
!  Description&lt;br /&gt;
|-&lt;br /&gt;
| 0x00030042&lt;br /&gt;
| SetApplicationId&lt;br /&gt;
|-&lt;br /&gt;
| 0x00040042&lt;br /&gt;
| SetTin&lt;br /&gt;
|-&lt;br /&gt;
| 0x000902D0&lt;br /&gt;
| ListContentSetsEx&lt;br /&gt;
|-&lt;br /&gt;
| 0x00180000&lt;br /&gt;
| GetBalance&lt;br /&gt;
|-&lt;br /&gt;
| 0x001D0000&lt;br /&gt;
| GetCustomerSupportCode&lt;br /&gt;
|-&lt;br /&gt;
| 0x00210000&lt;br /&gt;
| Initialize&lt;br /&gt;
|-&lt;br /&gt;
| 0x00240282&lt;br /&gt;
| CalculateContentsRequiredSize&lt;br /&gt;
|-&lt;br /&gt;
| 0x00250000&lt;br /&gt;
| RefreshServerTime&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= NIM service &amp;quot;nim:ndm&amp;quot; =&lt;br /&gt;
&lt;br /&gt;
= kagiya server =&lt;br /&gt;
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|eShop]].&lt;br /&gt;
&lt;br /&gt;
=New3DS=&lt;br /&gt;
NIM module only uses [[PTMSYSM:CheckNew3DS|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.&lt;br /&gt;
&lt;br /&gt;
=HTTPS requests=&lt;br /&gt;
&lt;br /&gt;
==Trusted RootCAs==&lt;br /&gt;
During startup NIM-module creates two RootCertChains with [[HTTP_Services|HTTPC]]. Both of these only contain the same [[HTTPC:RootCertChainAddDefaultCert|default]] cert with ID 0x3. The first RootCertChain is used with NetUpdateSOAP. Requests such as the &amp;quot;notifications.json&amp;quot; page don&#039;t use these RootCertChains(in this case just [[HTTPC:AddDefaultCert|default]] certID 0xB is used).&lt;br /&gt;
&lt;br /&gt;
==SOAP==&lt;br /&gt;
&lt;br /&gt;
===NetUpdateSOAP===&lt;br /&gt;
There are exactly 3 types of network SOAP requests used with [https://nus.c.shop.nintendowifi.net/nus/services/NetUpdateSOAP 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.&lt;br /&gt;
&lt;br /&gt;
See also [https://github.com/yellows8/ninupdates here].&lt;br /&gt;
&lt;br /&gt;
====GetSystemUpdate====&lt;br /&gt;
Returns the current sysupdate title-listing. This also contains the SystemTitleHash returned by GetSystemTitleHash.&lt;br /&gt;
&lt;br /&gt;
====GetSystemTitleHash====&lt;br /&gt;
Returns the current SystemTitleHash for the current sysupdate title-listing.&lt;br /&gt;
&lt;br /&gt;
====GetSystemCommonETicket====&lt;br /&gt;
Returns the Base64-encoded cetk for each specified TitleId entry.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
=Sysupdate checking process=&lt;br /&gt;
This section describes the process used when checking whether a sysupdate is required.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
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&#039;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.&lt;br /&gt;
&lt;br /&gt;
At least one &amp;lt;TitleVersion&amp;gt; entry with valid data in the GetSystemUpdate response is required.&lt;br /&gt;
&lt;br /&gt;
The titleIDs sent in the GetSystemUpdate SOAP request are decimal, while the titleIDs in the response are hex.&lt;br /&gt;
&lt;br /&gt;
=NIM [[System_SaveData]]=&lt;br /&gt;
==hash.dat==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
!  Offset&lt;br /&gt;
!  Size&lt;br /&gt;
!  Description&lt;br /&gt;
|-&lt;br /&gt;
| 0x60&lt;br /&gt;
| 0x1&lt;br /&gt;
| u8 flag used with the SystemTitleHash. 0x01 = latest sysupdate isn&#039;t installed as of last SOAP requests, 0x03 = latest sysupdate is installed as of last SOAP requests.&lt;br /&gt;
|-&lt;br /&gt;
| 0x61&lt;br /&gt;
| 0x21&lt;br /&gt;
| ASCII hex SystemTitleHash, including NUL-terminator. This is the latest SystemTitleHash which NIM module received from SOAP.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=Types=&lt;br /&gt;
==InstallationMode==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
!  Value&lt;br /&gt;
!  Description&lt;br /&gt;
|-&lt;br /&gt;
| 0&lt;br /&gt;
| Initial installation&lt;br /&gt;
|-&lt;br /&gt;
| 1&lt;br /&gt;
| Unknown&lt;br /&gt;
|-&lt;br /&gt;
| 2&lt;br /&gt;
| Unknown&lt;br /&gt;
|-&lt;br /&gt;
| 3&lt;br /&gt;
| Reinstallation&lt;br /&gt;
|}&lt;br /&gt;
==DownloadState==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
!  Value&lt;br /&gt;
!  Description&lt;br /&gt;
|-&lt;br /&gt;
| 0&lt;br /&gt;
| Not initialized&lt;br /&gt;
|-&lt;br /&gt;
| 1&lt;br /&gt;
| Download initialized&lt;br /&gt;
|-&lt;br /&gt;
| 2&lt;br /&gt;
| Downloading, verifying and installing TMD&lt;br /&gt;
|-&lt;br /&gt;
| 3&lt;br /&gt;
| Initializing save data&lt;br /&gt;
|-&lt;br /&gt;
| 4&lt;br /&gt;
| Downloading and installing contents&lt;br /&gt;
|-&lt;br /&gt;
| 5&lt;br /&gt;
| Waiting before calling [[AM:CommitImportPrograms]]&lt;br /&gt;
|-&lt;br /&gt;
| 6&lt;br /&gt;
| Running [[AM:CommitImportPrograms]]&lt;br /&gt;
|-&lt;br /&gt;
| 7&lt;br /&gt;
| Title installation finished&lt;br /&gt;
|-&lt;br /&gt;
| 8&lt;br /&gt;
| Unknown error regarding title version&lt;br /&gt;
|-&lt;br /&gt;
| 9&lt;br /&gt;
| Creating the .ctx file (or error doing so)?&lt;br /&gt;
|-&lt;br /&gt;
| 10&lt;br /&gt;
| Irrecoverable error encountered&lt;br /&gt;
|}&lt;br /&gt;
==TitleConfig==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
!  Offset&lt;br /&gt;
!  Length&lt;br /&gt;
!  Description&lt;br /&gt;
|-&lt;br /&gt;
| 0x0&lt;br /&gt;
| 0x8&lt;br /&gt;
| Title ID&lt;br /&gt;
|-&lt;br /&gt;
| 0x8&lt;br /&gt;
| 0x4&lt;br /&gt;
| Title version&lt;br /&gt;
|-&lt;br /&gt;
| 0xC&lt;br /&gt;
| 0x4&lt;br /&gt;
| Unknown (always 0)&lt;br /&gt;
|-&lt;br /&gt;
| 0x10&lt;br /&gt;
| 0x1&lt;br /&gt;
| Age rating for the HOME Menu parental controls&lt;br /&gt;
|-&lt;br /&gt;
| 0x11&lt;br /&gt;
| 0x1&lt;br /&gt;
| [[Filesystem_services#MediaType|Media Type]]&lt;br /&gt;
|-&lt;br /&gt;
| 0x12&lt;br /&gt;
| 0x2&lt;br /&gt;
| Padding&lt;br /&gt;
|-&lt;br /&gt;
| 0x14&lt;br /&gt;
| 0x4&lt;br /&gt;
| Unknown (always 0?)&lt;br /&gt;
|}&lt;br /&gt;
==TitleProgress==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
!  Offset&lt;br /&gt;
!  Length&lt;br /&gt;
!  Description&lt;br /&gt;
|-&lt;br /&gt;
| 0x0&lt;br /&gt;
| 0x4&lt;br /&gt;
| [[#DownloadState|Download State]]&lt;br /&gt;
|-&lt;br /&gt;
| 0x4&lt;br /&gt;
| 0x4&lt;br /&gt;
| Last result code in NIM related to the installation&lt;br /&gt;
|-&lt;br /&gt;
| 0x8&lt;br /&gt;
| 0x8&lt;br /&gt;
| Amount of bytes that have been downloaded&lt;br /&gt;
|-&lt;br /&gt;
| 0x10&lt;br /&gt;
| 0x8&lt;br /&gt;
| Total bytes that need to be downloaded&lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>AriA99</name></author>
	</entry>
	<entry>
		<id>https://www.3dbrew.org/w/index.php?title=NIMS:ConnectNoTicketDownload&amp;diff=19429</id>
		<title>NIMS:ConnectNoTicketDownload</title>
		<link rel="alternate" type="text/html" href="https://www.3dbrew.org/w/index.php?title=NIMS:ConnectNoTicketDownload&amp;diff=19429"/>
		<updated>2017-01-27T18:40:11Z</updated>

		<summary type="html">&lt;p&gt;AriA99: /* Description */ Add note why it&amp;#039;s called the way it&amp;#039;s called&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Request=&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
!  Index Word&lt;br /&gt;
!  Description&lt;br /&gt;
|-&lt;br /&gt;
| 0&lt;br /&gt;
| Header code [0x00570082]&lt;br /&gt;
|-&lt;br /&gt;
| 1&lt;br /&gt;
| Pointer to a buffer&lt;br /&gt;
|-&lt;br /&gt;
| 2&lt;br /&gt;
| Length of the buffer&lt;br /&gt;
|-&lt;br /&gt;
| 3&lt;br /&gt;
| {{Tooltip|Descriptor|0x0000000c {{!}} (size &amp;lt;nowiki&amp;gt;&amp;lt;&amp;lt;&amp;lt;/nowiki&amp;gt; 4)}} for mapping a [[IPC#Buffer_Mapping_Translation|write-only buffer]] in the target process&lt;br /&gt;
|-&lt;br /&gt;
| 4&lt;br /&gt;
| Pointer to a buffer (same as input word 1)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=Response=&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
!  Index Word&lt;br /&gt;
!  Description&lt;br /&gt;
|-&lt;br /&gt;
| 0&lt;br /&gt;
| Header code&lt;br /&gt;
|-&lt;br /&gt;
| 1&lt;br /&gt;
| Result code&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=Description=&lt;br /&gt;
Connects [[NIM_Services|NIM]] to the network for further use. This is &#039;&#039;required&#039;&#039; before any actual actions, such as [[NIMS:RegisterTask]] or [[NIMS:StartDownload]] can be taken.&lt;br /&gt;
&lt;br /&gt;
The buffer is a scratch buffer for nim. [[EShop|eShop]] provides a buffer of 0x20000 bytes.&lt;br /&gt;
&lt;br /&gt;
This command does not appear to affect tickets.&lt;/div&gt;</summary>
		<author><name>AriA99</name></author>
	</entry>
	<entry>
		<id>https://www.3dbrew.org/w/index.php?title=NIMS:ConnectNoTicketDownload&amp;diff=19428</id>
		<title>NIMS:ConnectNoTicketDownload</title>
		<link rel="alternate" type="text/html" href="https://www.3dbrew.org/w/index.php?title=NIMS:ConnectNoTicketDownload&amp;diff=19428"/>
		<updated>2017-01-27T18:39:16Z</updated>

		<summary type="html">&lt;p&gt;AriA99: Created page with &amp;quot;=Request= {| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot; |- !  Index Word !  Description |- | 0 | Header code [0x00570082] |- | 1 | Pointer to a buffer |- | 2 | Length of the buffer |- | 3 |...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Request=&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
!  Index Word&lt;br /&gt;
!  Description&lt;br /&gt;
|-&lt;br /&gt;
| 0&lt;br /&gt;
| Header code [0x00570082]&lt;br /&gt;
|-&lt;br /&gt;
| 1&lt;br /&gt;
| Pointer to a buffer&lt;br /&gt;
|-&lt;br /&gt;
| 2&lt;br /&gt;
| Length of the buffer&lt;br /&gt;
|-&lt;br /&gt;
| 3&lt;br /&gt;
| {{Tooltip|Descriptor|0x0000000c {{!}} (size &amp;lt;nowiki&amp;gt;&amp;lt;&amp;lt;&amp;lt;/nowiki&amp;gt; 4)}} for mapping a [[IPC#Buffer_Mapping_Translation|write-only buffer]] in the target process&lt;br /&gt;
|-&lt;br /&gt;
| 4&lt;br /&gt;
| Pointer to a buffer (same as input word 1)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=Response=&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
!  Index Word&lt;br /&gt;
!  Description&lt;br /&gt;
|-&lt;br /&gt;
| 0&lt;br /&gt;
| Header code&lt;br /&gt;
|-&lt;br /&gt;
| 1&lt;br /&gt;
| Result code&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=Description=&lt;br /&gt;
Connects [[NIM_Services|NIM]] to the network for further use. This is &#039;&#039;required&#039;&#039; before any actual actions, such as [[NIMS:RegisterTask]] or [[NIMS:StartDownload]] can be taken.&lt;br /&gt;
&lt;br /&gt;
The buffer is a scratch buffer for nim. [[EShop|eShop]] provides a buffer of 0x20000 bytes.&lt;/div&gt;</summary>
		<author><name>AriA99</name></author>
	</entry>
	<entry>
		<id>https://www.3dbrew.org/w/index.php?title=NIMS:RegisterSelf&amp;diff=19427</id>
		<title>NIMS:RegisterSelf</title>
		<link rel="alternate" type="text/html" href="https://www.3dbrew.org/w/index.php?title=NIMS:RegisterSelf&amp;diff=19427"/>
		<updated>2017-01-27T18:34:58Z</updated>

		<summary type="html">&lt;p&gt;AriA99: Created page with &amp;quot;=Request= {| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot; |- !  Index Word !  Description |- | 0 | Header code [0x003C0002] |- | 1 | {{Tooltip|Descriptor|0x20}} for IPC#Handle_Translation|p...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Request=&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
!  Index Word&lt;br /&gt;
!  Description&lt;br /&gt;
|-&lt;br /&gt;
| 0&lt;br /&gt;
| Header code [0x003C0002]&lt;br /&gt;
|-&lt;br /&gt;
| 1&lt;br /&gt;
| {{Tooltip|Descriptor|0x20}} for [[IPC#Handle_Translation|process ID]]&lt;br /&gt;
|-&lt;br /&gt;
| 2&lt;br /&gt;
| 0x10&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=Response=&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
!  Index Word&lt;br /&gt;
!  Description&lt;br /&gt;
|-&lt;br /&gt;
| 0&lt;br /&gt;
| Header code&lt;br /&gt;
|-&lt;br /&gt;
| 1&lt;br /&gt;
| Result code&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=Description=&lt;br /&gt;
Registers the current process with [[NIM_Services|NIM]]. This is &#039;&#039;required&#039;&#039; before any networking actions can be taken.&lt;/div&gt;</summary>
		<author><name>AriA99</name></author>
	</entry>
	<entry>
		<id>https://www.3dbrew.org/w/index.php?title=NIMS:SetAttribute&amp;diff=19426</id>
		<title>NIMS:SetAttribute</title>
		<link rel="alternate" type="text/html" href="https://www.3dbrew.org/w/index.php?title=NIMS:SetAttribute&amp;diff=19426"/>
		<updated>2017-01-27T18:31:01Z</updated>

		<summary type="html">&lt;p&gt;AriA99: Created page with &amp;quot;=Request= {| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot; |- !  Index Word !  Description |- | 0 | Header code [0x000B0084] |- | 1 | Length of the attribute to set (&amp;#039;&amp;#039;including&amp;#039;&amp;#039; trailing NUL...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Request=&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
!  Index Word&lt;br /&gt;
!  Description&lt;br /&gt;
|-&lt;br /&gt;
| 0&lt;br /&gt;
| Header code [0x000B0084]&lt;br /&gt;
|-&lt;br /&gt;
| 1&lt;br /&gt;
| Length of the attribute to set (&#039;&#039;including&#039;&#039; trailing NUL)&lt;br /&gt;
|-&lt;br /&gt;
| 2&lt;br /&gt;
| Length of the value to set (&#039;&#039;including&#039;&#039; trailing NUL if string)&lt;br /&gt;
|-&lt;br /&gt;
| 3&lt;br /&gt;
| {{Tooltip|Descriptor|0x00000002 {{!}} (size &amp;lt;nowiki&amp;gt;&amp;lt;&amp;lt;&amp;lt;/nowiki&amp;gt; 14) {{!}} (static_buffer_id &amp;lt;nowiki&amp;gt;&amp;lt;&amp;lt;&amp;lt;/nowiki&amp;gt; 10)}} for [[IPC#Static_Buffer_Translation|static buffer]] (id 0)&lt;br /&gt;
|-&lt;br /&gt;
| 4&lt;br /&gt;
| Pointer to the name of the attribute in ASCII to set&lt;br /&gt;
|-&lt;br /&gt;
| 5&lt;br /&gt;
| {{Tooltip|Descriptor|0x00000002 {{!}} (size &amp;lt;nowiki&amp;gt;&amp;lt;&amp;lt;&amp;lt;/nowiki&amp;gt; 14) {{!}} (static_buffer_id &amp;lt;nowiki&amp;gt;&amp;lt;&amp;lt;&amp;lt;/nowiki&amp;gt; 10)}} for [[IPC#Static_Buffer_Translation|static buffer]] (id 1)&lt;br /&gt;
|-&lt;br /&gt;
| 6&lt;br /&gt;
| Pointer to the value of the attribute to set&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=Response=&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
!  Index Word&lt;br /&gt;
!  Description&lt;br /&gt;
|-&lt;br /&gt;
| 0&lt;br /&gt;
| Header code&lt;br /&gt;
|-&lt;br /&gt;
| 1&lt;br /&gt;
| Result code&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=Description=&lt;br /&gt;
Sets an attribute. The name of the attribute appears to be an ASCII string. The types of the attributes &#039;&#039;may&#039;&#039; vary (research required, only ASCII strings observed).&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
!  Attribute&lt;br /&gt;
!  Value&lt;br /&gt;
|-&lt;br /&gt;
| TIN&lt;br /&gt;
| TIN (?). [[EShop|eShop]] sets this to (string!) &amp;quot;56789&amp;quot;.&lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>AriA99</name></author>
	</entry>
	<entry>
		<id>https://www.3dbrew.org/w/index.php?title=NIMS:IsTaskRegistered&amp;diff=19425</id>
		<title>NIMS:IsTaskRegistered</title>
		<link rel="alternate" type="text/html" href="https://www.3dbrew.org/w/index.php?title=NIMS:IsTaskRegistered&amp;diff=19425"/>
		<updated>2017-01-27T18:25:50Z</updated>

		<summary type="html">&lt;p&gt;AriA99: Created page with &amp;quot;=Request= {| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot; |- !  Index Word !  Description |- | 0 | Header code [0x00060080] |- | 1-2 | Title ID to query for |}  =Response= {| class=&amp;quot;wikitable...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Request=&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
!  Index Word&lt;br /&gt;
!  Description&lt;br /&gt;
|-&lt;br /&gt;
| 0&lt;br /&gt;
| Header code [0x00060080]&lt;br /&gt;
|-&lt;br /&gt;
| 1-2&lt;br /&gt;
| Title ID to query for&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=Response=&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
!  Index Word&lt;br /&gt;
!  Description&lt;br /&gt;
|-&lt;br /&gt;
| 0&lt;br /&gt;
| Header code&lt;br /&gt;
|-&lt;br /&gt;
| 1&lt;br /&gt;
| Result code&lt;br /&gt;
|-&lt;br /&gt;
| 2&lt;br /&gt;
| (u8) non-zero if there is a task for the given title ID&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=Description=&lt;br /&gt;
Checks whether there is a task registered with [[NIMS:RegisterTask]] for the given title ID.&lt;/div&gt;</summary>
		<author><name>AriA99</name></author>
	</entry>
	<entry>
		<id>https://www.3dbrew.org/w/index.php?title=NIMS:UnregisterTask&amp;diff=19424</id>
		<title>NIMS:UnregisterTask</title>
		<link rel="alternate" type="text/html" href="https://www.3dbrew.org/w/index.php?title=NIMS:UnregisterTask&amp;diff=19424"/>
		<updated>2017-01-27T18:24:21Z</updated>

		<summary type="html">&lt;p&gt;AriA99: Created page with &amp;quot;=Request= {| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot; |- !  Index Word !  Description |- | 0 | Header code [0x00050082] |- | 1-2 | Title ID of the title whose task to remove |- | 3 | {{To...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Request=&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
!  Index Word&lt;br /&gt;
!  Description&lt;br /&gt;
|-&lt;br /&gt;
| 0&lt;br /&gt;
| Header code [0x00050082]&lt;br /&gt;
|-&lt;br /&gt;
| 1-2&lt;br /&gt;
| Title ID of the title whose task to remove&lt;br /&gt;
|-&lt;br /&gt;
| 3&lt;br /&gt;
| {{Tooltip|Descriptor|0x20}} for [[IPC#Handle_Translation|process ID]]&lt;br /&gt;
|-&lt;br /&gt;
| 4&lt;br /&gt;
| Placeholder for process ID&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=Response=&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
!  Index Word&lt;br /&gt;
!  Description&lt;br /&gt;
|-&lt;br /&gt;
| 0&lt;br /&gt;
| Header code&lt;br /&gt;
|-&lt;br /&gt;
| 1&lt;br /&gt;
| Result code&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=Description=&lt;br /&gt;
Removes a task registered with [[NIMS:RegisterTask]].&lt;/div&gt;</summary>
		<author><name>AriA99</name></author>
	</entry>
	<entry>
		<id>https://www.3dbrew.org/w/index.php?title=NIMS:RegisterTask&amp;diff=19423</id>
		<title>NIMS:RegisterTask</title>
		<link rel="alternate" type="text/html" href="https://www.3dbrew.org/w/index.php?title=NIMS:RegisterTask&amp;diff=19423"/>
		<updated>2017-01-27T18:21:22Z</updated>

		<summary type="html">&lt;p&gt;AriA99: Remove duplicate &amp;quot;Descriptor&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Request=&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
!  Index Word&lt;br /&gt;
!  Description&lt;br /&gt;
|-&lt;br /&gt;
| 0&lt;br /&gt;
| Header code [0x00550246]&lt;br /&gt;
|-&lt;br /&gt;
| 1-6&lt;br /&gt;
| [[NIM_Services#TitleProgress|Title Progress]]&lt;br /&gt;
|-&lt;br /&gt;
| 7-8&lt;br /&gt;
| Unknown, not written by the system [[eShop]] application service command code *at* *all*.&lt;br /&gt;
|-&lt;br /&gt;
| 9&lt;br /&gt;
| Unknown, eShop always writes 0&lt;br /&gt;
|-&lt;br /&gt;
| 10&lt;br /&gt;
| {{Tooltip|Descriptor|0x20}} for [[IPC#Handle_Translation|process ID]]&lt;br /&gt;
|-&lt;br /&gt;
| 11&lt;br /&gt;
| Placeholder for process ID&lt;br /&gt;
|-&lt;br /&gt;
| 12&lt;br /&gt;
| {{Tooltip|Descriptor|0x00000002 {{!}} (size &amp;lt;nowiki&amp;gt;&amp;lt;&amp;lt;&amp;lt;/nowiki&amp;gt; 14) {{!}} (static_buffer_id &amp;lt;nowiki&amp;gt;&amp;lt;&amp;lt;&amp;lt;/nowiki&amp;gt; 10)}} for [[IPC#Static_Buffer_Translation|static buffer]] (id 1)&lt;br /&gt;
|-&lt;br /&gt;
| 13&lt;br /&gt;
| Pointer to the name of the title in UTF-16LE&lt;br /&gt;
|-&lt;br /&gt;
| 14&lt;br /&gt;
| {{Tooltip|Descriptor|0x00000002 {{!}} (size &amp;lt;nowiki&amp;gt;&amp;lt;&amp;lt;&amp;lt;/nowiki&amp;gt; 14) {{!}} (static_buffer_id &amp;lt;nowiki&amp;gt;&amp;lt;&amp;lt;&amp;lt;/nowiki&amp;gt; 10)}} for [[IPC#Static_Buffer_Translation|static buffer]] (id 5)&lt;br /&gt;
|-&lt;br /&gt;
| 15&lt;br /&gt;
| Pointer to the name of the developer of the title in UTF-16LE&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=Response=&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
!  Index Word&lt;br /&gt;
!  Description&lt;br /&gt;
|-&lt;br /&gt;
| 0&lt;br /&gt;
| Header code&lt;br /&gt;
|-&lt;br /&gt;
| 1&lt;br /&gt;
| Result code&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=Description=&lt;br /&gt;
Registers a task for sleep mode downloading. A glowing, wrapped package with the information from input words 13 and 15 will be shown on the [[Home_Menu|Home Menu]].&lt;/div&gt;</summary>
		<author><name>AriA99</name></author>
	</entry>
	<entry>
		<id>https://www.3dbrew.org/w/index.php?title=NIMS:RegisterTask&amp;diff=19422</id>
		<title>NIMS:RegisterTask</title>
		<link rel="alternate" type="text/html" href="https://www.3dbrew.org/w/index.php?title=NIMS:RegisterTask&amp;diff=19422"/>
		<updated>2017-01-27T18:20:39Z</updated>

		<summary type="html">&lt;p&gt;AriA99: Created page with &amp;quot;=Request= {| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot; |- !  Index Word !  Description |- | 0 | Header code [0x00550246] |- | 1-6 | Title Progress |- | 7-8 |...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Request=&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
!  Index Word&lt;br /&gt;
!  Description&lt;br /&gt;
|-&lt;br /&gt;
| 0&lt;br /&gt;
| Header code [0x00550246]&lt;br /&gt;
|-&lt;br /&gt;
| 1-6&lt;br /&gt;
| [[NIM_Services#TitleProgress|Title Progress]]&lt;br /&gt;
|-&lt;br /&gt;
| 7-8&lt;br /&gt;
| Unknown, not written by the system [[eShop]] application service command code *at* *all*.&lt;br /&gt;
|-&lt;br /&gt;
| 9&lt;br /&gt;
| Unknown, eShop always writes 0&lt;br /&gt;
|-&lt;br /&gt;
| 10&lt;br /&gt;
| Descriptor for {{Tooltip|Descriptor|0x20}} for [[IPC#Handle_Translation|process ID]]&lt;br /&gt;
|-&lt;br /&gt;
| 11&lt;br /&gt;
| Placeholder for process ID&lt;br /&gt;
|-&lt;br /&gt;
| 12&lt;br /&gt;
| {{Tooltip|Descriptor|0x00000002 {{!}} (size &amp;lt;nowiki&amp;gt;&amp;lt;&amp;lt;&amp;lt;/nowiki&amp;gt; 14) {{!}} (static_buffer_id &amp;lt;nowiki&amp;gt;&amp;lt;&amp;lt;&amp;lt;/nowiki&amp;gt; 10)}} for [[IPC#Static_Buffer_Translation|static buffer]] (id 1)&lt;br /&gt;
|-&lt;br /&gt;
| 13&lt;br /&gt;
| Pointer to the name of the title in UTF-16LE&lt;br /&gt;
|-&lt;br /&gt;
| 14&lt;br /&gt;
| {{Tooltip|Descriptor|0x00000002 {{!}} (size &amp;lt;nowiki&amp;gt;&amp;lt;&amp;lt;&amp;lt;/nowiki&amp;gt; 14) {{!}} (static_buffer_id &amp;lt;nowiki&amp;gt;&amp;lt;&amp;lt;&amp;lt;/nowiki&amp;gt; 10)}} for [[IPC#Static_Buffer_Translation|static buffer]] (id 5)&lt;br /&gt;
|-&lt;br /&gt;
| 15&lt;br /&gt;
| Pointer to the name of the developer of the title in UTF-16LE&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=Response=&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
!  Index Word&lt;br /&gt;
!  Description&lt;br /&gt;
|-&lt;br /&gt;
| 0&lt;br /&gt;
| Header code&lt;br /&gt;
|-&lt;br /&gt;
| 1&lt;br /&gt;
| Result code&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=Description=&lt;br /&gt;
Registers a task for sleep mode downloading. A glowing, wrapped package with the information from input words 13 and 15 will be shown on the [[Home_Menu|Home Menu]].&lt;/div&gt;</summary>
		<author><name>AriA99</name></author>
	</entry>
	<entry>
		<id>https://www.3dbrew.org/w/index.php?title=NIMS:GetProgress&amp;diff=19421</id>
		<title>NIMS:GetProgress</title>
		<link rel="alternate" type="text/html" href="https://www.3dbrew.org/w/index.php?title=NIMS:GetProgress&amp;diff=19421"/>
		<updated>2017-01-27T18:09:36Z</updated>

		<summary type="html">&lt;p&gt;AriA99: /* Description */ Fix description that was wrongly copied and pasted.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Request=&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
!  Index Word&lt;br /&gt;
!  Description&lt;br /&gt;
|-&lt;br /&gt;
| 0&lt;br /&gt;
| Header code [0x00030000]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=Response=&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
!  Index Word&lt;br /&gt;
!  Description&lt;br /&gt;
|-&lt;br /&gt;
| 0&lt;br /&gt;
| Header code&lt;br /&gt;
|-&lt;br /&gt;
| 1&lt;br /&gt;
| Result code&lt;br /&gt;
|-&lt;br /&gt;
| 2-7&lt;br /&gt;
| [[NIM_Services#TitleProgress|Title Progress]] struct&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=Description=&lt;br /&gt;
Gets information about the current [[NIM_Services|NIM]] download, which was started with [[NIMS:StartDownload]] or [[NIMS:StartDownloadSimple]].&lt;/div&gt;</summary>
		<author><name>AriA99</name></author>
	</entry>
	<entry>
		<id>https://www.3dbrew.org/w/index.php?title=NIMS:GetProgress&amp;diff=19420</id>
		<title>NIMS:GetProgress</title>
		<link rel="alternate" type="text/html" href="https://www.3dbrew.org/w/index.php?title=NIMS:GetProgress&amp;diff=19420"/>
		<updated>2017-01-27T18:09:05Z</updated>

		<summary type="html">&lt;p&gt;AriA99: Created page with &amp;quot;=Request= {| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot; |- !  Index Word !  Description |- | 0 | Header code [0x00030000] |}  =Response= {| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot; |- !  Index Word !...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Request=&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
!  Index Word&lt;br /&gt;
!  Description&lt;br /&gt;
|-&lt;br /&gt;
| 0&lt;br /&gt;
| Header code [0x00030000]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=Response=&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
!  Index Word&lt;br /&gt;
!  Description&lt;br /&gt;
|-&lt;br /&gt;
| 0&lt;br /&gt;
| Header code&lt;br /&gt;
|-&lt;br /&gt;
| 1&lt;br /&gt;
| Result code&lt;br /&gt;
|-&lt;br /&gt;
| 2-7&lt;br /&gt;
| [[NIM_Services#TitleProgress|Title Progress]] struct&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=Description=&lt;br /&gt;
This cancels downloading the current [[NIM_Services|NIM]] download, which was started with [[NIMS:StartDownload]] or [[NIMS:StartDownloadSimple]].&lt;/div&gt;</summary>
		<author><name>AriA99</name></author>
	</entry>
	<entry>
		<id>https://www.3dbrew.org/w/index.php?title=NIMS:CancelDownload&amp;diff=19419</id>
		<title>NIMS:CancelDownload</title>
		<link rel="alternate" type="text/html" href="https://www.3dbrew.org/w/index.php?title=NIMS:CancelDownload&amp;diff=19419"/>
		<updated>2017-01-27T18:07:32Z</updated>

		<summary type="html">&lt;p&gt;AriA99: Created page with &amp;quot;=Request= {| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot; |- !  Index Word !  Description |- | 0 | Header code [0x00020000] |}  =Response= {| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot; |- !  Index Word !...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Request=&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
!  Index Word&lt;br /&gt;
!  Description&lt;br /&gt;
|-&lt;br /&gt;
| 0&lt;br /&gt;
| Header code [0x00020000]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=Response=&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
!  Index Word&lt;br /&gt;
!  Description&lt;br /&gt;
|-&lt;br /&gt;
| 0&lt;br /&gt;
| Header code&lt;br /&gt;
|-&lt;br /&gt;
| 1&lt;br /&gt;
| Result code&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=Description=&lt;br /&gt;
This cancels downloading the current [[NIM_Services|NIM]] download, which was started with [[NIMS:StartDownload]] or [[NIMS:StartDownloadSimple]].&lt;/div&gt;</summary>
		<author><name>AriA99</name></author>
	</entry>
	<entry>
		<id>https://www.3dbrew.org/w/index.php?title=NIMS:StartDownloadSimple&amp;diff=19418</id>
		<title>NIMS:StartDownloadSimple</title>
		<link rel="alternate" type="text/html" href="https://www.3dbrew.org/w/index.php?title=NIMS:StartDownloadSimple&amp;diff=19418"/>
		<updated>2017-01-27T18:06:19Z</updated>

		<summary type="html">&lt;p&gt;AriA99: Fix header code.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Request=&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
!  Index Word&lt;br /&gt;
!  Description&lt;br /&gt;
|-&lt;br /&gt;
| 0&lt;br /&gt;
| Header code [0x00010200]&lt;br /&gt;
|-&lt;br /&gt;
| 1-6&lt;br /&gt;
| [[NIM_Services#TitleConfig|Title Config]]&lt;br /&gt;
|-&lt;br /&gt;
| 7-8&lt;br /&gt;
| Unknown, not written by the system [[eShop]] application service command code *at* *all*.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=Response=&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
!  Index Word&lt;br /&gt;
!  Description&lt;br /&gt;
|-&lt;br /&gt;
| 0&lt;br /&gt;
| Header code&lt;br /&gt;
|-&lt;br /&gt;
| 1&lt;br /&gt;
| Result code&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=Description=&lt;br /&gt;
This starts downloading the specified eShop title. The installation mode for [[NIMS:StartDownload]] appears to be automatically determined. See that page for further details.&lt;/div&gt;</summary>
		<author><name>AriA99</name></author>
	</entry>
	<entry>
		<id>https://www.3dbrew.org/w/index.php?title=NIMS:StartDownloadSimple&amp;diff=19417</id>
		<title>NIMS:StartDownloadSimple</title>
		<link rel="alternate" type="text/html" href="https://www.3dbrew.org/w/index.php?title=NIMS:StartDownloadSimple&amp;diff=19417"/>
		<updated>2017-01-27T18:05:41Z</updated>

		<summary type="html">&lt;p&gt;AriA99: Created page with &amp;quot;=Request= {| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot; |- !  Index Word !  Description |- | 0 | Header code [0x00420240] |- | 1-6 | Title Config |- | 7-8 | Unk...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Request=&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
!  Index Word&lt;br /&gt;
!  Description&lt;br /&gt;
|-&lt;br /&gt;
| 0&lt;br /&gt;
| Header code [0x00420240]&lt;br /&gt;
|-&lt;br /&gt;
| 1-6&lt;br /&gt;
| [[NIM_Services#TitleConfig|Title Config]]&lt;br /&gt;
|-&lt;br /&gt;
| 7-8&lt;br /&gt;
| Unknown, not written by the system [[eShop]] application service command code *at* *all*.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=Response=&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
!  Index Word&lt;br /&gt;
!  Description&lt;br /&gt;
|-&lt;br /&gt;
| 0&lt;br /&gt;
| Header code&lt;br /&gt;
|-&lt;br /&gt;
| 1&lt;br /&gt;
| Result code&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=Description=&lt;br /&gt;
This starts downloading the specified eShop title. The installation mode for [[NIMS:StartDownload]] appears to be automatically determined. See that page for further details.&lt;/div&gt;</summary>
		<author><name>AriA99</name></author>
	</entry>
	<entry>
		<id>https://www.3dbrew.org/w/index.php?title=NIMS:StartDownload&amp;diff=19416</id>
		<title>NIMS:StartDownload</title>
		<link rel="alternate" type="text/html" href="https://www.3dbrew.org/w/index.php?title=NIMS:StartDownload&amp;diff=19416"/>
		<updated>2017-01-27T18:02:38Z</updated>

		<summary type="html">&lt;p&gt;AriA99: Update with references to struct on NIM_Services and fill in missing u8.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Request=&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
!  Index Word&lt;br /&gt;
!  Description&lt;br /&gt;
|-&lt;br /&gt;
| 0&lt;br /&gt;
| Header code [0x00420240]&lt;br /&gt;
|-&lt;br /&gt;
| 1-6&lt;br /&gt;
| [[NIM_Services#TitleConfig|Title Config]]&lt;br /&gt;
|-&lt;br /&gt;
| 7-8&lt;br /&gt;
| Unknown, not written by the system [[eShop]] application service command code *at* *all*.&lt;br /&gt;
|-&lt;br /&gt;
| 9&lt;br /&gt;
| [[NIM_Services#InstallationMode|Installation Mode]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=Response=&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
!  Index Word&lt;br /&gt;
!  Description&lt;br /&gt;
|-&lt;br /&gt;
| 0&lt;br /&gt;
| Header code&lt;br /&gt;
|-&lt;br /&gt;
| 1&lt;br /&gt;
| Result code&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=Description=&lt;br /&gt;
This starts downloading the specified eShop title in the given mode.&lt;br /&gt;
&lt;br /&gt;
[[NIMS:GetProgress]] may be used to monitor the progress of installation. To abort the current download, see [[NIMS:CancelDownload]].&lt;/div&gt;</summary>
		<author><name>AriA99</name></author>
	</entry>
	<entry>
		<id>https://www.3dbrew.org/w/index.php?title=NIM_Services&amp;diff=19415</id>
		<title>NIM Services</title>
		<link rel="alternate" type="text/html" href="https://www.3dbrew.org/w/index.php?title=NIM_Services&amp;diff=19415"/>
		<updated>2017-01-27T17:56:15Z</updated>

		<summary type="html">&lt;p&gt;AriA99: /* NIM server service &amp;quot;nim:s&amp;quot; */ Add stubs for filling in individual commands.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:Services]]&lt;br /&gt;
= NIM user service &amp;quot;nim:u&amp;quot; =&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
!  Command Header&lt;br /&gt;
!  Description&lt;br /&gt;
|-&lt;br /&gt;
| 0x00010000&lt;br /&gt;
| Related to starting a sysupdate?&lt;br /&gt;
|-&lt;br /&gt;
| 0x00020000&lt;br /&gt;
| [[NIMU:GetUpdateDownloadProgress|GetUpdateDownloadProgress]]&lt;br /&gt;
|-&lt;br /&gt;
| 0x0003....&lt;br /&gt;
| ?&lt;br /&gt;
|-&lt;br /&gt;
| 0x00040000&lt;br /&gt;
| [[NIMU:FinishTitlesInstall|FinishTitlesInstall]]&lt;br /&gt;
|-&lt;br /&gt;
| 0x00050000&lt;br /&gt;
| This obtains an event handle. Home Menu will check whether a system update is available when this event is triggered.&lt;br /&gt;
|-&lt;br /&gt;
| 0x0006....&lt;br /&gt;
| ?&lt;br /&gt;
|-&lt;br /&gt;
| 0x0007....&lt;br /&gt;
| ?&lt;br /&gt;
|-&lt;br /&gt;
| 0x0008....&lt;br /&gt;
| ?&lt;br /&gt;
|-&lt;br /&gt;
| 0x00090000&lt;br /&gt;
| [[NIMU:CheckSysupdateAvailable|CheckSysupdateAvailable]]&lt;br /&gt;
|-&lt;br /&gt;
| 0x000A0000&lt;br /&gt;
| GetState&lt;br /&gt;
|-&lt;br /&gt;
| 0x000B0000&lt;br /&gt;
| [[NIMU:GetSystemTitleHash|GetSystemTitleHash]]&lt;br /&gt;
|-&lt;br /&gt;
| 0x000C0082&lt;br /&gt;
| ?&lt;br /&gt;
|-&lt;br /&gt;
| 0x000E0080&lt;br /&gt;
| ?&lt;br /&gt;
|-&lt;br /&gt;
| 0x000F0042&lt;br /&gt;
| ?&lt;br /&gt;
|-&lt;br /&gt;
| 0x00110000&lt;br /&gt;
| ?&lt;br /&gt;
|-&lt;br /&gt;
| 0x00130000&lt;br /&gt;
| ?&lt;br /&gt;
|-&lt;br /&gt;
| 0x00140000&lt;br /&gt;
| ?&lt;br /&gt;
|-&lt;br /&gt;
| 0x00150000&lt;br /&gt;
| ?&lt;br /&gt;
|-&lt;br /&gt;
| 0x00170042&lt;br /&gt;
| ?&lt;br /&gt;
|-&lt;br /&gt;
| 0x00180080&lt;br /&gt;
| ?&lt;br /&gt;
|-&lt;br /&gt;
| 0x00250000&lt;br /&gt;
| ?&lt;br /&gt;
|-&lt;br /&gt;
| 0x00260200&lt;br /&gt;
| ?&lt;br /&gt;
|-&lt;br /&gt;
| 0x00270000&lt;br /&gt;
| ?&lt;br /&gt;
|-&lt;br /&gt;
| 0x00280000&lt;br /&gt;
| ?&lt;br /&gt;
|-&lt;br /&gt;
| 0x00290246&lt;br /&gt;
| ?&lt;br /&gt;
|-&lt;br /&gt;
| 0x002A0000&lt;br /&gt;
| ?&lt;br /&gt;
|-&lt;br /&gt;
| 0x002B0000&lt;br /&gt;
| ?&lt;br /&gt;
|-&lt;br /&gt;
| 0x002C0000&lt;br /&gt;
| ?&lt;br /&gt;
|-&lt;br /&gt;
| 0x002D00C0&lt;br /&gt;
| ?&lt;br /&gt;
|-&lt;br /&gt;
| 0x00480002&lt;br /&gt;
| ?&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= NIM server service &amp;quot;nim:s&amp;quot; =&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
!  Command Header&lt;br /&gt;
!  Description&lt;br /&gt;
|-&lt;br /&gt;
| 0x00010200&lt;br /&gt;
| [[NIMS:StartDownloadSimple|StartDownloadSimple]]&lt;br /&gt;
|-&lt;br /&gt;
| 0x00020000&lt;br /&gt;
| [[NIMS:CancelDownload|CancelDownload]]&lt;br /&gt;
|-&lt;br /&gt;
| 0x00030000&lt;br /&gt;
| [[NIMS:GetProgress|GetProgress]]&lt;br /&gt;
|-&lt;br /&gt;
| 0x00050082&lt;br /&gt;
| [[NIMS:UnregisterTask|UnregisterTask]]&lt;br /&gt;
|-&lt;br /&gt;
| 0x00060080&lt;br /&gt;
| [[NIMS:IsTaskRegistered|IsTaskRegistered]]&lt;br /&gt;
|-&lt;br /&gt;
| 0x000A0000&lt;br /&gt;
| [[NIMS:CheckSysupdateAvailableSOAP|CheckSysupdateAvailableSOAP]]&lt;br /&gt;
|-&lt;br /&gt;
| 0x000B0084&lt;br /&gt;
| [[NIMS:SetAttribute|SetAttribute]]&lt;br /&gt;
|-&lt;br /&gt;
| 0x0016020A&lt;br /&gt;
| [[NIMS:ListTitles|ListTitles]]&lt;br /&gt;
|-&lt;br /&gt;
| 0x0022....&lt;br /&gt;
| AccountDeleteTitleETicketsSOAP. The SOAP request is sent only after the ticket for the specified titleID has been successfully deleted.&lt;br /&gt;
|-&lt;br /&gt;
| 0x00290000&lt;br /&gt;
| [[NIMS:AccountCheckBalanceSOAP|AccountCheckBalanceSOAP]]&lt;br /&gt;
|-&lt;br /&gt;
| 0x002D0042&lt;br /&gt;
| [[NIMS:DownloadTickets|DownloadTickets]]&lt;br /&gt;
|-&lt;br /&gt;
| 0x003C0002&lt;br /&gt;
| [[NIMS:RegisterSelf|RegisterSelf]]&lt;br /&gt;
|-&lt;br /&gt;
| 0x003F0000&lt;br /&gt;
| GetInitializeResult. Checks whether nim is properly initialized or not. If it is not, the result code returned is non-zero.&lt;br /&gt;
|-&lt;br /&gt;
| 0x00420240&lt;br /&gt;
| [[NIMS:StartDownload|StartDownload]]&lt;br /&gt;
|-&lt;br /&gt;
| 0x00550246&lt;br /&gt;
| [[NIMS:RegisterTask|RegisterTask]]&lt;br /&gt;
|-&lt;br /&gt;
| 0x00570082&lt;br /&gt;
| [[NIMS:ConnectNoTicketDownload|ConnectNoTicketDownload]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= NIM server service &amp;quot;nim:aoc&amp;quot; =&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
!  Command Header&lt;br /&gt;
!  Description&lt;br /&gt;
|-&lt;br /&gt;
| 0x00030042&lt;br /&gt;
| SetApplicationId&lt;br /&gt;
|-&lt;br /&gt;
| 0x00040042&lt;br /&gt;
| SetTin&lt;br /&gt;
|-&lt;br /&gt;
| 0x000902D0&lt;br /&gt;
| ListContentSetsEx&lt;br /&gt;
|-&lt;br /&gt;
| 0x00180000&lt;br /&gt;
| GetBalance&lt;br /&gt;
|-&lt;br /&gt;
| 0x001D0000&lt;br /&gt;
| GetCustomerSupportCode&lt;br /&gt;
|-&lt;br /&gt;
| 0x00210000&lt;br /&gt;
| Initialize&lt;br /&gt;
|-&lt;br /&gt;
| 0x00240282&lt;br /&gt;
| CalculateContentsRequiredSize&lt;br /&gt;
|-&lt;br /&gt;
| 0x00250000&lt;br /&gt;
| RefreshServerTime&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= NIM service &amp;quot;nim:ndm&amp;quot; =&lt;br /&gt;
&lt;br /&gt;
= kagiya server =&lt;br /&gt;
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|eShop]].&lt;br /&gt;
&lt;br /&gt;
=New3DS=&lt;br /&gt;
NIM module only uses [[PTMSYSM:CheckNew3DS|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.&lt;br /&gt;
&lt;br /&gt;
=HTTPS requests=&lt;br /&gt;
&lt;br /&gt;
==Trusted RootCAs==&lt;br /&gt;
During startup NIM-module creates two RootCertChains with [[HTTP_Services|HTTPC]]. Both of these only contain the same [[HTTPC:RootCertChainAddDefaultCert|default]] cert with ID 0x3. The first RootCertChain is used with NetUpdateSOAP. Requests such as the &amp;quot;notifications.json&amp;quot; page don&#039;t use these RootCertChains(in this case just [[HTTPC:AddDefaultCert|default]] certID 0xB is used).&lt;br /&gt;
&lt;br /&gt;
==SOAP==&lt;br /&gt;
&lt;br /&gt;
===NetUpdateSOAP===&lt;br /&gt;
There are exactly 3 types of network SOAP requests used with [https://nus.c.shop.nintendowifi.net/nus/services/NetUpdateSOAP 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.&lt;br /&gt;
&lt;br /&gt;
See also [https://github.com/yellows8/ninupdates here].&lt;br /&gt;
&lt;br /&gt;
====GetSystemUpdate====&lt;br /&gt;
Returns the current sysupdate title-listing. This also contains the SystemTitleHash returned by GetSystemTitleHash.&lt;br /&gt;
&lt;br /&gt;
====GetSystemTitleHash====&lt;br /&gt;
Returns the current SystemTitleHash for the current sysupdate title-listing.&lt;br /&gt;
&lt;br /&gt;
====GetSystemCommonETicket====&lt;br /&gt;
Returns the Base64-encoded cetk for each specified TitleId entry.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
=Sysupdate checking process=&lt;br /&gt;
This section describes the process used when checking whether a sysupdate is required.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
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&#039;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.&lt;br /&gt;
&lt;br /&gt;
At least one &amp;lt;TitleVersion&amp;gt; entry with valid data in the GetSystemUpdate response is required.&lt;br /&gt;
&lt;br /&gt;
The titleIDs sent in the GetSystemUpdate SOAP request are decimal, while the titleIDs in the response are hex.&lt;br /&gt;
&lt;br /&gt;
=NIM [[System_SaveData]]=&lt;br /&gt;
==hash.dat==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
!  Offset&lt;br /&gt;
!  Size&lt;br /&gt;
!  Description&lt;br /&gt;
|-&lt;br /&gt;
| 0x60&lt;br /&gt;
| 0x1&lt;br /&gt;
| u8 flag used with the SystemTitleHash. 0x01 = latest sysupdate isn&#039;t installed as of last SOAP requests, 0x03 = latest sysupdate is installed as of last SOAP requests.&lt;br /&gt;
|-&lt;br /&gt;
| 0x61&lt;br /&gt;
| 0x21&lt;br /&gt;
| ASCII hex SystemTitleHash, including NUL-terminator. This is the latest SystemTitleHash which NIM module received from SOAP.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=Types=&lt;br /&gt;
==InstallationMode==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
!  Value&lt;br /&gt;
!  Description&lt;br /&gt;
|-&lt;br /&gt;
| 0&lt;br /&gt;
| Initial installation&lt;br /&gt;
|-&lt;br /&gt;
| 1&lt;br /&gt;
| Unknown&lt;br /&gt;
|-&lt;br /&gt;
| 2&lt;br /&gt;
| Unknown&lt;br /&gt;
|-&lt;br /&gt;
| 3&lt;br /&gt;
| Reinstallation&lt;br /&gt;
|}&lt;br /&gt;
==DownloadState==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
!  Value&lt;br /&gt;
!  Description&lt;br /&gt;
|-&lt;br /&gt;
| 0&lt;br /&gt;
| Not initialized&lt;br /&gt;
|-&lt;br /&gt;
| 1&lt;br /&gt;
| Download initialized&lt;br /&gt;
|-&lt;br /&gt;
| 2&lt;br /&gt;
| Downloading, verifying and installing TMD&lt;br /&gt;
|-&lt;br /&gt;
| 3&lt;br /&gt;
| Initializing save data&lt;br /&gt;
|-&lt;br /&gt;
| 4&lt;br /&gt;
| Downloading and installing contents&lt;br /&gt;
|-&lt;br /&gt;
| 5&lt;br /&gt;
| Waiting before calling [[AM:CommitImportPrograms]]&lt;br /&gt;
|-&lt;br /&gt;
| 6&lt;br /&gt;
| Running [[AM:CommitImportPrograms]]&lt;br /&gt;
|-&lt;br /&gt;
| 7&lt;br /&gt;
| Title installation finished&lt;br /&gt;
|-&lt;br /&gt;
| 8&lt;br /&gt;
| Unknown error regarding title version&lt;br /&gt;
|-&lt;br /&gt;
| 9&lt;br /&gt;
| Creating the .ctx file (or error doing so)?&lt;br /&gt;
|-&lt;br /&gt;
| 10&lt;br /&gt;
| Irrecoverable error encountered&lt;br /&gt;
|}&lt;br /&gt;
==TitleConfig==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
!  Offset&lt;br /&gt;
!  Length&lt;br /&gt;
!  Description&lt;br /&gt;
|-&lt;br /&gt;
| 0x0&lt;br /&gt;
| 0x8&lt;br /&gt;
| Title ID&lt;br /&gt;
|-&lt;br /&gt;
| 0x8&lt;br /&gt;
| 0x4&lt;br /&gt;
| Title version&lt;br /&gt;
|-&lt;br /&gt;
| 0xC&lt;br /&gt;
| 0x4&lt;br /&gt;
| Unknown (always 0)&lt;br /&gt;
|-&lt;br /&gt;
| 0x10&lt;br /&gt;
| 0x1&lt;br /&gt;
| Age rating for the HOME Menu parental controls&lt;br /&gt;
|-&lt;br /&gt;
| 0x11&lt;br /&gt;
| 0x1&lt;br /&gt;
| [[Filesystem_services#MediaType|Media Type]]&lt;br /&gt;
|-&lt;br /&gt;
| 0x12&lt;br /&gt;
| 0x2&lt;br /&gt;
| Padding&lt;br /&gt;
|-&lt;br /&gt;
| 0x14&lt;br /&gt;
| 0x4&lt;br /&gt;
| Unknown (always 0?)&lt;br /&gt;
|}&lt;br /&gt;
==TitleProgress==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
!  Offset&lt;br /&gt;
!  Length&lt;br /&gt;
!  Description&lt;br /&gt;
|-&lt;br /&gt;
| 0x0&lt;br /&gt;
| 0x4&lt;br /&gt;
| [[#DownloadState|Download State]]&lt;br /&gt;
|-&lt;br /&gt;
| 0x4&lt;br /&gt;
| 0x4&lt;br /&gt;
| Last result code in NIM related to the installation&lt;br /&gt;
|-&lt;br /&gt;
| 0x8&lt;br /&gt;
| 0x8&lt;br /&gt;
| Amount of bytes that have been downloaded&lt;br /&gt;
|-&lt;br /&gt;
| 0x10&lt;br /&gt;
| 0x8&lt;br /&gt;
| Total bytes that need to be downloaded&lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>AriA99</name></author>
	</entry>
	<entry>
		<id>https://www.3dbrew.org/w/index.php?title=NIM_Services&amp;diff=19414</id>
		<title>NIM Services</title>
		<link rel="alternate" type="text/html" href="https://www.3dbrew.org/w/index.php?title=NIM_Services&amp;diff=19414"/>
		<updated>2017-01-27T17:44:54Z</updated>

		<summary type="html">&lt;p&gt;AriA99: Update the page with structs.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:Services]]&lt;br /&gt;
= NIM user service &amp;quot;nim:u&amp;quot; =&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
!  Command Header&lt;br /&gt;
!  Description&lt;br /&gt;
|-&lt;br /&gt;
| 0x00010000&lt;br /&gt;
| Related to starting a sysupdate?&lt;br /&gt;
|-&lt;br /&gt;
| 0x00020000&lt;br /&gt;
| [[NIMU:GetUpdateDownloadProgress|GetUpdateDownloadProgress]]&lt;br /&gt;
|-&lt;br /&gt;
| 0x0003....&lt;br /&gt;
| ?&lt;br /&gt;
|-&lt;br /&gt;
| 0x00040000&lt;br /&gt;
| [[NIMU:FinishTitlesInstall|FinishTitlesInstall]]&lt;br /&gt;
|-&lt;br /&gt;
| 0x00050000&lt;br /&gt;
| This obtains an event handle. Home Menu will check whether a system update is available when this event is triggered.&lt;br /&gt;
|-&lt;br /&gt;
| 0x0006....&lt;br /&gt;
| ?&lt;br /&gt;
|-&lt;br /&gt;
| 0x0007....&lt;br /&gt;
| ?&lt;br /&gt;
|-&lt;br /&gt;
| 0x0008....&lt;br /&gt;
| ?&lt;br /&gt;
|-&lt;br /&gt;
| 0x00090000&lt;br /&gt;
| [[NIMU:CheckSysupdateAvailable|CheckSysupdateAvailable]]&lt;br /&gt;
|-&lt;br /&gt;
| 0x000A0000&lt;br /&gt;
| GetState&lt;br /&gt;
|-&lt;br /&gt;
| 0x000B0000&lt;br /&gt;
| [[NIMU:GetSystemTitleHash|GetSystemTitleHash]]&lt;br /&gt;
|-&lt;br /&gt;
| 0x000C0082&lt;br /&gt;
| ?&lt;br /&gt;
|-&lt;br /&gt;
| 0x000E0080&lt;br /&gt;
| ?&lt;br /&gt;
|-&lt;br /&gt;
| 0x000F0042&lt;br /&gt;
| ?&lt;br /&gt;
|-&lt;br /&gt;
| 0x00110000&lt;br /&gt;
| ?&lt;br /&gt;
|-&lt;br /&gt;
| 0x00130000&lt;br /&gt;
| ?&lt;br /&gt;
|-&lt;br /&gt;
| 0x00140000&lt;br /&gt;
| ?&lt;br /&gt;
|-&lt;br /&gt;
| 0x00150000&lt;br /&gt;
| ?&lt;br /&gt;
|-&lt;br /&gt;
| 0x00170042&lt;br /&gt;
| ?&lt;br /&gt;
|-&lt;br /&gt;
| 0x00180080&lt;br /&gt;
| ?&lt;br /&gt;
|-&lt;br /&gt;
| 0x00250000&lt;br /&gt;
| ?&lt;br /&gt;
|-&lt;br /&gt;
| 0x00260200&lt;br /&gt;
| ?&lt;br /&gt;
|-&lt;br /&gt;
| 0x00270000&lt;br /&gt;
| ?&lt;br /&gt;
|-&lt;br /&gt;
| 0x00280000&lt;br /&gt;
| ?&lt;br /&gt;
|-&lt;br /&gt;
| 0x00290246&lt;br /&gt;
| ?&lt;br /&gt;
|-&lt;br /&gt;
| 0x002A0000&lt;br /&gt;
| ?&lt;br /&gt;
|-&lt;br /&gt;
| 0x002B0000&lt;br /&gt;
| ?&lt;br /&gt;
|-&lt;br /&gt;
| 0x002C0000&lt;br /&gt;
| ?&lt;br /&gt;
|-&lt;br /&gt;
| 0x002D00C0&lt;br /&gt;
| ?&lt;br /&gt;
|-&lt;br /&gt;
| 0x00480002&lt;br /&gt;
| ?&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= NIM server service &amp;quot;nim:s&amp;quot; =&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
!  Command Header&lt;br /&gt;
!  Description&lt;br /&gt;
|-&lt;br /&gt;
| 0x00060080&lt;br /&gt;
| The input at cmdreq[1-2] is an u64 titleID. This writes an u8 to cmdreply[2]. It&#039;s unknown what exactly the [[eShop]] application uses this for, it only uses this command for apps which are installed(checked via [[Application_Manager_Services|AM]] probably). In those cases, it seems the outval for this command(with result-code=0) is normally 0?&lt;br /&gt;
|-&lt;br /&gt;
| 0x000A0000&lt;br /&gt;
| [[NIMS:CheckSysupdateAvailableSOAP|CheckSysupdateAvailableSOAP]]&lt;br /&gt;
|-&lt;br /&gt;
| 0x0016020A&lt;br /&gt;
| [[NIMS:ListTitles|ListTitles]]&lt;br /&gt;
|-&lt;br /&gt;
| 0x0022....&lt;br /&gt;
| AccountDeleteTitleETicketsSOAP. The SOAP request is sent only after the ticket for the specified titleID has been successfully deleted.&lt;br /&gt;
|-&lt;br /&gt;
| 0x00290000&lt;br /&gt;
| [[NIMS:AccountCheckBalanceSOAP|AccountCheckBalanceSOAP]]&lt;br /&gt;
|-&lt;br /&gt;
| 0x002D0042&lt;br /&gt;
| [[NIMS:DownloadTickets|DownloadTickets]]&lt;br /&gt;
|-&lt;br /&gt;
| 0x00420240&lt;br /&gt;
| [[NIMS:StartDownload|StartDownload]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= NIM server service &amp;quot;nim:aoc&amp;quot; =&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
!  Command Header&lt;br /&gt;
!  Description&lt;br /&gt;
|-&lt;br /&gt;
| 0x00030042&lt;br /&gt;
| SetApplicationId&lt;br /&gt;
|-&lt;br /&gt;
| 0x00040042&lt;br /&gt;
| SetTin&lt;br /&gt;
|-&lt;br /&gt;
| 0x000902D0&lt;br /&gt;
| ListContentSetsEx&lt;br /&gt;
|-&lt;br /&gt;
| 0x00180000&lt;br /&gt;
| GetBalance&lt;br /&gt;
|-&lt;br /&gt;
| 0x001D0000&lt;br /&gt;
| GetCustomerSupportCode&lt;br /&gt;
|-&lt;br /&gt;
| 0x00210000&lt;br /&gt;
| Initialize&lt;br /&gt;
|-&lt;br /&gt;
| 0x00240282&lt;br /&gt;
| CalculateContentsRequiredSize&lt;br /&gt;
|-&lt;br /&gt;
| 0x00250000&lt;br /&gt;
| RefreshServerTime&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= NIM service &amp;quot;nim:ndm&amp;quot; =&lt;br /&gt;
&lt;br /&gt;
= kagiya server =&lt;br /&gt;
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|eShop]].&lt;br /&gt;
&lt;br /&gt;
=New3DS=&lt;br /&gt;
NIM module only uses [[PTMSYSM:CheckNew3DS|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.&lt;br /&gt;
&lt;br /&gt;
=HTTPS requests=&lt;br /&gt;
&lt;br /&gt;
==Trusted RootCAs==&lt;br /&gt;
During startup NIM-module creates two RootCertChains with [[HTTP_Services|HTTPC]]. Both of these only contain the same [[HTTPC:RootCertChainAddDefaultCert|default]] cert with ID 0x3. The first RootCertChain is used with NetUpdateSOAP. Requests such as the &amp;quot;notifications.json&amp;quot; page don&#039;t use these RootCertChains(in this case just [[HTTPC:AddDefaultCert|default]] certID 0xB is used).&lt;br /&gt;
&lt;br /&gt;
==SOAP==&lt;br /&gt;
&lt;br /&gt;
===NetUpdateSOAP===&lt;br /&gt;
There are exactly 3 types of network SOAP requests used with [https://nus.c.shop.nintendowifi.net/nus/services/NetUpdateSOAP 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.&lt;br /&gt;
&lt;br /&gt;
See also [https://github.com/yellows8/ninupdates here].&lt;br /&gt;
&lt;br /&gt;
====GetSystemUpdate====&lt;br /&gt;
Returns the current sysupdate title-listing. This also contains the SystemTitleHash returned by GetSystemTitleHash.&lt;br /&gt;
&lt;br /&gt;
====GetSystemTitleHash====&lt;br /&gt;
Returns the current SystemTitleHash for the current sysupdate title-listing.&lt;br /&gt;
&lt;br /&gt;
====GetSystemCommonETicket====&lt;br /&gt;
Returns the Base64-encoded cetk for each specified TitleId entry.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
=Sysupdate checking process=&lt;br /&gt;
This section describes the process used when checking whether a sysupdate is required.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
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&#039;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.&lt;br /&gt;
&lt;br /&gt;
At least one &amp;lt;TitleVersion&amp;gt; entry with valid data in the GetSystemUpdate response is required.&lt;br /&gt;
&lt;br /&gt;
The titleIDs sent in the GetSystemUpdate SOAP request are decimal, while the titleIDs in the response are hex.&lt;br /&gt;
&lt;br /&gt;
=NIM [[System_SaveData]]=&lt;br /&gt;
==hash.dat==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
!  Offset&lt;br /&gt;
!  Size&lt;br /&gt;
!  Description&lt;br /&gt;
|-&lt;br /&gt;
| 0x60&lt;br /&gt;
| 0x1&lt;br /&gt;
| u8 flag used with the SystemTitleHash. 0x01 = latest sysupdate isn&#039;t installed as of last SOAP requests, 0x03 = latest sysupdate is installed as of last SOAP requests.&lt;br /&gt;
|-&lt;br /&gt;
| 0x61&lt;br /&gt;
| 0x21&lt;br /&gt;
| ASCII hex SystemTitleHash, including NUL-terminator. This is the latest SystemTitleHash which NIM module received from SOAP.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=Types=&lt;br /&gt;
==InstallationMode==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
!  Value&lt;br /&gt;
!  Description&lt;br /&gt;
|-&lt;br /&gt;
| 0&lt;br /&gt;
| Initial installation&lt;br /&gt;
|-&lt;br /&gt;
| 1&lt;br /&gt;
| Unknown&lt;br /&gt;
|-&lt;br /&gt;
| 2&lt;br /&gt;
| Unknown&lt;br /&gt;
|-&lt;br /&gt;
| 3&lt;br /&gt;
| Reinstallation&lt;br /&gt;
|}&lt;br /&gt;
==DownloadState==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
!  Value&lt;br /&gt;
!  Description&lt;br /&gt;
|-&lt;br /&gt;
| 0&lt;br /&gt;
| Not initialized&lt;br /&gt;
|-&lt;br /&gt;
| 1&lt;br /&gt;
| Download initialized&lt;br /&gt;
|-&lt;br /&gt;
| 2&lt;br /&gt;
| Downloading, verifying and installing TMD&lt;br /&gt;
|-&lt;br /&gt;
| 3&lt;br /&gt;
| Initializing save data&lt;br /&gt;
|-&lt;br /&gt;
| 4&lt;br /&gt;
| Downloading and installing contents&lt;br /&gt;
|-&lt;br /&gt;
| 5&lt;br /&gt;
| Waiting before calling [[AM:CommitImportPrograms]]&lt;br /&gt;
|-&lt;br /&gt;
| 6&lt;br /&gt;
| Running [[AM:CommitImportPrograms]]&lt;br /&gt;
|-&lt;br /&gt;
| 7&lt;br /&gt;
| Title installation finished&lt;br /&gt;
|-&lt;br /&gt;
| 8&lt;br /&gt;
| Unknown error regarding title version&lt;br /&gt;
|-&lt;br /&gt;
| 9&lt;br /&gt;
| Creating the .ctx file (or error doing so)?&lt;br /&gt;
|-&lt;br /&gt;
| 10&lt;br /&gt;
| Irrecoverable error encountered&lt;br /&gt;
|}&lt;br /&gt;
==TitleConfig==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
!  Offset&lt;br /&gt;
!  Length&lt;br /&gt;
!  Description&lt;br /&gt;
|-&lt;br /&gt;
| 0x0&lt;br /&gt;
| 0x8&lt;br /&gt;
| Title ID&lt;br /&gt;
|-&lt;br /&gt;
| 0x8&lt;br /&gt;
| 0x4&lt;br /&gt;
| Title version&lt;br /&gt;
|-&lt;br /&gt;
| 0xC&lt;br /&gt;
| 0x4&lt;br /&gt;
| Unknown (always 0)&lt;br /&gt;
|-&lt;br /&gt;
| 0x10&lt;br /&gt;
| 0x1&lt;br /&gt;
| Age rating for the HOME Menu parental controls&lt;br /&gt;
|-&lt;br /&gt;
| 0x11&lt;br /&gt;
| 0x1&lt;br /&gt;
| [[Filesystem_services#MediaType|Media Type]]&lt;br /&gt;
|-&lt;br /&gt;
| 0x12&lt;br /&gt;
| 0x2&lt;br /&gt;
| Padding&lt;br /&gt;
|-&lt;br /&gt;
| 0x14&lt;br /&gt;
| 0x4&lt;br /&gt;
| Unknown (always 0?)&lt;br /&gt;
|}&lt;br /&gt;
==TitleProgress==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
!  Offset&lt;br /&gt;
!  Length&lt;br /&gt;
!  Description&lt;br /&gt;
|-&lt;br /&gt;
| 0x0&lt;br /&gt;
| 0x4&lt;br /&gt;
| [[#DownloadState|Download State]]&lt;br /&gt;
|-&lt;br /&gt;
| 0x4&lt;br /&gt;
| 0x4&lt;br /&gt;
| Last result code in NIM related to the installation&lt;br /&gt;
|-&lt;br /&gt;
| 0x8&lt;br /&gt;
| 0x8&lt;br /&gt;
| Amount of bytes that have been downloaded&lt;br /&gt;
|-&lt;br /&gt;
| 0x10&lt;br /&gt;
| 0x8&lt;br /&gt;
| Total bytes that need to be downloaded&lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>AriA99</name></author>
	</entry>
</feed>