MAX DUO Pokémon Toolkit GitHub

Home / How it works

The DUO and its firmware

The DUO isn't a computer of its own. When you switch the GBA on, the GBA itself runs Datel's program from the DUO's flash as if it were a game. The DUO adds three things:

  • A switch (an Actel logic chip): whether the GBA sees the DUO's program or the game in the DUO's slot.
  • A USB chip (a Cypress microcontroller): passes 8-byte messages between the PC and the GBA, one at a time.
  • Its own flash (512 KB): Datel's program, the code database, the DS saves.
PC ══ USB ══ Cypress USB chip ══ one-byte link, taking turns ══╗
                                                               ║
GBA ══ cartridge bus ══ Actel switch ══ DUO flash (Datel's program, codes, DS saves)
                              └── your GBA game (ROM + save chip)

Reading a save

  1. The PC uploads a tiny CRC-checked program into the GBA's RAM (the DUO's program must switch itself out of view).
  2. It flips the switch so the GBA sees the game.
  3. It reads one byte of the game's ROM - the wake read. The save chip ignores everything until the ROM has been touched after a switch; finding this took several failed versions.
  4. It reads the save one byte at a time (the save bus is 8 bits wide) and computes a CRC-32.
  5. It switches back and checks the DUO's program is visible again.
  6. The data goes to the PC in compressed 4 KB blocks, each with a CRC; the PC compares the whole bank with the GBA's CRC, reads again on any disagreement, and refuses after two.

Why about 50 seconds: the USB chip holds one 8-byte message, and the two sides take turns - about 9 ms a turn, so 18 ms per 8 bytes. Compression helps: a nearly empty save copies in about 25 s.

Programs from RAM (v4.2)

Every link feature is a small C program (ARM7 Thumb, built with clang) that the PC uploads into the GBA's RAM and the firmware runs: the Wireless Adapter and distributor (adapter.c), the e-Reader (ereader.c), the trade partner (trade.c), Record Mixing (mix.c), the Colosseum (colosseum.c), the Tower, Blender, Contest, multiboot sender, the adapter check and the over-the-air builds. They must fit below 0x0203AE00; duo_events.py carries copies, and a test checks each against a fresh build.

The firmware's own code lives in an unused padding area of Datel's image; everything Datel wrote stays where it was. Next: the USB protocol.