CIC-NUS: Difference between revisions

Jump to navigation Jump to search
Content added Content deleted
No edit summary
Line 127: Line 127:
|Pin 15
|Pin 15
|P2:0
|P2:0
|Data I/O (to PIF)
|DIO (to PIF)
|-
|-
|
|
Line 135: Line 135:
|Pin 14
|Pin 14
|P2:1
|P2:1
|Data CLK (to PIF)
|DCLK (to PIF)
|-
|-
|
|
Line 184: Line 184:


=== '''Physical connection with PIF''' ===
=== '''Physical connection with PIF''' ===
Each CIC is connected to PIF via two lines: Pin 14 (aka Data CLK) and pin 15 (aka Data I/O). In this simple serial protocol, the PIF acts as the master, and the CIC as the slave. Whenever the PIF firmware is ready to send or receive data, it will pulse the CLK line and then either move the DATA line (in case PIF is wiring), or read the line status as moved by CIC (in case of reading). The protocol makes it clear beforehand whether a write or a read should happen. Any time the CIC needs to either read a data from the PIF or write a data for it, it spins waiting to see the front on the CLK line.
Each CIC is connected to PIF via two lines: Pin 14 (aka DCLK) and pin 15 (aka DIO). In this simple serial protocol, the PIF acts as the master, and the CIC as the slave. Whenever the PIF firmware is ready to send or receive data, it will pulse the DCLK line and then either move the DCLK line (in case PIF is wiring), or read the line status as moved by CIC (in case of reading). The protocol makes it clear beforehand whether a write or a read should happen. Any time the CIC needs to either read a data from the PIF or write a data for it, it spins waiting to see the front on the DCLK line.


=== Boot sequence ===
=== Boot sequence ===


==== 1. ID ====
==== 1. ID ====
[[File:ID nibble.png|thumb|ID nibble with value 0101 (yellow = CLK, cyan = DATA)]]
[[File:ID nibble.png|thumb|ID nibble with value 0101 (yellow = DCLK, cyan = DIO)]]
The CIC writes 1 nibble (4 bits) to the PIF called "ID". The bits are as follow (in order of transmission, so what we call here "bit 0" would actually be "bit 3" in a reconstructed 4 bit register).
The CIC writes 1 nibble (4 bits) to the PIF called "ID". The bits are as follow (in order of transmission, so what we call here "bit 0" would actually be "bit 3" in a reconstructed 4 bit register).


Line 199: Line 199:
==== 2. Seeds ====
==== 2. Seeds ====
The CIC writes 6 nibbles which contains one of the boot secrets: the checksum seeds. These are 2 seeds of 1 byte each one, called IPL2 seed and IPL3 seed (please refer to the [[PIF-NUS]] page for a description of how these seeds are then used by PIF). In all known PIF variants, the two seeds happen to be exactly the same byte, even though the protocol would allow for them to differ. A table in the PIF-NUS page lists the seeds for all known CIC variants. In addition these 2 bytes, a third byte is transmitted first, which is a fixed value (0xB5).
The CIC writes 6 nibbles which contains one of the boot secrets: the checksum seeds. These are 2 seeds of 1 byte each one, called IPL2 seed and IPL3 seed (please refer to the [[PIF-NUS]] page for a description of how these seeds are then used by PIF). In all known PIF variants, the two seeds happen to be exactly the same byte, even though the protocol would allow for them to differ. A table in the PIF-NUS page lists the seeds for all known CIC variants. In addition these 2 bytes, a third byte is transmitted first, which is a fixed value (0xB5).
[[File:Seed.png|thumb|Scrambled seed (yellow = CLK, cyan = DATA)]]
[[File:Seed.png|thumb|Scrambled seed (yellow = DCLK, cyan = DIO)]]
For instance, the transmitted sequence for a CIC 6102 which uses 0x3F as seed is <code>B5 3F 3F</code>.
For instance, the transmitted sequence for a CIC 6102 which uses 0x3F as seed is <code>B5 3F 3F</code>.


Line 217: Line 217:


==== 4. Checksum ====
==== 4. Checksum ====
[[File:Checksum.png|thumb|A checksum transmitted to PIF (yellow: CLK, cyan: DATA)]]
[[File:Checksum.png|thumb|A checksum transmitted to PIF (yellow: DCLK, cyan: DIO)]]
The CIC writes 16 nibbles which contain the other boot secret: the IPL2 checksum. This is a 6 byte checksum that is used by the PIF to verify that the IPL3 found in the cartridge is the correct one for this CIC. The exact process (that also involves the CPU at its IPL2 stage) is detailed in the [[PIF-NUS page]].
The CIC writes 16 nibbles which contain the other boot secret: the IPL2 checksum. This is a 6 byte checksum that is used by the PIF to verify that the IPL3 found in the cartridge is the correct one for this CIC. The exact process (that also involves the CPU at its IPL2 stage) is detailed in the [[PIF-NUS|PIF-NUS page]].


As a prefix to the 6 byte (12 nibble) checksum, 2 bytes (4 nibbles) are prefixed. These bytes come from the random number generated in the previous step and are thus different at each boot.
As a prefix to the 6 byte (12 nibble) checksum, 2 bytes (4 nibbles) are prefixed. These bytes come from the random number generated in the previous step and are thus different at each boot.
Line 236: Line 236:


==== 2. Command "Die" (bits: 01) ====
==== 2. Command "Die" (bits: 01) ====
When the CIC receives this command, it enters an infinite loop in which it does nothing, thus stopping any communication with CIC, until powered off.
When the CIC receives this command, it enters an infinite loop in which it does nothing, thus stopping any communication with PIF, until powered off.


==== 3. Command "Challenge" (bits: 10) ====
==== 3. Command "Challenge" (bits: 10) ====