STM32F1 DEBUG

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

Previous topic - Next topic

tha

31.4.4 การใช้ serial wire และการปลดปล่อย the unused debug pins ไปเป็น GPIOs

เพื่อใช้ the serial wire DP เพื่อปลดปล่อยบาง GPIOs, the user software ต้องเซ็ต SWJ_CFG=010 เพียงหลังจากรีเซ็ต. นี้ปลดปล่อย PA15, PB3 and PB4 ซึ่งบัดนี้มาเป็นมีให้ใช้ประโยชน์เป็น GPIOs.

เมื่อทำการดีบัก, the host จะดำเนินการดังต่อไปนี้:
•    ภายใต้ system reset, ทุก SWJ pins ถูกกำหนด (JTAG-DP + SW-DP).
•    ภายใต้ system reset, the debugger host ส่ง the JTAG sequence เพื่อสวิทช์จาก the JTAG-DP ไปเป็น the SW-DP.
•    ยังคงอยู่ภายใต้ system reset, the debugger เซ็ต a breakpoint บน vector reset.
•    The system reset ถูกปลดปล่อยและ the Core หยุดทำงาน.
•    the debug communications ทั้งหมดจากจุดนี้ถูกทำโดยใช้ the SW-DP. JTAG pins อื่นๆสามารถถูกกำหนดใหม่เป็น GPIOs โดย
      the user software.

Note: สำหรับ user software designs, โปรดทราบว่า :
เพื่อปลดปล่อย the debug pins, โปรดจำไว้ว่าพวกมันจะถูกกำหนดค่าเป็นอันดับแรกทั้งใน input-pull-up (nTRST, TMS, TDI) หรือ pull-down (TCK) หรือ output tristate (TDO) เป็นระยะเวลาหนึ่งหลังจากรีเซ็ตจนกระทั่งทันทีที่ the user software ปลดปล่อย the pins.
เมื่อ debug pins (JTAG or SW or TRACE) ถูกแม็ป, การเปลี่ยน the corresponding IO pin configuration ใน the IOPORT controller จะไม่มีผลอะไร.

tha

31.5 STM32F10xxx JTAG TAP connection

The STM32F10xxx MCUs รวม two serially connected JTAG TAPs, the boundary scan TAP (IR เป็น 5-bit wide) และ the Cortex®-M3 TAP (IR เป็น 4-bit wide).

เพื่อเข้าถึง the TAP ของ the Cortex®-M3 สำหรับ debug purposes:
1.    อันดับแรก, จำเป็นต้องเลื่อน the BYPASS instruction ของ the boundary scan TAP.
2.    จากนั้น, สำหรับแต่ละ IR shift, the scan chain บรรจุ 9 bits (=5+4) และ the unused TAP instruction ต้องถูกเลื่อนในการ
       ใช้ the BYPASS instruction
3.    สำหรับแต่ละ data shift, the unused TAP, ซึ่งอยู่ใน BYPASS mode, เพิ่ม 1 extra data bit ใน the data scan chain.

Note: สำคัญ: เมื่อ Serial-Wire ถูกเลือกโดยใช้ the dedicated Arm® JTAG sequence, the boundary scan TAP จะถูกปิดการใช้งานโดยอัตโนมัติ (JTMS ถูกบังคับ high).


tha

31.6 ID codes and locking mechanism

มีหลาย ID codes ภายใน the STM32F10xxx MCUs. ST แนะนำอย่างแข็งขัน tools designers ให้ล็อค debuggers ของพวกมันโดยใช้ the MCU DEVICE ID code มีตำแหน่งใน the external PPB memory แม็ปที่ address 0xE0042000

31.6.1 MCU device ID code

The STM32F10xxx MCUs รวม an MCU ID code. ID นี้ระบุ the ST MCU partnumber และ the die revision. มันเป็นส่วนหนึ่งของ the DBG_MCU component และถูกแม็ปบน the external PPB bus (ดู Section 31.16). code นี้เข้าถึงได้โดยใช้ the JTAG debug port (สี่หรือห้า pins) หรือ the SW debug port (สอง pins) หรือโดย the user software. มันเข้าถึงได้แม้ในขณะที่ the MCU อยู่ภายใต้ system reset.

มีเพียง the DEV_ID[11:0] ที่ถูกใช้สำหรับระบุตัวตนโดย the debugger/programmer tools.



Bits 31:16 REV_ID[15:0] Revision identifier
ฟิลด์นี้แสดงให้เห็น the revision of the device:
In low-density devices:
   – 0x1000 = Revision A
In medium-density devices:
   – 0x0000 = Revision A
   – 0x2000 = Revision B
   – 0x2001 = Revision Z
   – 0x2003 = Revision 1, 2, 3, X or Y
In high-density devices:
   – 0x1000 = Revision A or 1
   – 0x1001 = Revision Z
   – 0x1003 = Revision 1, 2, 3, X or Y
In XL-density devices:
   – 0x1000 = Revision A or 1
In connectivity line devices:
   – 0x1000 = Revision A
   – 0x1001 = Revision Z

Bits 15:12 Reserved, must be kept at reset value.

Bits 11:0 DEV_ID[11:0]: Device identifier
ฟิลด์นี้แสดงให้เห็น the device ID.
For low-density devices, the device ID is 0x412
For medium-density devices, the device ID is 0x410
For high-density devices, the device ID is 0x414
For XL-density devices, the device ID is 0x430
For connectivity devices, the device ID is 0x418


tha

31.6.2 Boundary scan TAP

JTAG ID code


The TAP ของ the STM32F10xxx BSC (boundary scan) รวม a JTAG ID code เท่ากับ
•    In low-density devices:
      –    0x06412041 = Revision A
•    In medium-density devices:
      –    0x06410041 = Revision A
      –    0x16410041 = Revision B, Revision Z and Revision Y
•    In high-density devices:
      –    0x06414041 = Revision A, Revision Z and Revision Y
•    In XL-density devices
      –    0x06430041 = Revision A
•    In connectivity line devices:
      –    0x06418041 = Revision A and Revision Z

tha

31.6.3 Cortex®-M3 TAP

The TAP ของ the Arm® Cortex®-M3 รวม a JTAG ID code. ID code นี้คือ the Arm® default one และยังไม่ถูกแก้ไขเลย. code นี้เข้าถึงได้เฉพาะโดย the JTAG Debug Port, มันคือ 0x3BA00477 (ตรงกันกับ Cortex®-M3 r1p1-01rel0, ดู Section 31.2).

31.6.4 Cortex®-M3 JEDEC-106 ID code

The Arm® Cortex®-M3 รวม a JEDEC-106 ID code. มันอยู่ในตำแหน่งใน the 4 KB ROM table ที่แม็ปบน the internal PPB bus ที่ address 0xE00FF000_0xE00FFFFF.

code นี้เข้าถึงได้โดย the JTAG Debug Port (4 to 5 pins) หรือโดย the SW Debug Port (two pins) หรือโดย the user software.

tha

31.7 JTAG debug port

A standard JTAG state machine ถูกจัดให้มีใช้กับ a 4-bit instruction register (IR) และ five data registers (สำหรับรายละเอียดเต็ม, อ้างอิงถึง the Cortex®-M3 r1p1 Technical Reference Manual (TRM), สำหรับการอ้างอิง, ดู Section 31.2).




tha

31.8 SW debug port

31.8.1 SW protocol introduction

synchronous serial protocol นี้ใช้สองขา :
•    SWCLK: clock จาก host ถึง target
•    SWDIO: bidirectional

The protocol ยอมให้ two banks of registers (DPACC registers and APACC registers) ถูกอ่านและเขียนถึง.

Bits ถูกส่งถ่าย LSB-first บน the wire.

สำหรับ SWDIO bidirectional management, the line ต้องถูก pulled-up บน the board (100 KΩ ถูกแนะนำโดย Arm®).

แต่ละครั้งที่ทิศทางของ SWDIO เปลี่ยนใน the protocol, a turnaround time ถูกใส่ตรงที่ the line ไม่ถูกขับโดย the host หรือ the target. โดยค่าเริ่มต้น, turnaround time นี้คือ one bit time, อย่างไรก็ตามสามารถที่จะปรับโดยการกำหนดค่า the SWCLK frequency.

tha

31.8.2 SW protocol sequence

แต่ละลำดับประกอบด้วย three phases:
1.    Packet request (8 bits) ถูกส่งโดย the host
2.    Acknowledge response (3 bits) ถูกส่งโดย  the target
3.    Data transfer phase (33 bits) ถูกส่งโดย the host หรือ the target



อ้างอิงถึง the Cortex®-M3 r1p1 TRM สำหรับคำอธิบายโดยละเอียดของ DPACC and APACC registers.

The packet request ถูกตามด้วย the turnaround time เสมอ(ค่าเริ่มต้น 1 bit) ตรงที่ไม่ทั้ง the host หรือ target ขับ the line.



The ACK Response ต้องถูกตามด้วย a turnaround time เฉพาะถ้ามันเป็น a READ transaction หรือถ้า a WAIT หรือ FAULT acknowledge ถูกรับแล้ว.



The DATA transfer ต้องถูกตามด้วย a turnaround time เฉพาะถ้ามันเป็น a READ transaction.