MAX DUO Pokémon Toolkit GitHub

Home / Library

How much of the MAX DUO the toolkit uses

Rendered from docs/DUO_RESOURCES.md in the repository.

This page answers one question: are we using everything the Action Replay MAX DUO offers? It covers the GBA's RAM, the DUO's own flash, the USB link, and the parts the toolkit doesn't touch at all.

How it was measured. The RAM figures come from tools/duo_memory_map.py, run on 22 November 2026. The script runs Datel's real firmware with Reckless v4.2 in the simulator (tests/hwsim.py) and records every write to the GBA's RAM, in 1 KB pages, during three things:

  • booting into USB server mode;
  • a full 128 KB save backup;
  • a multiboot send of a 125 KB program.

The full output is in extracted/duo_memory_map.txt. The hardware facts come from HARDWARE.md and FINDINGS.md. What the simulator cannot show is marked as such.

Summary

Resource Size Used by the toolkit Spare (measured) Worth using?
GBA main RAM (EWRAM) 256 KB ~134 KB: Datel's variables, the 128 KB transfer buffer at 0x02010030, the program area 0x02038000-0x0203AFFF, stacks and buffers above 63 KB never written at 0x02000400-0x0200FFFF, plus ~31 KB above the buffer (0x02030030-0x02037BFF) Yes, for bigger multiboot programs (up to ~222 KB)
GBA fast RAM (IWRAM) 32 KB 3 KB (Datel's variables, the stacks) 29 KB Only for timing-critical code; nothing needs it yet
USB link 8-byte packets, ~18 ms per round trip (fixed by the Cypress chip) Program files go 4 bytes per round trip (PUT, 0x2C) Half of each packet Yes: about 2× faster loading, more with compression
DUO flash 512 KB Datel + Reckless firmware 191,172 bytes; Datel's storage 48 KB; code database 256 KB No blank 1 KB anywhere inside the firmware image (Reckless filled Datel's padding). 5.3 KB after the image and 16 KB at 0x0803C000 are undescribed Not recommended (see below)
DS card slot — Not used — Out of scope

Today a multiboot program reaches the DUO through put_blob in duo_events.py. The sending program mbsend takes one 32-bit word per PUT packet (0x2C): a whole 8-byte USB round trip carries only 4 bytes of the file.

At about 18 ms per round trip (FINDINGS.md), that works out as:

Program Size Load time today
Bonus Disc client.skip_handshake.bin 27.6 KB about 2 minutes
Channel pokechan.standalone_en.bin 116 KB about 8½ minutes

These figures are the measured round-trip time multiplied by the number of packets. They have not been timed on the hardware.

Two improvements need no firmware change, because programs already receive Datel's raw 8-byte recv8/send8 routines in their API table (firmware/programs/link_core.h):

  • Raw 8-byte packets. The program would receive the file the way the firmware's own UPLOAD (0x1E) does: 8 data bytes per packet, one acknowledgement each, strictly alternating. That halves the load time.
  • Compression. Send the file LZ77-packed and unpack it on the DUO's GBA with the BIOS (LZ77UnCompWram) before the multiboot.
  • The Channel variant contains about 38 KB of zero padding and pictures, so it should shrink a lot.
  • The Bonus Disc's client.bin is already packed and would gain little.

The firmware's own UPLOAD can't simply be pointed at the buffer: it only writes inside the 12 KB program area (0x02038000-0x0203AFFF, checked by LAB_SETADDR). Changing that would mean a firmware update.

2. Bigger multiboot programs fit in RAM that is never touched

The GBA BIOS accepts multiboot programs up to 255.75 KB after the header. mbsend accepts 131,024 bytes, because its buffer is Datel's 128 KB SendFile buffer at 0x02010030 (BLOB_AT/IMAGE_MAX in firmware/programs/mbsend.c). The limit is in the program, not the firmware.

In the simulator, nothing writes to EWRAM between 0x02000400 and 0x0200FFFF in any of the three activities. Datel's only early-EWRAM writes are a few words at 0x02000000, from 0x0800BA08. Nothing writes above a 125 KB image either, up to 0x02037BFF; the program area starts at 0x02038000.

A buffer from 0x02000400 to 0x02037BFF would hold about 222 KB: most of what the BIOS allows, though not all of it.

Caveats:

  • The simulator only exercises USB server mode and our commands. Datel's menus, cheat engine and DS functions may use that RAM, but they are not running while a program runs.
  • No program found on the Pokémon discs needs more than 128 KB. The largest are XD's maxbtl at 107 KB and Colosseum's colbtl at 92 KB. So this matters only for other people's programs.

3. IWRAM is almost empty

Only three 1 KB pages are written: Datel's variables at 0x03000000 and 0x03002000, and the stacks at the top. IWRAM is the GBA's only zero-wait-state RAM with a 32-bit bus.

It would be the place for code whose timing matters, for example if link timing ever had to be generated in software. Nothing in the toolkit needs it today.

4. The DUO's flash: little to gain, real risk

  • The firmware image (191,172 bytes) has no blank space left. Reckless's additions fill Datel's padding at 0x0801E7C2-0x0801FD90, and the script found no 0xFF run of 1 KB or more.
  • Two stretches beyond it are undescribed: 5.3 KB between the image's end and Datel's storage at 0x08030000, and 16 KB at 0x0803C000-0x0803FFFF. Their contents are on the device, not in the repository. A read-only lab script (maxduo_saves.py --lab) could check whether they are blank.
  • Using flash for storage means writing to it. The only flash-writing path the toolkit has is Datel's update process, which rewrites the firmware. A mistake there can stop the DUO from booting. The GBA could send a multiboot program straight from flash, as Emerald does from its ROM. That would avoid the RAM limit, but RAM already holds about 222 KB, so the risk buys almost nothing.
  • Datel's 256 KB code database is Datel's own data. Nobody has measured how full it is.

5. What the DUO has that the toolkit does not touch

  • The DS card slot. It belongs to the MAX Drive DS side, so it is outside a GBA toolkit.
  • VRAM, palette and OAM. Datel's screen uses them. They are not good general storage.

What was done (22 November 2026, the same day)

The owner asked for all three recommendations below. Status:

  1. Faster load: done (simulator; hardware untested).
  2. mbsend has a fast load (POLL 22). The PC sends the file as raw 8-byte packets, each answered (0x2D, count), so the link still strictly alternates.
  3. Optionally the file is LZ77-packed and unpacked on the DUO's GBA by its BIOS (SWI 11h). The packed bytes sit at the top of the buffer and unpack to its start.
  4. duo_events.py (lz77_pack, lz77_unpack_in_place, load_image_fast) only packs when the file shrinks by at least 10% and a byte-by-byte replay of the BIOS's unpacking shows the output never reaches input not yet read. The CRC of the whole result is checked either way.
  5. The simulator's BIOS model gained SWI 11h (tests/hwsim.py lz77_swi), byte by byte in the BIOS's order, so an overrun would show.
  6. New load times, at ~18 ms per USB round trip: the Bonus Disc variant about 1 minute (was 2; already packed, so sent unpacked); the Channel variant about 2.6 minutes (was 8.7; packed 116,128 -> 68,968 bytes). See extracted/fastload_estimates.txt.
  7. Bigger buffer: done. mbsend's buffer is now 0x02000400-0x02037BFF: 227,328 bytes, of which 227,280 are for the file (was 131,024). The program itself grew from 2,792 to 3,084 bytes, still well inside its area.
  8. Flash: left alone. A read-only lab job to see whether the two undescribed areas are blank is ready: lab/jobs/flash_free_check.json. Run it with python maxduo_saves.py --lab script lab/jobs/flash_free_check.json. Each area is blank if its CRC matches the value under "expect" in the file.

Tests (in tests/test_v4.py):

  • All four existing multiboot tests pass unchanged.
  • Multiboot fast load: a 144 KB random program (beyond the old limit) goes over raw packets and boots.
  • Multiboot fast load, packed: a padded program goes packed, SWI 11h unpacks it to 0x02000400, and every byte arrives. An image whose unpacking would overrun its input is detected and sent unpacked.
  • The real Channel variant through the new path: intact, CRC matches, booted (extracted/channel_eur/emu/pathA_sim_standalone_fastload.txt).
  • mbsend was rebuilt with clang 18.1.3 (the version the repository pins). Built from the old source, it is byte-identical to the copy that was embedded, which confirms the toolchain matches. Only mbsend was re-embedded.

Reading the GBA's own BIOS (added 22 November 2026)

python duo_events.py bios runs firmware/programs/biosdump.c on the DUO's GBA.

  • How it reads the BIOS. It reads all 16 KB through the BIOS routine MidiKey2Freq (SWI 1Fh), with the formula GBATEK gives for exactly this. The BIOS can only be read by its own code, so the program asks a BIOS routine to do the reading.
  • Where it goes. The PC fetches the copy word by word, checks the CRC, and keeps it in bios/, which is git-ignored because it is Nintendo's code.
  • Worked on hardware on 22 November: CRC-32 81977335 and MD5 a860e8c0b6d573d191e4ec7db1b1e4f6, the retail BIOS. That first use settled the 0xBD question (see GAMECUBE_MULTIBOOT.md).
  • What it is for: reading the BIOS's own multiboot receive code (does it check 0xBD?), and running the real BIOS in the emulators.

Recommendations, in order

  1. A faster mbsend load path. Raw 8-byte packets roughly halve the time; adding LZ77 helps padded programs such as the Channel variant much more. No firmware change is needed: it is a new build of mbsend plus the PC side, both testable in the simulator first.
  2. Optionally, a bigger mbsend buffer (0x02000400-0x02037BFF, about 222 KB), only once a program actually needs it. It would be checked in the simulator against a full set of Datel activities first.
  3. Leave the flash alone, unless a read-only lab check finds the undescribed areas blank and a use appears that RAM can't serve.