JTAG programmer recording (SVF)
On a test bench, the session log of a JTAG programmer was saved: dump.svf (Serial Vector Format 1.1). For each SDR, the log contains the values sent (TDI) and the values returned from the device (TDO). There are two devices in the chain: ours (IR = 4 bits) and another one after it in bypass (padded with TIR/TDR; the SDR lengths relate only to our device). In SVF, the least significant bit of a hex value is shifted into TDI/TDO first.
Debug module: IR = 0x8 (DBGACC), DR = 35 bits (LSB first). TDI: bit0 = RnW (1 = read), bit2..1 = ADDR (0 CTRL, 1 TAR, 2 DRW, 3 RDBUFF), bit34..3 = data (on write). TDO: bit2..0 = ACK for that request (010 = OK, 001 = WAIT: the request was not accepted and is dropped, and the programmer sends it again), bit34..3 = RDBUF — the result of the last ACCEPTED DRW read up to this scan (that is, the result arrives in the next scan; the value returned when a read starts is stale). Semantics: a TAR write = setting the address; a DRW read: RDBUF = memory[TAR], then TAR += 4; a DRW write: memory[TAR] = data, TAR += 4; reads of CTRL/RDBUFF and TAR/CTRL do not affect RDBUF. Words consist of little-endian (LE) bytes.
Memory: at 0x08000000 there is a ROM header: 'SECR' | pointer u32 | length u32 | crc32 u32 (for the flag bytes), followed by a banner. The secret buffer (the flag in ASCII, padded with zeros) is at the address given by the pointer. Task: reconstruct the memory image and find the flag: BAYROQ{JTAG_SVF_...}. (Note: the last 16 characters of the flag are lowercase hexadecimal digits.)