2026-04-22 18:46:54 +00:00
|
|
|
# ROM Analysis Walkthrough
|
2026-04-12 13:55:24 +00:00
|
|
|
|
2026-04-22 18:46:54 +00:00
|
|
|
## 1. Determine the ROM Format
|
2026-04-12 13:55:24 +00:00
|
|
|
|
2026-04-22 18:46:54 +00:00
|
|
|
ADSP-2191 instructions are 24 bits (3 bytes). A raw dump can be:
|
2026-04-12 13:55:24 +00:00
|
|
|
|
2026-04-22 18:46:54 +00:00
|
|
|
- **Packed (3 bytes/word)**: Most common for SPI flash dumps.
|
|
|
|
|
Load directly: `r2 -a adsp219x -b 24 dump.bin`
|
|
|
|
|
- **Padded (4 bytes/word)**: 32-bit aligned with a leading 0x00.
|
|
|
|
|
Strip padding or use `r2 -s 1` to skip the first pad byte.
|
|
|
|
|
- **Boot stream**: Contains block headers (target address, byte
|
|
|
|
|
count, flags) followed by data. Requires parsing the header
|
|
|
|
|
format first.
|
2026-04-12 13:55:24 +00:00
|
|
|
|
2026-04-22 18:46:54 +00:00
|
|
|
### Quick Format Check
|
2026-04-12 13:55:24 +00:00
|
|
|
|
2026-04-22 18:46:54 +00:00
|
|
|
Look at the first few bytes. If you see `00 00 00` at offset 0
|
|
|
|
|
(a NOP), you likely have packed 3-byte format. If you see
|
|
|
|
|
`00 00 00 00` followed by meaningful data at offset 4, it is
|
|
|
|
|
probably 4-byte padded.
|
2026-04-12 13:55:24 +00:00
|
|
|
|
2026-04-22 18:46:54 +00:00
|
|
|
## 2. Find the Entry Point
|
2026-04-12 13:55:24 +00:00
|
|
|
|
2026-04-22 18:46:54 +00:00
|
|
|
The reset vector is at PM address 0x0000. Typical patterns:
|
2026-04-12 13:55:24 +00:00
|
|
|
|
2026-04-22 18:46:54 +00:00
|
|
|
0x0000: JUMP main (Type 10a, opcode starts with 0x1C)
|
|
|
|
|
0x0000: NOP (entry at next instruction)
|
2026-04-12 13:55:24 +00:00
|
|
|
|
2026-04-22 18:46:54 +00:00
|
|
|
The interrupt vector table occupies the first ~128 PM words,
|
|
|
|
|
with 4-word spacing per vector. Most vectors contain RTI (return
|
|
|
|
|
from interrupt) or JUMP to a handler.
|
2026-04-12 13:55:24 +00:00
|
|
|
|
2026-04-22 18:46:54 +00:00
|
|
|
## 3. Identify Code vs Data Regions
|
2026-04-12 13:55:24 +00:00
|
|
|
|
2026-04-22 18:46:54 +00:00
|
|
|
**Code regions** produce coherent disassembly: register loads,
|
|
|
|
|
compute instructions, jumps, and loops in logical sequence.
|
2026-04-12 13:55:24 +00:00
|
|
|
|
2026-04-22 18:46:54 +00:00
|
|
|
**Data regions** (coefficient tables, lookup tables) produce
|
|
|
|
|
nonsensical disassembly: random-looking mnemonics, impossible
|
|
|
|
|
register combinations, jumps to invalid addresses. Mark these
|
|
|
|
|
as data in r2:
|
2026-04-12 13:55:24 +00:00
|
|
|
|
2026-04-22 18:46:54 +00:00
|
|
|
Cd 300 @ 0x1000 # Mark 300 bytes as data at offset 0x1000
|
2026-04-12 13:55:24 +00:00
|
|
|
|
2026-04-22 18:46:54 +00:00
|
|
|
## 4. Recognize DSP Patterns
|
2026-04-12 13:55:24 +00:00
|
|
|
|
2026-04-22 18:46:54 +00:00
|
|
|
### FIR Filter
|
2026-04-12 13:55:24 +00:00
|
|
|
|
2026-04-22 18:46:54 +00:00
|
|
|
CNTR = N;
|
|
|
|
|
DO loop_end UNTIL CE;
|
|
|
|
|
MR = MR + MX0*MY0 (SS), MX0 = DM(I0,M0), MY0 = PM(I4,M4);
|
|
|
|
|
loop_end: ...
|
2026-04-12 13:55:24 +00:00
|
|
|
|
2026-04-22 18:46:54 +00:00
|
|
|
Look for: Type 11 (DO UNTIL CE) followed by Type 1 multifunction
|
|
|
|
|
instructions with MAC operations.
|
2026-04-12 13:55:24 +00:00
|
|
|
|
2026-04-22 18:46:54 +00:00
|
|
|
### IIR Filter (Biquad)
|
2026-04-12 13:55:24 +00:00
|
|
|
|
2026-04-22 18:46:54 +00:00
|
|
|
Nested loops: outer loop over samples, inner loop over biquad
|
|
|
|
|
sections. Contains ASHIFT for scaling between stages.
|
2026-04-12 13:55:24 +00:00
|
|
|
|
2026-04-22 18:46:54 +00:00
|
|
|
### Initialization Sequence
|
2026-04-12 13:55:24 +00:00
|
|
|
|
2026-04-22 18:46:54 +00:00
|
|
|
Sequences of Type 6/7 instructions loading I/M/L registers.
|
|
|
|
|
This sets up circular buffers for the signal processing kernel.
|
2026-04-12 13:55:24 +00:00
|
|
|
|
2026-04-22 18:46:54 +00:00
|
|
|
## 5. Useful r2 Commands
|
2026-04-12 13:55:24 +00:00
|
|
|
|
2026-04-22 18:46:54 +00:00
|
|
|
e asm.arch = adsp219x
|
|
|
|
|
e asm.bits = 24
|
|
|
|
|
pd 200 # Disassemble 200 instructions
|
|
|
|
|
pD 600 # Disassemble 600 bytes (= 200 instructions)
|
|
|
|
|
/x 1c00 # Find unconditional JUMPs
|
|
|
|
|
/x 16 # Find DO UNTIL loops
|
|
|
|
|
/x 0a # Find RTS/RTI instructions
|
|
|
|
|
V # Enter visual mode
|