STM32F1 DEBUG

Started by tha, June 17, 2021, 02:42:38 PM

Previous topic - Next topic

tha

31.8.3 SW-DP state machine (reset, idle states, ID code)

The State Machine ของ the SW-DP มี an internal ID code ซึ่งระบุ the SW-DP. มันเป็นไปตาม the JEP-106 standard. ID code นี้เป็นระหัสเริ่มต้นของ Arm® ตัวหนึ่งและถูกเซ็ตเป็น 0x1BA01477 (ตรงกันกับ Cortex®-M3 r1p1).

Note: บันทึกไว้ว่า the SW-DP state machine จะไม่ทำงานจนกระทั่ง the target อ่าน ID code นี้.

•    The SW-DP state machine อยู่ใน RESET STATE อย่างใดอย่างหนึ่งหลังจาก power-on reset, หรือหลังจาก the DP ได้สวิทช์
      จาก JTAG ไปยัง SWD หรือหลังจาก the line เป็น high เป็นเวลามากกว่า 50 cycles
•    The SW-DP state machine อยู่ใน IDLE STATE ถ้า the line เป็น low เป็นเวลาอย่างน้อยสองไซเคิลหลังจาก RESET state.
•    After RESET state, จำเป็นต้องเข้าสู่ไปใน an IDLE state ก่อนและเพื่อดำเนินการ a READ เข้าถึงของ the DP-SW ID CODE
      register. มิฉะนั้น, the target จะปล่อยออก a FAULT acknowledge response บนการส่งถ่ายอื่น.

รายละเอียดที่มากขึ้นของ the SW-DP state machine สามารถถูกพบใน the Cortex®-M3 r1p1 TRM และ the CoreSight Design Kit r1p0 TRM.

tha

31.8.4 DP and AP read/write accesses

•    Read เข้าถึงไปยัง the DP ไม่ถูกโพสต์: the target response สามารถถูกทำทันที (ถ้า ACK=OK) หรือสามารถถูกหน่วงเวลา (ถ้า
      ACK=WAIT).
•    Read เข้าถึงไปยัง the AP ถูกโพสต์. นี้หมายความว่าผลของ the access ถูกส่งคืนบน the next transfer. ถ้า the next access ที่
      ถูกทำไม่ใช่ an AP access, ดังนั้น the DP-RDBUFF register ต้องถูกอ่านเพื่อให้ได้ the result.
      The READOK flag ของ the DP-CTRL/STAT register ถูกอัปเดตบนทุกๆ AP read access หรือ RDBUFF read request เพื่อ
      ให้ทราบหาก the AP read access สำเร็จแล้ว.
•    The SW-DP จัดให้มีใช้ a write buffer (สำหรับทั้ง DP หรือ AP writes), ที่เปิดการใช้งานมันเพื่อยอมรับ a write operation แม้ว่า
      เมื่อ transactions อื่นยังคงค้างอยู่. ถ้า the write buffer เต็ม, the target acknowledge response จะเป็น "WAIT". ด้วยข้อ
      ยกเว้นของ IDCODE read หรือ CTRL/STAT read หรือ ABORT write ซึ่งถูกยอมรับถึงแม้ว่า the write buffer เต็ม.
•    เนื่องจาก the asynchronous clock domains SWCLK and HCLK, สอง extra SWCLK cycles ถูกต้องการหลังจาก a write
      transaction (หลังจาก the parity bit) เพื่อทำให้การเขียนเป็นผลภายใน. ไซเคิลเหล่านี้ควรถูกใช้ในขณะที่กำลังขับ the line low
      (IDLE state)
      สิ่งนี้มีความสำคัญอย่างยิ่งเมื่อเขียน the CTRL/STAT สำหรับ a power-up request. ถ้า the next transaction (ต้องการ a
      power-up) เกิดขึ้นทันที, มันจะล้มเหลว.

tha

31.8.5 SW-DP registers

เข้าถึง registers เหล่านี้ถูกเริ่มต้นเมื่อ APnDP=0





31.8.6 SW-AP registers

เข้าถึง registers เหล่านี้ถูกเริ่มต้นเมื่อ APnDP=1
มี AP Registers จำนวนมาก (ดู AHB-AP) ที่ถูกติดต่อที่อยู่เป็นการรวมของ:
•    The shifted value A[3:2]
•    ค่าปัจจุบันของ the DP SELECT register


tha

31.9 AHB-AP (AHB access port) - ใช้ได้สำหรับทั้ง JTAG-DP and SW-DP

คุณสมบัติ:
•    System access ไม่ขึ้นอยู่กับ the processor status.
•    อยางใดอย่างหนึ่ง SW-DP หรือ JTAG-DP เข้าถึง AHB-AP.
•    The AHB-AP เป็น an AHB master ใน the Bus Matrix. ดังนั้น, มันสามารถเข้าถึงทุก the data buses (Dcode Bus, System
      Bus, internal and external PPB bus) แต่ the ICode bus.
•    Bitband transactions ถูกรองรับ.
•    AHB-AP transactions ข้าม the FPB.

The address ของ the 32-bits AHP-AP resisters เป็น 6-bits wide (มากถึง 64 words หรือ 256 bytes) และประกอบด้วย :
   c)    Bits [7:4] = the bits [7:4] APBANKSEL ของ the DP SELECT register
   d)    Bits [3:2] = the 2 address bits ของ A[3:2] ของ the 35-bit packet ร้องขอสำหรับ SW-DP.

The AHB-AP ของ the Cortex®-M3 ประกอบด้วย 9 x 32-bits registers:


tha

31.10 Core debug

Core debug ถูกเข้าถึงผ่านทาง the core debug registers. Debug เข้าถึง registers เหล่านี้โดยทาง the Advanced High-performance Bus (AHB-AP) port. The processor สามารถเข้าถึง registers เหล่านี้โดยตรงบน the internal Private Peripheral Bus (PPB).

มันประกอบด้วย 4 registers:



Note: สำคัญ: registers เหล่านี้ไม่ถูกรีเซ็ตโดย a system reset. พวกมันถูกรีเซ็ตเฉพาะโดย a power-on reset.

อ้างอิงถึง the Cortex®-M3 r1p1 TRM สำหรับรายละเอียดที่มากขึ้น.

เพื่อ Halt บน reset, จำเป็นต้อง:
•    เปิดการใช้งาน the bit0 (VC_CORRESET) of the Debug and Exception Monitor Control Register
•    เปิดการใช้งาน the bit0 (C_DEBUGEN) of the Debug Halting Control and Status Register.

tha

31.11 ความสามารถของ the debugger host ในการเชื่อมต่อภายใต้ system reset

The reset system ของ the STM32F10xxx MCU ประกอบด้วยแหล่งการรีเซ็ตต่อไปนี้ :
•    POR (power-on reset) ซึ่งถือสิทธิ์ a RESET ทุกครั้งที่ power-up.
•    Internal watchdog reset
•    Software reset
•    External reset

The Cortex®-M3 ทำให้ต่างกันในการรีเซ็ตของ the debug part (โดยทั่วไปคือ PORRESETn) และอีกตัว (SYSRESETn)

ด้วยวิธีนี้ , มันสามารถเป็นได้สำหรับ the debugger ที่จะเชื่อมต่อภายใต้ System Reset, การโปรแกรม the Core Debug Registers เพื่อหยุด the core เมื่อมีการเฟทช์ the reset vector. ดังนั้น the host สามารถปลดปล่อย the system reset และ the core จะหยุดโดยทันทีโดยไม่มีการปฏิบัติคำสั่งใดๆ. นอกจากนี้, มันสามารถเป็นได้ที่จะโปรแกรมคุณลักษณะการดีบักใดๆภายใต้ System Reset.

Note: ขอแนะนำอย่างยิ่งให้ the debugger host เชื่อมต่อ (เซ็ต a breakpoint ใน the reset vector) ภายใต้ system reset.

tha

31.12 FPB (Flash patch breakpoint)

The FPB unit:
•    จัดให้มีใช้ hardware breakpoints
•    patches code และ data จาก code space ไปยัง system space. คุณลักษณะนี้ช่วยให้ความเป็นไปได้ในการแก้ไข software
      bugs ที่อยู่ใน the Code Memory Space.

การใช้ a Software Patch หรือ a Hardware Breakpoint เป็นเอกสิทธิ์เฉพาะตัว.

The FPB ประกอบด้วย:
•    2 literal comparators สำหรับจับคู่กับ literal ที่โหลดจาก Code Space และแม็ปซ้ำไปยัง a corresponding area ใน the
      System Space.
•    6 instruction comparators สำหรับจับคู่กับ instruction ที่เฟทช์จาก Code Space. พวกมันสามารถถูกใช้อย่างใดอย่างหนึ่งเพื่อ
      แม็บซ้ำไปยัง a corresponding area ใน the System Space หรือเพื่อสร้าง a Breakpoint Instruction ไปยัง the core.

tha

31.13 DWT (data watchpoint trigger)

The DWT unit ประกอบด้วย four comparators. พวกมันสามารถกำหนดค่าเป็น :
•    a hardware watchpoint or
•    a trigger to an ETM or
•    a PC sampler or
•    a data address sampler

The DWT จัดให้มีบางวิธีการเพื่อให้บาง profiling informations อีกด้วย. สำหรับสิ่งนี้, บาง counters สามารถเข้าถึงได้เพื่อให้จำนวนของ:
•    Clock cycle
•    Folded instructions
•    Load store unit (LSU) operations
•    Sleep cycles
•    CPI (clock per instructions)
•    Interrupt overhead