Pokémon mini Development Documentation

PokeCard 512

Designed by Lupin, the PokeCard 512 was a series of three flash cards originally based on JustBurn’s flash cart.

There was never a shell specifically made for this, but rev 2+ should fit in Ksanto’s with some modification to the bottom shell. Version 1 does not need a shell and might not even work with one.

There were a few label designs for this:

PokeCard 512 rev 2.1

Sold for €35 for just the cart and €55 for the linker.

Features

Issues / limitations

Technical specifications

Pins are the same as the PokeCard 512 rev 2

Differences from rev 2

PokeCard 512 rev 2.1 flasher

Connects to the PC with a USB 2.0 Mini-B cable. This should support rev 2.0 cards, but have not tested it personally.

Use PokeFlash GUI to flash with this. It can also craft multicarts for you.

Technical specifications

Pins

TODO: confirm..somehow, TMS/TDO don’t seem right

Pin # Name Description
1 GND Ground
2 TMS  
3 TDO  
4 TDI  
5 TCK  
6 VCC 3.3V in

PokeCard 512 rev 2

Despite both being considered rev 2, there were two versions of this card. The differentiator is the code flashed onto the CPLD, which was updated on carts created after 2011-04-17.

The CPLD of the early versions can be updated by following the steps here. This will allow multicart functionality.

Features

Issues / limitations

Technical specifications

Pins

Pin # Name Description
1 GND Ground
2 PG_SDO Programming serial data out
3 PG_ON Programming on?
4 PG_SDI Programming serial data in
5 PG_CLK Programming clock
6 VCC 3.3V in

PokeCard 512 rev 2 flasher

Connects to the PC with a USB 2.0 Mini-B cable. This should support rev 2.1 cards, but have not tested it personally.

Use PokeFlash GUI to flash with this. It can also craft multicarts for you.

Technical specifications

Pins

TODO: confirm..somehow, TMS/TDO don’t seem right. They’re twisted in Mr.Blinky’s picture but not on Agilo’s soldered-in version of the linker, and I’m expecting TDO should go to PG_SDO

Pin # Name Description
1 GND Ground
2 RST Unconnected
3 TRST Unconnected
4 TMS  
5 TDO  
6 TDI  
7 TCK  
8 VCC 3.3V in

Reprograming the CPLD using JTAG

You probably need the rev 2 flasher to update the CPLD, it’s unknown if rev 2.1’s works.

If you have a rev 2 flasher with the 8-pin header or want to add it yourself, you can grab the 8-pin cable above or otherwise grab a 6-pin JST SH-style breakout board that you can plug the existing cable into.

  1. Solder one wire to the GND pin and one to the VCC pin of the cart-side JST SH-style header
  2. Solder one wire to each of the three pads on the back of the cart. Top to bottom these are TCK, TMS, and TDI
  3. Carefully solder one wire to the 5th pin down from the top-left of the CPLD
  4. Assuming the breakout board version, count the pins from the black wire (= pin 1, GND) and solder the wires into place: GND, TMS, TDO, TDI, TCK, VCC (TODO: confirm TMS/TDO)

Now connect the flasher to your PC as normal and use Lupin’s TestSuite to flash prog.svf from this zip.

PokeCard 512

We informally refer to this as rev 1, but it wasn’t labeled as such on the cartridge. This is more or less a recreation of JustBurn’s flash cart with some small adjustments.

Unlike its successors, these had to be programmed from the regular cartridge pins, requiring an official Pokémon mini connector ripped from the console.

This can be programmed by the PokeCard 512 flasher or a PokeUSB

Features

Issues / limitations

Technical specifications

PokeCard 512 flasher

This flasher requires an official PM cartridge connector, but was sold with them already attached. As such, it’s capable of dumping official cartridges. It’s possible this is an early version of PokeUSB.

Use PokeUSB on Windows XP to flash with this.

PokeCard 512 with linker top PokeCard 512 with linker bottom

Technical specifications

PokeUSB

This flasher requires an official PM cartridge connector, but was sold with them already attached. As such, it’s capable of dumping official cartridges.

Use PokeUSB on Windows XP to flash with this.

Technical specifications

PokeUSB 1.2 PokeUSB 1.0? PokeUSB prototype?

Multicart

Multicart is very simple on PokeCard 512 rev 2+ because the official flashing tool, PokeFlash GUI, can create them for you in the GUI. The bootloader supports up to 17 ROMs.

To do so, open the tool and add all your ROMs from the File menu. Once added, select the ROMs you want to make into a multicart (you can Ctrl+Click to select multiple) and add them to the ROM sets section by clicking the Add >> button. You must select at least two or it will not make a multicart. Now connect you PokeCard if you haven’t already and click Flash ROM set once it’s ready. Remember it can’t fit more than one commercial game, so you can only put (small) homebrew in the ROM set!

PokeFlash GUI

To get multiple tabs like this, you’ll have to edit PokeFlashGUI.ini manually. Simply increase the value of RomTabs and/or FlashTabs (ROM sets) under [Config] and the next time you open and close the tool it will create the necessary configs for you. You can change the Title under the tab config to change the names like in the image above.

Backup Save tool

To use the Backup Save tool, create a multicart. On the multicart menu, press the B button to open the Backup Save tool.

On this menu you can select a save slot to back up and press A to do so.

Pressing B again cycles through the other backup tools: Restore Save, Delete Save, then back to the Select Game menu.

To back up the save to your computer, you’ll need to use the command-line version of PokeFlash. Open a terminal to the location where PokeFlash.exe is and run ./PokeFlash.exe -d backup.min which will dump it to backup.min. You can then technically extract the save information, but it’s beyond the scope of this document to explain that in detail.

Save backup format

The location where save backups are saved depends on how many games are on the cart.

Offset Size Descrtipion
$00 4 Magic bytes: SGMN
$04 3 Time from seconds timer
$07 14 Defaults and time from EEPROM
$15 1 EEPROM save slot number
$16 18 EEPROM slot’s header
$28 1280 EEPROM slot’s data

BIOS backup tool

To use the Backup Save tool, create a multicart. On the multicart menu, press the B button to open the Backup Save tool then press the C button to enter the Flash Info screen. On here, press A to backup the BIOS to the cart.

To back up the save to your computer, you’ll need to use the command-line version of PokeFlash. Open a terminal to the location where PokeFlash.exe is and run ./PokeFlash.exe -d backup.min which will dump it to backup.min. The BIOS will have been saved to $000000 and is $1000 bytes long, you can open the backup in a hex editor such as HxD and extract the BIOS from here.

Writing from software

The PokeCard 512 rev 2+ offers full flash control from software. So any command - such as writing, erasing, getting manufacturer information, etc. - can be run from software.

Since flashing data to the cartridge requires entering command sequences which would be interrupted by reads, any functions which write to the cart must be run from RAM with interrupts masked (LD SC, #0C0h).

There are two registers the PokeCard offers:

#define FLASH_ADDR1 (*((volatile uint8_t _far *)0x080AAA))
#define FLASH_ADDR2 (*((volatile uint8_t _far *)0x080555))

In order to flash a single byte, perform the following sequence:

// rev 2 (which has a scrambled data bus)
FLASH_ADDR1 = 0x99;
FLASH_ADDR2 = 0x66;
FLASH_ADDR1 = 0x44;

// rev 2.1
FLASH_ADDR1 = 0x55;
FLASH_ADDR2 = 0xAA;
FLASH_ADDR1 = 0xA0;

// both, no need to scramble for the value in rev 2??
*((volatile uint8_t _far *)address) = value;
// wait ~32 more cycles, such as with _nop()s or a DJR loop

Bank switching

Because bank switching changes where the CPU reads from immediately, it’s recommended to switch from code running in RAM. If this is for a multicart, you can call _int(0x02) after to reset the console and load software from the new slot.

#define FLASH_ADDR2 (*((volatile uint8_t _far *)0x080555))
#define BANK_SWITCH (*((volatile uint8_t _far *)0x07FFFF))

// Unconfirmed but was in the notes, no mention of rev 2 tho
static inline void bank_reset(char rev2) {
	// Resets bank offset to $000000
	FLASH_ADDR2 = rev2 ? 0x41 | 0x90;
}

// Select an 8K bank
BANK_SWITCH = 0x00; // select bank  0 ($000000)
BANK_SWITCH = 0x01; // select bank  1 ($002000)
BANK_SWITCH = 0x02; // select bank  2 ($004000)
// ...
BANK_SWITCH = 0x3F; // select bank 63 ($07E000)

// The source for the multirom mentions this calculation
// for the bank offset, but it doesn't seem to be how
// PokeFlash assembles the ROM? not sure what it's about
offset = ((bank ^ 4) & 7) * 0x010000 + (bank & 0x38) * 0x0400;