| .github/workflows | ||
| CMakeModules | ||
| externals | ||
| hwtest | ||
| include/teakra | ||
| src | ||
| tests | ||
| .clang-format | ||
| .gitattributes | ||
| .gitignore | ||
| .lfsconfig | ||
| appveyor.yml | ||
| CMakeLists.txt | ||
| LICENSE | ||
| meson.build | ||
| README.md | ||
Teakra
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.
srccontains main source code for compiling portable libraries/tools. Detailed documentation for the Teak architecture and for peripherals is also here.includecontains the header for the emulator and the disassembler libraries.dsptestercontains the source code of a 3DS tool that tests processor instructions and registersdspmemorytestercontains 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.