Repository navigation
DSi Hardware
The DSi's extra hardware, as found by running the DSi menu, system apps and DSi titles, and by test ROMs on a real DSi. See Hardware notes for what Measured, Software and Unverified mean.
Measured on a DSi in DSi mode with maelle-ndma.nds. All 78 results now match
(b9d3a6b, 74be950).
- The reserved destination address step (3) acts as fixed. melonDS treats it as increment.
NDMAxCNTbits 0-9 read 0.- While a channel is enabled, only its enable bit can be written. That covers SAD, DAD, TCNT, WCNT, BCNT and FDATA as well as CNT.
-
Transfers don't change TCNT. If they did, re-enabling a channel would copy far too much
(
afb85e3). - GXFIFO as a trigger sends 112 words at a time, like DS DMA.
Not measured: the DS cart trigger (needs a real card in the slot) and ARM7 timers 2-3 (libnds uses them).
Which software uses which modes: the DSi menu only uses 0x10 (immediate), 0xA and 0xB, plus 0x8 for the SD card. Pokémon Black 2 uses no NDMA at all.
Measured with maelle-wram.nds (0277e6f,
1cf015b).
- The top byte of MBK9 reads back as 0 and does nothing. Cart headers fill it with their WRAMCNT (0xFC for the DSi menu), but every 4 KB block of shared WRAM still follows WRAMCNT, as on a DS.
- MBK9's low bits must read back what was written (mask 0xFFFF0F). The DSi menu checks this, and launches fail if they read 0.
- An earlier theory that the top byte locks blocks to the CPU that had them (needed for an ES key heap at 0x3004000) was wrong. Making MBK9 readable was the real fix.
Measured on a DSi in DSi mode with maelle-mic.nds. Maelle matches all 26 tests
(2d7b502). GBATEK leaves most of this open. The full write-up is
in tests/hardware/README.md.
- The sample clock runs freely. The first sample comes 0 to 1 frames after turning the microphone on. Each frame has a left slot, and a right slot half a frame later, even when the rate is divided. Frames are 1024 or 704 cycles times the divider.
- Formats: 0 takes both slots, starting from a left one. 1 takes only the right, 2 only the left, 3 none.
- In stereo, the right slot repeats the left slot's sample, so both halves of each word are the same. In mono, the older sample is in the low half.
- IRQ modes 1 and 3 fire when the FIFO becomes half full, and again only after it drops below half. Mode 2 fires on overrun, not when the FIFO becomes full.
- NDMA mode 0xC asks for a block when the FIFO becomes half full, then not again until it has been empty. Blocks of 8 or 16 words carry on. Smaller blocks stop after the first. A channel turned on after the FIFO is already half full never starts.
-
Reads of any size, at either half of
MIC_DATA, take a whole word. An empty FIFO reads the last word read, over and over, even after it's cleared. - Turning the microphone off keeps the FIFO and an overrun. Clearing only works if the microphone was off before the write.
- Muting the microphone in the touchscreen controller doesn't zero the samples. They drift slowly, like an input settling.
Values system software leaves:
- TWiLight Menu++ leaves
SNDEXCNTat 0x800F, and so does the DSi menu for both DS and DSi titles (from a dump of the handover, see DSi system software). - DSi Sound records through
MIC_CNT= 0xE006: left only, rate divided by 2, so 16.36 kHz. Recording doesn't use the DSP. It plays the preview on SPU channels as PCM16.
-
The DSi talks to the TSC in a newer protocol. One byte picks a register in the current page, then each following
byte reads or writes one register. Coordinates are in page 0xFC, as big-endian buffers with bit 15 set when the pen
state changed. Page 3 says whether the pen is down (Software, after melonDS's DSi_TSC,
8aaa827). -
The register-select byte sends back 0, as in DS mode (
6f69576). -
DS titles need the TSC switched to DS mode through page 0xFF. The DSi menu does this before starting a DS title. A
directly booted DS title in DSi mode otherwise gets no touches (Castlevania: Dawn of Sorrow)
(
63376b9). -
DSi titles with header flags bit 0 at 0x1BF clear also get the TSC in DS mode. Korg DS-10+ reads it the DS way
(
72b4717). -
Microphone gain (page 1, register 0x2F): the system sets 0x2B (21.5 dB) at boot. DSi Sound sets 0x42 (33 dB)
when it starts and while recording, and also unmutes the ADC at page 0, register 0x52 bit 7
(
448c0ab). -
Headset detection (from GBATEK, Unverified,
a4b729d): page 0 register 0x43 bits 6-5 = 1 for a headset when detection is on. 0x2C bit 4 is a sticky change flag, cleared on read. 0x2E bit 4 is the current state. 0x39 shows the GPI2 pin, which carries the headphone state unless it's in mode 0.
From GBATEK, Unverified (a4b729d):
- 0x4004C00-0x4004C04 (data, direction, edge, IE, GPIO_WIFI) are on the ARM7 in DSi mode.
- GPIO33[1] is the headphone jack and interrupts through IF2 bit 5 on the selected edge. GPIO33[2] is the power button and reads 1 when idle. Idle inputs read 0xD7.
- The DSi menu leaves
GPIO_DATA/GPIO_DIRat 0x80D7,GPIO_IEDGE/GPIO_IEat 0x4000 (GPIO33[2] interrupting) andGPIO_WIFIat 0x0100 (DS Wi-Fi mode) (Measured from a handover dump,eb123d9).
Software:
-
Register 0x40 holds the volume level, 0-31. DSi Sound's slider writes it and reads it back, so it has to stick.
It starts at full, as in melonDS. Output scales evenly from silent at 0 to full at 31
(
7521a9b). - The byte sent with the I2C stop isn't written. DSi Sound sends the level again that way. Writing it lands in the backlight register.
-
To reboot, the system writes 0x70 = 1, then 0x11 = 1. System Settings and Flipnote Studio exit this way
(
63af0a2).
-
Only devices that are there acknowledge. The DSi finds its cameras by probing, so absent devices must not ACK, and
read 0xFF. On a DSi the devices are 0x4A (MCU), 0x78 (outer camera) and 0x7A (inner camera)
(
9746603).
After melonDS and GBATEK, checked with DSi Camera (preview, capture, album, saving), Software
(9746603):
- Two Aptina MT9V113 sensors: 0x78 outer, 0x7A inner. Chip ID 0x2280, standby at 0x0018, misc at 0x001A (bit 9). MCU
variable window at 0x098C/0x0990.
SEQ_CMD0x2103 drives state 0x2104 to 3 or 7. Sizes: 0x2703/0x2705 for preview, 0x2707/0x2709 for capture. Read mode at 0x2717/0x272D, where bit 0 set means not mirrored. - The ARM9's camera module raises interrupt 25 every 1/15 s (2,234,248 cycles), with lines 3,173 cycles apart. It fills two 512-word buffers in turn, each handed to NDMA mode 0xB.
- Capture is
SEQ_CMD2, at 640x480, one line per NDMA block. - DSi Camera loads no DSP program at all.
-
A job with 0 blocks finishes at once, and still raises its interrupt if enabled. After decrypting a title's modcrypt
areas, the launcher starts one. If it stays busy, the ARM7 waits on
AES_CNTbit 31 forever, the launcher's write ofTWLCFG1.datnever happens, and the screen stays white with no error (400692d,28e02a1). -
AES-CCM jobs with only associated data have to finish. DSi Camera signs every photo with a CCM MAC over about 1,000
blocks (0x3F9) of associated data and no payload, sent by ARM7 NDMA mode 0xA (IPC tag 0x13). If the job only completes
after a payload block, saving never ends (
909ea60). -
Modcrypt areas can end mid-block. DSiWare modcrypts its ARM7i, which ends partway through a block, and that last
partial block holds the ARM7's DSi autoload table. Decrypt it too, or the ARM7 copies garbage and both CPUs hang on a
white screen. Cards only modcrypt whole 0x4000-byte areas (
6e3584f).
Software, checked with DSi Sound, Flipnote Studio and System Settings:
-
The interrupt is the OR of the unmasked request bits, and the ARM7 sees it on the rising edge. Raising IF2 for every
request bit gives data commands (like ACMD51) two interrupts. DSi Sound's own NAND driver posts one message per
interrupt into a 5-entry queue and takes one per command, so the extras fill the queue, completions get dropped, and
saves crawl along one block every 4 seconds on a timeout. The app then shows "saving" forever, and "data damaged" the
next time. The request mask is 0x8B7F031D. Bits 5 and 7 only show the card's state and aren't part of the line.
If they're counted, nothing ever fires (
f2da750). -
Card detect after a reset: the firmware resets the controller (
SD_SOFT_RESET0x40048E0, thenSD_CARD_OPTION0x4004828 = 0x40EA), acknowledges everything, unmasks IRQ bits 3 and 4, and waits for the card-inserted event (bit 4). Leaving reset must raise it after 0x400 << n HCLKs, where n isCARD_OPTIONbits 0-3 (0xF means 0x100, per GBATEK). Reset also sets the option register to 0x40EE. Without this, no DSi software ever sees an SD card (8ffd036). - No card: IRQ status bits 5 and 7 clear, and port-0 commands time out (bit 22) without bit 0.
-
The data request must only rise when the FIFO has room. Flipnote Studio puts the first block of a multi-block write
in the 32-bit FIFO before sending CMD25, with NDMA mode 8 armed for the rest. Raising the request with the FIFO full
makes NDMA overrun, the last block never arrives, and the backup fails after a 4-second timeout
(
624b523). - Card registers: the response registers hold CSD bits 127-8 (the CRC byte dropped), the same layout as the CID in the nocash NAND footer. For an image Maelle builds an SDSC v1.0 CSD (256 KB units, up to 1 GB) or SDHC v2.0 (512 KB units). For the NAND it uses a real DSi eMMC's CSD from melonDS (0xF000000 bytes) with C_SIZE refitted. SCR is 02 25/35, the SD status follows ACMD6's bus width, speed class 2, AU 4 MB. These values are Unverified against a real DSi.
- The DSi menu never touches the SD card by itself. There's no top-bar icon either way.
Not covered yet: error detail, data timeouts, CMD6/12/38, MMC CMD8 (SEND_EXT_CSD), SD_STOP_INTERNAL,
SD_CARD_CLK_CTL, real block timing and hot swap.
After melonDS's DSi_NWifi, Software:
-
The DSi menu uploads the Wi-Fi firmware over SDIO before starting any title. Without it, launches fail with
FATALbit 7 (WLANFIRM_LOAD) (2314b12). - The SDIO controller is a second SD/MMC controller, with its own IRQ, NDMA request and card interrupt registers.
-
SDIO_SOFT_RESETbit 0 restarts the chip. System Settings' connection test for connections 1-3 runs on the DS Wi-Fi hardware first, then resets the DSi chip this way and repeats the test on it. If the reset isn't there, the chip takes the restart for commands and the system shows its error screen (f98ffbb). Connections 4-6 (Advanced Setup) only use the DSi chip. - Nintendo's connection test server still answers 200 OK. Support code 11172 means success.
-
SCFG_EXTon a real DSi: EXT9 = 0x8307F100 under both TWiLight Menu++ and Unlaunch. EXT7 = 0x93FFFB06 under TWiLight Menu++ and 0x93FFFF07 under Unlaunch (Measured, read by the hardware test ROMs). For a DSi title, EXT7 = 0x13FBFB00 | (header[0x1B8] & 0x80040407) (2f82f06). -
Once a CPU clears bit 31 of its
SCFG_EXT, its SCFG and MBK registers read 0 and ignore writes. - Pokémon Black 2's ARM7 skips its own setup if it starts with bit 31 already clear. The launcher clears it for some titles (the Browser) after doing their setup. A loader that clears it without doing that setup leaves Black 2 on a white screen. Direct boot should leave it set so the title's startup code does the setup.
-
SCFG_EXT9bits 14-15 set main RAM's size. A DSi gives DS titles 4 MB, with the mirrors they use. Mapping 16 MB left Mario Kart DS, Phantom Hourglass and Chinatown Wars on blank screens in DSi mode (e16659e). -
SCFG_ROMswitches each CPU to the DS BIOS for DS titles (fdb4691). -
SCFG_MCand the card slot's power states: a power cycle resets the card's encryption. -
SCFG_CLKbit 0 picks the ARM9's clock. See ARM CPUs.
-
DSi cards have a second KEY1 mode, entered with command 0x3D, which uses level 1 of a table in the DSi's ARM7 BIOS
(at 0xC6D0) and reads the secure area at the start of the card's DSi area. Normal reads only reach the DSi area after a
DSi has entered that mode. The exception is the area's first 0x3000 bytes, which read like the ROM's first 0x8000. On a
DS, normal reads never reach it. After melonDS, Software: with it, the launcher loads all of Pokémon Black and Black 2 from the card
(
dcd2c55). -
Once unlocked, the DSi area is readable by both CPUs. After a Mystery Gift, Black 2 restarts and HMAC-checks the
ARM9, ARM7, ARM9i and ARM7i against the DSi header, reading the card's DSi area from the ARM9 when only the ARM7
unlocked it. If any check fails it stops for good at 0x01FF8F9C
(
901d15d). - In DSi mode, the card's Blowfish table comes from the DSi's ARM9 BIOS, since its ARM7 BIOS doesn't have the DS one.
-
DSiWare secure areas use KEY1 with the normal NDS table. With the wrong table, 0x02004000-0x020047FF fills with
E7FFDEFFand the title hangs at 0x02FFFFF0. -
DSi titles check what they read from the card with HMAC-SHA1 through BIOS SWIs 0x24-0x27. Pokémon Black 2 does it
every frame on its Press Start screen, in DSi mode only. It's a large share of that screen's CPU time
(
4b9dfd1).
-
Nintendo's DSP programs can be told apart by the CRC32 of the DSP's 8 program pages when
DSP_PCFGbit 0 releases it from reset. melonDS's high-level versions of the AAC, G.711 and graphics programs are keyed that way (35e9457). -
DSi Sound's program takes an interrupt for every sample, which makes low-level DSP emulation slow
(
1b4081c). -
SNDEXCNTmutes the SPU and mixes in the DSP's sound at the ratio it sets. The exact curve is unknown. - The DSP's I2S frame updates at 1024 or 704 cycles, set by
SNDEXCNTbit 13. -
melonDS's scaler looks wrong (Unverified: from reading the code, with no hardware reference and no software
found that uses it): nearest-neighbour steps down a line by the rectangle's width instead of the picture's, and
bilinear blends a line with itself instead of the one below (
81a2c68,e1e96ad). - DSi Sound's preview of a recording plays about 7% sharp, with Teakra too, though the recorded data is an exact 440 Hz. Whether a real DSi does this is unknown.