DSi/3DS DSP emulator, disassembler, assembler, and tester
Find a file
Kirill Zhumarin 48b078bfbe
Some checks failed
build / build (ubuntu-latest) (push) Failing after 3m4s
build / build (macos-latest) (push) Has been cancelled
build / build (windows-latest) (push) Has been cancelled
Fixes
2026-10-30 23:09:33 +03:00
.github/workflows ci: enable test assets and cache them (#64) 2025-08-24 16:34:20 -04:00
CMakeModules new interface 2018-02-11 11:54:39 +02:00
externals Bump catch to 2.13.8 2022-02-24 11:17:58 +11:00
hwtest move hardware tests to a folder 2019-01-02 11:26:18 -05:00
include/teakra Fix TeakLite assembler and disassembler encodings 2026-09-24 23:41:15 +03:00
src Fixes 2026-10-30 23:09:33 +03:00
tests Fixes 2026-10-30 23:09:33 +03:00
.clang-format reformat everything 2018-08-02 01:08:59 +03:00
.gitattributes move the test file to correct place 2025-08-07 22:11:37 -04:00
.gitignore Add GitHub CI, remove broken Travis one 2025-08-06 16:16:39 +02:00
.lfsconfig ci: enable test assets and cache them (#64) 2025-08-24 16:34:20 -04:00
appveyor.yml appveyor: add tests 2018-12-09 13:35:44 -07:00
CMakeLists.txt ci: enable test assets and cache them (#64) 2025-08-24 16:34:20 -04:00
LICENSE Create LICENSE 2018-06-11 18:59:48 +03:00
meson.build Add Siemens Teak boot stream tools 2026-09-25 00:04:29 +03:00
README.md Add Siemens Teak boot stream tools 2026-09-25 00:04:29 +03:00

Teakra

Build Status Build status

Emulator, (dis-)assembler, tools and documentation for XpertTeak, the DSP used by DSi/3DS.

Many thanks to Martin Korth and many other contributers for their help and their excellent GBATEK doc!

Contents

Please refer to README.md in the following directories for their detail.

  • src contains main source code for compiling portable libraries/tools. Detailed documentation for the Teak architecture and for peripherals is also here.
  • include contains the header for the emulator and the disassembler libraries.
  • dsptester contains the source code of a 3DS tool that tests processor instructions and registers
  • dspmemorytester contains the source code of another 3DS tool that tests memory read/write, MMIO and DMA.

General Information of the XpertTeak

The XpertTeak DSP consists of a Teak-family architecture processor, and peripheral components including DMA, interrupt controller and audio input/output ports etc. The exact architecture of the processor is still unclear. GBATEK states that the architecture is TeakLite II, the successor of the TeakLite architecture. Their evidence is the TeakLite II disassembler bundled in RealView Developer Suite. However, a Teak family debugger from here shows that the "TEAK(-REVA, -REVB, DEV-A0, -RTL2_0)" contains very similar registers and instruction set described in GBATEK, while the "TeakLite-II" contains very different registers and instructions. This shows that the architecture is likely the original Teak, introduced along with TeakLite as a "non-Lite" expansion to it.

DSi and 3DS both include XpertTeak. However, their uses of XpertTeak are pretty different. Most DSi games don't use it at all. It's used by the "Nintendo DSi Sound" and "Nintendo Zone" system utilities, and by the "Cooking Coach" cartridge (according to GBATEK), where it appears to be intended for audio/video decoding. On the contrary, 3DS games all use XpertTeak for audio decoding and output.

Siemens/APOXI Teak tools

teak-assembler and teak-disassembler use the native PLOAD/DLOAD/BRANCH boot stream found in Siemens and APOXI firmware. The stream has no fixed segment table or segment-count limit. Build the tools with:

cmake -S . -B build
cmake --build build --target teak-assembler teak-disassembler

An assembly source contains program and data segments plus an entry point:

entry 0100
segment p 0100
nop

segment d 4000
data 1234
build/src/teak_assembler/teak-assembler source.asm firmware.bin
build/src/teak_disassembler/teak-disassembler firmware.bin listing.txt

The entry point may instead be supplied as --entry 0100. Load segments are automatically split into hardware-safe records of at most 507 words. Each numeric field is hexadecimal.

The disassembler treats PLOAD records as program code, DLOAD records as 16-bit data, and BRANCH as the entry point. Adjacent load records are joined before disassembly so an instruction and its expansion word may cross a record boundary.

Legacy and diagnostic tools

The 3DS-oriented makedsp1 and dsp1_reader tools remain available for the fixed-header DSP1 format.

pmb887x_dsp_emu

The emulator starts the PMB8876 Program MASK ROM and sends every container record through its shared-RAM boot protocol. The MASK ROM itself performs PLOAD, DLOAD, and the final BRANCH; the runner does not copy payloads directly into their destination addresses.

build/src/pmb887x_dsp_emu/pmb887x_dsp_emu [options] container.bin
Option Description
--cycles NUMBER Execute at most NUMBER runtime instructions after boot; default is 100000. Decimal and 0x-prefixed values are accepted.
--boot-cycles NUMBER Allow at most NUMBER instructions for MASK ROM boot and container transfer; default is 1000000.
--rom FILE Load the required PMB8876 Program MASK ROM dump, or a flat little-endian P-space image for other file sizes.
--data-rom FILE Load a 139264-byte PMB887x Data MASK ROM dump.
--self-test Exercise boot and runtime memory commands, validating acknowledgements and transferred data.
--trace Print every executed instruction.
--trace-mmio Print every access to the PMB887x MMIO window.
--dump-data FILE Dump the 64K-word data address space after execution.
--dump-program FILE Dump the 256K-word program address space after execution.
--help Print command-line help.

Example using matched PMB8876 revision 10, DSP Mask ROM ID 0x0801 images:

build/src/pmb887x_dsp_emu/pmb887x_dsp_emu \
  --rom pmb8876-0801-program-mask-rom.bin \
  --data-rom pmb8876-0801-data-mask-rom.bin \
  --self-test \
  --cycles 0 \
  --trace-mmio \
  container.bin

The 212992-byte Program ROM layout is mapped as fixed P:2000..9FFF plus three selectable P:A000..FFFF banks. The 139264-byte Data ROM layout is mapped as fixed D:8000..8FFF plus four selectable D:9000..CFFF views. D:DEA3[3:2] selects the program bank and D:DEA3[1:0] selects the data view.

The PMB887x D:DE00..EBFF register window currently uses stateful MMIO stubs: registers start at zero and retain writes. --trace-mmio reports every access with its full D: address. Individual PMB887x peripherals are not modelled yet. The Data MASK ROM is required for post-BRANCH firmware initialization and runtime MASK ROM commands such as READ_PROG.

--self-test validates the DSP Mask ID, one-word RAM boundaries, 509-word transfers, every Program/Data ROM bank, and boot-mode PLOAD, PREAD, DLOAD, and DREAD. It also verifies that boot and runtime write commands cannot modify MASK ROM. After loading the container, it tests BB_INIT, runtime WRITE_DSP/READ_DSP (IDs 32/33), WRITE_PROG/READ_PROG (IDs 34/35), all three command pipes, repeated command dispatch, and the disabled-command rejection path on Mask ID 0x0801. Scratch state is restored. Finally, the DSP is reset, both MASK ROMs and the container are reloaded, and one more runtime read is checked. Any failed command, acknowledgement, or data comparison produces a non-zero exit status.

The Mask ID is not hard-coded: both 0x0800 and 0x0801 are accepted when the ID reported in Shared RAM matches the loaded Program ROM. Program ROM, Data ROM, and the startup container must still belong to the same Mask revision.