HW 2: Bus Analysis and Debug Port Discovery
Covers: Weeks 3–4 Due: Friday of Week 5 — 30 October 2026, 23:59:59 Points: 100
Introduction
HW #1 got a signal off a board using the simplest possible interface. This assignment moves to the buses that carry the interesting data — I2C and SPI — and then to the interface that bypasses the firmware entirely, JTAG/SWD.
The through-line: each interface you add gives you a different kind of access. UART gives you what the firmware chose to say. I2C and SPI give you what the firmware says to its own peripherals, which it did not intend for you to read. JTAG gives you the silicon, regardless of what the firmware wants.
One thing about the unknown target is worth saying plainly, because it changes how you work. The firmware is undocumented, but the board is not — it is built on a published reference design, and you identified the SoC in HW #1 Task 1. That asymmetry is the common case in real assessments: vendors ship reference designs with the chip markings intact, the silicon vendor publishes the schematic and a pin-by-pin table of what every header pin is wired to, and the only genuinely secret thing is the software. So the pin-finding work in this assignment is partly bench measurement and partly document archaeology, and full credit requires both — a pin you found in a table and then confirmed on the bench, not one or the other.
Use your own Feather stack as a known-good reference whenever you need to calibrate a tool or a decoder setting. It is much cheaper to discover that your logic analyzer’s threshold is wrong on hardware whose behavior you already know.
Tasks
Task 1 — I2C capture and decode
20 points.
The target carries an ST MEMS e-compass — a 3-axis accelerometer and magnetometer in one package — on an I2C bus, and the firmware talks to it at boot. You have the part’s datasheet and the board’s pin tables. You do not have the firmware.
- Identify the two candidate I2C pins on the extension headers and justify your choice before you probe: name the MCU port pins, the header pins they appear on, and the document and table you got that from.
- Confirm the identification electrically. An idle I2C bus is not ambiguous — say what you measured and why it rules out the alternatives.
- Attach your logic analyzer to SDA and SCL and capture the first few milliseconds after power-on. Decode it and include the screenshot.
- The firmware probes several addresses at boot. From the decoded capture
alone, report:
- Every address the firmware addressed, as a 7-bit address, and how you distinguished the address from the R/W bit. Review Addressing and the acknowledge if the shifted-by-one problem is not yet second nature.
- Which addresses ACKed and which NAKed, and where in each transaction you can see it.
- What each ACKing address corresponds to, cross-referenced against the e-compass datasheet. One package answers at more than one address; explain why.
- At least two of the NAKing addresses, and what part the firmware’s author was plausibly looking for at each. At least one of them is a single bit away from an address that ACKed — find it, and say what that near-miss would cost you if you misread one bit of your decode.
- The capture contains at least one transaction that is longer than an address probe. Report it byte by byte — target address, register address, value — explain how its shape on the bus differs from the probes around it, and say what that write configures, per the datasheet.
- Explain in your own words why an I2C capture tells you what devices exist on a board, while a SPI capture on MOSI/MISO alone does not.
⚠️ Newer revisions of this board fit a different e-compass part than older ones, with the same bus addresses and a different register map. If your register decode disagrees with your datasheet, suspect the datasheet before you suspect the capture, and report which part your board actually has.
Task 2 — SPI: find the bus, then take it
25 points.
Where this device keeps its firmware is the first thing to settle, and the answer decides how you will extract it in HW #3. The SPI work in this task then happens against a MEMS part that is genuinely on the board — a better teaching target than a flash chip, because it has a register map, a documented command format, and an identity register that will tell you something your visual inspection cannot.
- Where does this device keep its firmware? Answer from evidence, not assumption: your HW #1 board survey, the SoC’s datasheet, and the memory sizes in the boot log. State the case — internal flash on the SoC, or an external flash package — and name the extraction route that case implies. “There is no external flash package on this board” is a perfectly good answer if that is what your evidence says; what is not acceptable is assuming a part is there because devices usually have one. Carry this answer into HW #3 Task 1; it is the decision that task opens with.
- Identify the four SPI signals for the gyroscope on the extension headers — SCK, MOSI, MISO, and CS — the same way you did in Task 1: from the pin table first, then confirmed on the bench. Note that this part’s CS pin also selects between its SPI and I2C interfaces, which matters for step 4.
- Sniff before you drive. Capture all four lines with the board running normally and report what you see. Your finding here determines whether the next step is safe to attempt, so state the conclusion explicitly: is anything else driving this bus?
- Take the bus. With a Bus Pirate, Tigard, or equivalent as SPI master,
read the gyroscope’s identity register and report the byte you got back.
- Give the command byte you sent and the arithmetic that produced it, in the form of the worked example below.
- State the clock polarity and phase you used and cite the datasheet sentence that determines them. If you had to try more than one combination, say so and say what the wrong ones looked like.
- Decode the value. Which part is actually fitted to your board? More than one part has been shipped in this position, each with its own identity value, and the board revision printed on the silkscreen is not a reliable guide to which one you have — the published board-support packages disagree with each other about the revision boundary. Report what the silicon said, which datasheet it sends you to, and whether it agrees with your HW #1 Task 1 identification.
- Perform a multiple-byte read of a contiguous block of configuration registers in one transaction, and report the values. Then repeat the same read with the address auto-increment bit cleared and include both captures. Explain the difference in one or two sentences — it is a one-bit change to one byte, and it is the most common reason a register dump comes back looking like nonsense.
- From the configuration registers you read, state whether the firmware has configured this part or left it in its reset state, and give your evidence.
⚠️ Do not let two devices power the board. If your probe or adapter can supply the target, know which way the current is going before you connect it. Pick one source of 3.3 V and verify the other is not driving the rail.
Task 3 — Bus behavior under contention
15 points.
A short written analysis, grounded in what you did in Task 2.
- Explain what happens electrically when two devices drive the same push-pull SPI clock line in opposite directions, and why I2C’s open-drain wiring does not have the same failure mode. See Bus contention.
- In Task 2 you took over a bus on a board whose processor was still running. State what made that safe on this target, and then state what you would have had to do first if it had not been — give two methods for keeping a running host off a bus you want to drive, with a specific risk of each.
- One of those methods is holding the host in reset. Explain what that does to a bus whose traffic the host was generating rather than merely sharing, and how that difference would show up in a capture. This is a diagnostic worth having: it tells you whether the thing you are sniffing is a device or a performance.
- The gyroscope also supports a 3-wire mode in which the data output is multiplexed onto the input line. Describe what a capture of a 3-wire transaction looks like compared to the 4-wire one you took, and how you would recognize that you were looking at one.
- Under what circumstances would you stop trying to read a part in-circuit and desolder it instead? Give a concrete decision criterion, not “when it is difficult.”
Task 4 — Debug port discovery
25 points.
- Survey the target for debug interfaces: headers, jumpers, test pads, via clusters. Photograph and document each candidate, including anything that is unpopulated or silkscreened but unused.
- This board hands you more than a typical product would — document what it gives you and what it costs. Specifically: the on-board debug probe, the connector that exposes the debug signals, that connector’s full pinout, and the jumpers that determine who owns the debug bus. Cite the table you got each from.
- Then do it the hard way, because products do not come with on-board probes: locate the SoC’s debug pins on the extension headers and bring up a session with an external probe — a Black Magic Probe, or a second ST-LINK or equivalent driven by OpenOCD — with the on-board probe disconnected from the bus. Report the wiring you used and what you had to change to get the on-board probe out of the way.
- Determine whether the target exposes JTAG, SWD, both, or neither, and document your method — pin table, standard-pinout guess, or JTAGulator scan. The SoC’s full JTAG signal set and what actually reaches a connector are not the same thing; say which signals reach where, and what wiring would be required to attempt full JTAG.
- Capture and report the IDCODE your probe reads. Then read the SoC’s own device identification register over the same connection and report that too. These are two different values identifying two different things — see The tell: IDCODE — and a submission that conflates them loses the points for this item. State whether the device ID agrees with your HW #1 chip identification. Disagreement is an interesting finding, not a failure: investigate and report it.
- Attempt to halt the core. Report whether it succeeded, the exact command you used, and its output. If it failed, report the error and your interpretation.
- If you find no working port, document the search space you covered — which pin combinations, which protocols, which probe — and state what you would try next given more time. A well-documented negative result receives full credit; an undocumented one does not.
Task 5 — Lockdown analysis
15 points.
Written analysis, grounded in what you observed.
- Based on your Task 4 results, state whether debug access is locked on your target, and give your evidence. “I got an IDCODE” is not sufficient evidence either way; explain why not.
- Attempt to read the SoC’s option bytes over your debug connection and report the read-protection value, or report the failure. Either outcome is a finding — say what yours tells you.
- Look up this SoC family’s read-protection mechanism in its reference manual. Describe how it is meant to work: how many levels there are, which one is reversible and at what cost, and which one is permanent. Name the register or byte that controls it.
- Describe one documented technique for defeating read protection on an STM32 part, with a citation to primary work. Say whether the technique applies to this family or to a different one, and what would have to be true for it to carry over. Do not attempt it; this task is analysis only. Fault injection against course hardware is available as a final project option.
- If debug is not locked on your target, explain what an attacker with five minutes of physical access could do, and what it would have cost the vendor to prevent it. Be specific about the cost — the mechanism has a real downside for the vendor, and naming it is part of the answer.
Worked example: a register read command byte
To make the expected form clear, here is the shape of a full-credit answer to Task 2.4.1 — for a different register than the one the task asks for, so you cannot copy it.
This part does not use a flash-style command set. A transfer is 16 clocks: one command byte, then one data byte. The command byte is bit-packed, and the datasheet numbers its bits in transmission order, which is the opposite of the convention you are probably used to. First bit on the wire:
bit 0 RW 1 = read, 0 = write
bit 1 MS 1 = auto-increment address across multiple bytes
bits 2-7 AD5..AD0, the register address
So to read CTRL_REG4 at address 0x23, as a single byte:
RW = 1 -> 0b1_______ = 0x80
MS = 0 (single byte) -> 0b_0______ = 0x00
AD = 0x23 = 0b100011 -> 0b__100011 = 0x23
----------
command byte 0b10100011 = 0xA3
Clock out 0xA3, then clock out one dummy byte while the part drives its data
line, and the register contents come back during that second byte. In a
decoded capture:
CS ‾‾‾\___________________________/‾‾‾
MOSI A3 00
MISO -- 00
The 0x00 on MISO is the real reset value of that register, which is a useful
sanity check on your wiring: a part that is not responding gives you 0x00 too.
That is why Task 2.4 asks for the identity register instead — it is the one
register whose correct answer is not zero, so it distinguishes “working” from
“wired wrong.”
Submission
Commit hw2/hw2.md and supporting images to your repository before the
deadline.
Carry two things forward into HW #3: your Task 2.1 conclusion about where the firmware lives, and the working debug access from Task 4. HW #3 Task 1 opens by asking you to state which extraction route applies and to justify it from this assignment’s evidence.
Grading
| Item | Points |
|---|---|
| Task 1 — I2C capture and decode | 20 |
| Task 2 — SPI: find the bus, then take it | 25 |
| Task 3 — Bus behavior under contention | 15 |
| Task 4 — Debug port discovery | 25 |
| Task 5 — Lockdown analysis | 15 |
| Total | 100 |
Notebook quality is assessed within each task rather than separately. An undocumented result is an incomplete result.
References
- NXP UM10204, I2C-bus specification and user manual — https://www.pololu.com/file/0J435/UM10204.pdf
- ST UM1570, Discovery kit with STM32F303VC MCU (board pin tables, debug connector, jumpers) — https://www.st.com/resource/en/user_manual/um1570-discovery-kit-with-stm32f303vc-mcu-stmicroelectronics.pdf
- ST RM0316, STM32F303 reference manual (flash, option bytes, read protection, debug support) — https://www.st.com/resource/en/reference_manual/rm0316-stm32f303xbcde-stm32f303x68-stm32f328x8-stm32f358xc-stm32f398xe-advanced-armbased-mcus-stmicroelectronics.pdf
- ST L3GD20 datasheet (SPI read/write protocol, register map, WHO_AM_I) — https://www.st.com/resource/en/datasheet/l3gd20.pdf
- ST I3G4250D, the gyroscope fitted to later board revisions — https://www.st.com/en/mems-and-sensors/i3g4250d.html
- ST LSM303DLHC datasheet — https://www.st.com/resource/en/datasheet/lsm303dlhc.pdf
- ST LSM303AGR, the e-compass fitted to later board revisions — https://www.st.com/en/mems-and-sensors/lsm303agr.html
- IEEE 1149.1 (JTAG) overview — https://standards.ieee.org/ieee/1149.1/4484/
- ARM Debug Interface Architecture Specification — https://developer.arm.com/documentation/ihi0031/latest/
- Obermaier and Tatschner, Shedding too much Light on a Microcontroller’s Firmware Protection, USENIX WOOT 2017 — https://www.usenix.org/conference/woot17/workshop-program/presentation/obermaier
- Schink and Obermaier, Exception(al) Failure — Breaking the STM32F1 Read-Out Protection — https://blog.zapb.de/stm32f1-exceptional-failure/
- Black Magic Probe documentation — https://black-magic.org/
- OpenOCD user guide — https://openocd.org/doc/html/index.html
- JTAGulator — https://grandideastudio.com/portfolio/security/jtagulator/
- Bus Pirate documentation — https://buspirate.com/
- Tigard — https://github.com/tigard-tools/tigard
Related course pages: Schedule · I2C · SPI · JTAG and SWD · Tools · HW #1 · HW #3 · Final Project
🛠️ Maintenance note: this assignment is written against the target board having no external SPI flash and a MEMS gyroscope on SPI. If the target hardware changes, Task 2 is the part that breaks. Two board-revision hazards to re-check each term: later revisions fit a different gyroscope and a different e-compass than earlier ones, with different identity values and register maps, so Task 1’s register decode and Task 2.4’s identity value both depend on which boards are in the course stock — inventory them before the term and keep a note of which revisions you have. Task 4 depends on the boards being left at read-protection level 0; if you hand out locked boards deliberately, label them and keep unlocked spares. JTAGulator and Black Magic Probe firmware both change command syntax between major versions.