DAP
DAP
Category: Debug/Programming
Overview
ARM DAP (Debug Access Port) is the CoreSight debug entry point that provides access to the processor's debug infrastructure via JTAG or SWD. The DAP contains a Debug Port (DP) and one or more Access Ports (APs) including the MEM-AP for memory-mapped access.
1. Theory & Fundamentals
- DP (Debug Port): Entry point via JTAG or SWD; contains IDCODE, CTRL/STAT, SELECT, RDBUFF
- AP (Access Port): Connected to DP; MEM-AP provides AHB/AXI bus access
- MEM-AP CSW: Control/Status Word — configures transfer size, mode
- MEM-AP TAR: Transfer Address Register — target memory address
- MEM-AP DRW: Data Read/Write — actual data transfer
- APSEL: SELECT register chooses which AP to address
- Multiple APs: One per bus master (AHB-AP, APB-AP, JTAG-AP)
2. Frame / Packet Structure
Protocol-specific to DAP.
See official documentation for complete frame formats.
3. Protocol Mechanics
- Standard Debug/Programming mechanics apply
- See hardware implementation for specific protocol flow
4. Hardware Implementation
- Dedicated hardware probe/interface required
- Standard MCU/embedded connection
5. Register-Level / Configuration
// Access ARM memory via DAP MEM-AP (using CMSIS-DAP or J-Link)
// OpenOCD / pyOCD handles DAP internally
// Direct DAP access example:
// 1. Write APSEL=0 (select MEM-AP)
// 2. Write CSW = 0x23000052 (32-bit, auto-increment)
// 3. Write TAR = 0x20000000 (SRAM address)
// 4. Read DRW to get memory contents
// Most tools abstract this: pyocd read32 0x20000000
6. Driver / Software Development
- Implement send/receive based on protocol specification
- Use official SDK or library where available
7. Debugging & Testing
- Use official debug tools for analysis
- Logic analyzer for signal verification
- Common issues: Timing, voltage levels, clock configuration
8. Real-World Applications
- MCU programming in production
- In-system firmware updates
- Debug during development
- Post-mortem fault analysis
- Test automation
9. Advanced Topics & Edge Cases
- Advanced features depend on specific MCU family
- Security lock bits and read protection
- Production programming automation
10. Standards & Variants
| Interface | MCU Family |
|---|---|
| DAP | See overview |
💡 Practical Examples
Ex 1: Basic usage — connect probe and program device.
Ex 2: Read memory contents during debug session.
Ex 3: Set breakpoint and inspect register state.
🧪 Practice Questions
Beginner: 1) What MCUs use DAP? 2) Pin count? 3) Programming vs debugging? 4) Required tools? 5) Entry sequence?
Intermediate: 1) Protocol timing. 2) Read/write commands. 3) Breakpoint types. 4) Security bypass? 5) Production programming flow.
Advanced: 1) Custom programmer implementation. 2) Automated test via DAP. 3) Unlock locked device. 4) CI/CD integration. 5) Multi-device programming.
Checklist
- [ ] Connect DAP probe correctly
- [ ] Program flash via DAP
- [ ] Set hardware breakpoint
- [ ] Step through code
- [ ] Read/write memory
- [ ] Configure fuses/config bits
- [ ] Automate with CLI tool
- [ ] Handle security/lock bits