# Booting: the BIOS, the firmware, and direct boot Source: GBATEK "BIOS Functions", "BIOS RAM Usage", "DS Memory Control - BIOS", "DS Firmware Header", "DS Encryption by Gamecode/Idcode (KEY1)", "DS Cartridge Protocol"; OBSERVED lines are from MAME's run of the BIOS (mame-oracle.md). DOC unless marked. ## The real path 1. Reset: the ARM9 starts at FFFF0000h (its BIOS, 4 KB), the ARM7 at 00000000h (its BIOS, 16 KB). OBSERVED: both BIOSes begin with the same check of 4000300h (POSTFLG) and the ARM9's sets up CP15 (control 00002078h, caches invalidated, DTCM at 00800000h, then DTCM on). 2. The ARM7 BIOS reads the firmware over SPI, decrypts its boot code with KEY1 (id code "MACP"), decompresses it (LZ77) and checks a CRC (GBATEK "firmware_decryption"). 3. The firmware (Nintendo's menu: health and safety screen, settings, PictoChat, Download Play) reads the cartridge header, then the secure area through the KEY1 phase (with the BIOS's help), loads the ARM9 and ARM7 binaries to their RAM addresses and starts them. The header lands at 027FFE00h. The BIOS locks BIOSPROT at 1204h before starting the cartridge. 4. The game runs; its SWIs call the BIOS (decompression, CRC, division, halt, sound tables...). MAME's `nds` stops early: the ARM7 halts and the ARM9 polls (OBSERVED: the ARM9 spends the frame in a loop reading a halfword; the ARM7's log ends "arm7: HALT"); MAME's driver has no video and no cartridge slot. It shows step 1 and the start of step 2 only. ## Direct boot (what most emulators offer) Skip steps 1-3: copy the header to 027FFE00h, load the two binaries per the header, put the values the BIOS and firmware leave in RAM and registers (GBATEK "BIOS RAM Usage": the user settings copy at 027FFC80h, chip IDs at 027FF800h and 027FFC00h, the boot indicator, CP15 and IPC state...), and jump to the entry points. Needs no firmware boot code and no KEY1 for the boot (the BIOS is still needed for SWIs, unless a free BIOS is used). Its risk: every value left in RAM must be right, and that list is GBATEK's reading of real boots (DOC), not a capture. ## Free replacements - **BIOS**: a BSD-2-Clause "Custom NDS ARM7/ARM9 BIOS replacement" (Gilead Kutnick, 2013, written for DraStic; its readme says it "is not derived from Nintendo's BIOS implementation but has been implemented using publically available documentation"). It is distributed inside melonDS's GPL tree (`freebios/`), with its own BSD-2 notice (licence read through the GitHub API, 2026-11-26; nothing fetched). It cannot hold Nintendo's KEY1 table, so it serves direct boot only. Open decision: where to fetch it from (an MIT repository must not fetch a GPL tree; the BSD-2 files alone would be fine). - **Firmware**: no free firmware is known; a direct boot needs only a firmware *data* image (user settings, touchscreen calibration, Wi-Fi calibration, MAC), which the board can synthesise from GBATEK's layout with CRCs. Games read the user settings (language, name) and the calibration. ## What the board needs, by path | Path | BIOS | Firmware | KEY1 table | Cartridge model | | --- | --- | --- | --- | --- | | Real boot | player's (both) | player's (with boot code) | from the player's ARM7 BIOS | re-encrypted secure area, KEY1/KEY2 replies | | Direct boot, Nintendo BIOS | player's | synthesised data | only for games that use KEY1 later | KEY2 replies (or KEY2 off) | | Direct boot, free BIOS | the BSD-2 replacement | synthesised data | none | as above; SWI behaviour as the replacement implements it | ## Unknowns (U) - U1 The complete post-boot state for direct boot (GBATEK's list is long but marked partly "?"); judge: a boot through the real path in our own board, compared value by value (the board judging itself: tier 5, but it finds omissions). - U2 Firmware differences that games notice (version, Lite vs DS), and the iQue firmware's. - U3 How the free BIOS's SWIs differ in results and timing from Nintendo's (only matters if adopted).