Difference between revisions of "CCI"

From 3dbrew
Jump to navigation Jump to search
m
(Removed redirect to NCSD)
Tag: Removed redirect
 
(13 intermediate revisions by 5 users not shown)
Line 1: Line 1:
This document is about the format of CTR cart images (CCI), which is also the format of 3DS ROM dumps.
+
See also: [[NCSD]].
 +
 
 +
This page documents the format of NCSD. CTR cart images (CCI) is NCSD, but is used for other things as well. CSU is NCSD used for system updates and development tools.
 +
 
 +
This is a container format which generally holds [[CXI]] files inside.
  
 
=== Overview ===
 
=== Overview ===
CCI files start with a NCSD header, followed by up to a maximum of 8 NCCH blocks according to spec. The first block usually starts at 0x4000. In most carts the first block contains game code/data, the second block contains the download play "child" and the third block contains potential system updates. The exact contents of NCCH blocks can be determined by looking at the flags.
+
NCSD images start with a NCSD header, followed by up to a maximum of 8 partitions according to spec. The first partition(NCCH 0) usually starts at 0x4000, this is generally the main NCCH executable. The following info on partitions 1, 2, and 7 are only valid for .CCI. The second partition(NCCH 1) contains the game "Manual"(title ID for the .CXI containing the Manual always starts with '0005'). The third partition(NCCH 2) contains the download play "Child"(The title ID for the NCCH containing the Child always starts with '0006'). The eighth block(NCCH 7) contains "Update Data"(The title ID for the NCCH containing the Update Data always starts with '8000') The format of partitions can be determined from the partition FS flags, while the contents can be determined from the partitions flags.
 
 
The NCCH blocks are in the same format as [[CXI]] files.
 
  
 
=== NCSD header ===
 
=== NCSD header ===
 
{| class="wikitable" border="1"
 
{| class="wikitable" border="1"
 
|-
 
|-
OFFSET
+
Offset
SIZE
+
Size
DESCRIPTION
+
Description
 
|-
 
|-
 
|  0x000
 
|  0x000
 
|  0x100
 
|  0x100
|  RSA-2048 signature of the NCSD header, using SHA-256 (needs to be confirmed)
+
|  RSA-2048 SHA-256 signature of the NCSD header
 
|-
 
|-
 
|  0x100
 
|  0x100
 
|  4
 
|  4
|  Magic ID, always 'NCSD'
+
|  Magic Number 'NCSD'
 
|-
 
|-
 
|  0x104
 
|  0x104
 
|  4
 
|  4
|  Size of the CCI image, in media units (1 media unit = 0x200 bytes)
+
|  Size of the NCSD image, in media units (1 media unit = 0x200 bytes)
 
|-
 
|-
 
|  0x108
 
|  0x108
Line 29: Line 31:
 
|  Title/Program ID
 
|  Title/Program ID
 
|-
 
|-
0x120
+
0x110
4
+
8
Offset to the first NCCH in media units
+
Partitions FS type
 
|-
 
|-
0x124
+
0x118
4
+
8
Size of the first NCCH
+
Partitions crypt type
 
|-
 
|-
0x130
+
0x120
|  4
+
0x40=(4+4)*8
|  Offset to the second NCCH
+
|  Offset & Length partition table
 
|-
 
|-
0x134
+
0x160
4
+
0x20
Size of the second NCCH
+
Exheader SHA-256 hash
 
|-
 
|-
0x158
+
0x180
4
+
0x4
Offset to the third NCCH
+
Additional header size
 
|-
 
|-
0x15C
+
0x184
4
+
0x4
Size of the third NCCH
+
Sector zero offset
 
|-
 
|-
 
|  0x188
 
|  0x188
 
|  8
 
|  8
NCCH Flags: byte[5]-byte[7] indicate content type ( system update, application, ... ) size of media units ( 512*2^byte[6] ) and encryption.
+
Partition Flags: byte[5]-byte[7] indicate content type ( system update, application, manual, ... ) size of media units ( 512*2^byte[6] ) and encryption.
 
|-
 
|-
 
|  0x190
 
|  0x190
|  8
+
0x40=8*8
Partition ID of the first NCCH
+
Partitions' Title ID table
 
|-
 
|-
0x1A0
+
0x1D0
8
+
0x28
Partition ID of the second NCCH
+
Reserved
 
|-
 
|-
0x1C8
+
0x1F8
 
|  8
 
|  8
Partition ID of the third NCCH
+
Unknown
 
|-
 
|-
 
|  0x200
 
|  0x200
 
|  4
 
|  4
 
|  Always 0xFFFFFFFF
 
|  Always 0xFFFFFFFF
 +
|-
 +
|  0x204
 +
|  252
 +
|  Padding?
 
|-
 
|-
 
|  0x300
 
|  0x300
 
|  4
 
|  4
 
|  Used ROM size in bytes
 
|  Used ROM size in bytes
 +
|-
 +
|  0x304
 +
|  28
 +
|  Padding
 
|-
 
|-
 
|  0x320
 
|  0x320
16
+
8
Unknown
+
[[NVer]] Title ID (Only Present in retail .CCI)
 +
|-
 +
|  0x328
 +
|  8
 +
|  [[NVer]] Title Version (Only Present in retail .CCI)
 
|}
 
|}
  
Parts of the first NCCH block's header are found around 0x1000 for whatever reason.
+
Parts of the first NCCH block's header are found around 0x1000 for whatever reason. NCSD can hold up to 8 partitions. (i.e. Mario Kart 7 holds 4 NCCHs, most we've seen so far)
 +
 
 +
The region-specific NVer title for this NCSD presumably must exist on NAND. The NVer title version may also be used to check whether a system update is required before running the app.
  
CCI images may not include all three NCCH blocks. For example, Ghost Recon: Shadow Wars lacks the second NCCH. Entries at 0x130, 0x134 and 0x1A0 in its NCSD header are zero.
+
[[Category:File formats]]

Latest revision as of 17:42, 1 December 2018

See also: NCSD.

This page documents the format of NCSD. CTR cart images (CCI) is NCSD, but is used for other things as well. CSU is NCSD used for system updates and development tools.

This is a container format which generally holds CXI files inside.

Overview[edit]

NCSD images start with a NCSD header, followed by up to a maximum of 8 partitions according to spec. The first partition(NCCH 0) usually starts at 0x4000, this is generally the main NCCH executable. The following info on partitions 1, 2, and 7 are only valid for .CCI. The second partition(NCCH 1) contains the game "Manual"(title ID for the .CXI containing the Manual always starts with '0005'). The third partition(NCCH 2) contains the download play "Child"(The title ID for the NCCH containing the Child always starts with '0006'). The eighth block(NCCH 7) contains "Update Data"(The title ID for the NCCH containing the Update Data always starts with '8000') The format of partitions can be determined from the partition FS flags, while the contents can be determined from the partitions flags.

NCSD header[edit]

Offset Size Description
0x000 0x100 RSA-2048 SHA-256 signature of the NCSD header
0x100 4 Magic Number 'NCSD'
0x104 4 Size of the NCSD image, in media units (1 media unit = 0x200 bytes)
0x108 8 Title/Program ID
0x110 8 Partitions FS type
0x118 8 Partitions crypt type
0x120 0x40=(4+4)*8 Offset & Length partition table
0x160 0x20 Exheader SHA-256 hash
0x180 0x4 Additional header size
0x184 0x4 Sector zero offset
0x188 8 Partition Flags: byte[5]-byte[7] indicate content type ( system update, application, manual, ... ) size of media units ( 512*2^byte[6] ) and encryption.
0x190 0x40=8*8 Partitions' Title ID table
0x1D0 0x28 Reserved
0x1F8 8 Unknown
0x200 4 Always 0xFFFFFFFF
0x204 252 Padding?
0x300 4 Used ROM size in bytes
0x304 28 Padding
0x320 8 NVer Title ID (Only Present in retail .CCI)
0x328 8 NVer Title Version (Only Present in retail .CCI)

Parts of the first NCCH block's header are found around 0x1000 for whatever reason. NCSD can hold up to 8 partitions. (i.e. Mario Kart 7 holds 4 NCCHs, most we've seen so far)

The region-specific NVer title for this NCSD presumably must exist on NAND. The NVer title version may also be used to check whether a system update is required before running the app.