openocd jtag pin toggle
[x300-pci] / openocd-jtag / msg-137182292914653.raw
1 From dpavlin@nuc.tv Sat Jan 23 13:37:33 2016
2 To: root@nuc.tv
3 Auto-Submitted: auto-generated
4 Subject: *** SECURITY information for nuc.tv ***
5 Status: RO
6 Content-Length: 8647
7 Lines: 180
8
9 --n8g4imXOkfNTN/H1
10 Content-Type: text/plain; charset=us-ascii
11 Content-Disposition: inline
12
13 Hi,
14
15 It wasn't the first time I tried and failed to find any guides on
16 using JTAG for its original purpose, so I felt like trying it on my
17 own. It's still unclear how to communicate with several different
18 devices on a chain at the same time as OpenOCD seems to require to
19 have only one TAP in non-bypass mode at a time.
20
21 Here go draft instructions:
22
23 1. You need a BSDL file for the components you're using. For STM32s
24 it's readily available from the vendor's website.
25
26 2. From the BSDL file you need to figure out the Boundary Scan
27 Register Length, e.g. for STM32F100 it's shown in this line:
28 attribute BOUNDARY_LENGTH of STM32F1_Low_Med_density_value_LQFP64 : entity is 232;
29
30 3. It's followed by
31 attribute BOUNDARY_REGISTER of STM32F1_Low_Med_density_value_LQFP64 : entity is
32
33 which describes which bits of BSR correspond to which device's ports.
34
35 4. Read the description of the port you're interested in. E.g. PC8
36 is described by
37       "75       (BC_1,  *,              CONTROL,        1),                             " &
38       "74       (BC_1,  PC8,            OUTPUT3,        X,      75,     1,      Z),     " &
39       "73       (BC_4,  PC8,            INPUT,          X),                             " &          
40
41 which means that bit 73 reflects port's input (when it's configured as
42 input), bit 74 defines port's output (when it's configured as output),
43 bit 75 sets PC8 to Z-state when set to 1 and to output when set to 0.  
44
45 5. Decide on what mode you need: in SAMPLE/PRELOAD mode the buffers
46 are disconnected from the boundary scan logic and are controlled by
47 the cpu as usual but you can still sample their values. In EXTEST mode
48 the buffers are fully controlled by the boundary scan logic. Some SoCs
49 (including STM32) allow to do boundary scan while SRST is held low,
50 that makes it impossible for CPU to interfere with the test. You can
51 control SRST state with "jtag_reset" command.
52
53 6. Source manual_bs.tcl (attached) and call "init_bs <bstap>
54 <bsrlength>". This should be done after "init" call.
55
56 7. Proceed with your tests by calling "sample_get_bit_bsr <bitn>" and
57 other functions from manual_bs.tcl
58
59 An example of a semi-automated boundary scan test for an
60 STM32VLDiscovery board is attached, here follows the log:
61
62 $ sudo openocd -f interface/raspberrypi-native.cfg -f target/stm32f1x.cfg -f stm32vldiscovery_bs.tcl 
63 Open On-Chip Debugger 0.8.0-dev-00011-g7b21292-dirty (2013-05-09-23:11)
64 Licensed under GNU GPL v2
65 For bug reports, read
66         http://openocd.sourceforge.net/doc/doxygen/bugs.html
67 Info : only one transport option; autoselect 'jtag'
68 BCM2835 GPIO config: tck = 11, tms = 25, tdi = 10, tdi = 9
69 adapter speed: 1000 kHz
70 adapter_nsrst_delay: 100
71 jtag_ntrst_delay: 100
72 cortex_m3 reset_config sysresetreq
73 Info : clock speed 1006 kHz
74 Info : JTAG tap: stm32f1x.cpu tap/device found: 0x3ba00477 (mfg: 0x23b, part: 0xba00, ver: 0x3)
75 Info : JTAG tap: stm32f1x.bs tap/device found: 0x06420041 (mfg: 0x020, part: 0x6420, ver: 0x0)
76 Info : stm32f1x.cpu: hardware has 6 breakpoints, 4 watchpoints
77
78
79 Starting basic STM32VLDiscovery JTAG boundary scan test
80
81 All LEDs should be OFF, press Enter
82
83 Green LED should be ON, blue LED OFF, press Enter
84
85 Green and blue LEDs should be ON, press Enter
86
87 Blue LED should be ON, green LED OFF, press Enter
88
89 Green and blue LEDs should be ON, do NOT press the USER button, press Enter
90
91 Green and blue LEDs should be ON, DO press the USER button, press Enter
92
93 Green and blue LEDs should be ON, do NOT press the USER button, press Enter
94
95 Green and blue LEDs should be ON, DO press the USER button, press Enter
96
97 All tests passed SUCCESSFULLY, exiting
98 shutdown command invoked
99
100 -- 
101 Be free, use free (http://www.gnu.org/philosophy/free-sw.html) software!
102 mailto:fercerpav@gmail.com
103
104 --n8g4imXOkfNTN/H1
105 Content-Type: application/x-tcl
106 Content-Disposition: attachment; filename="manual_bs.tcl"
107 Content-Transfer-Encoding: quoted-printable
108
109 # Init global variables to work with the boundary scan register=0A# the fir=
110 st argument is tap name, the second is BSR length=0Aproc init_bs {tap len} =
111 {=0A    global bsrtap bsrlen=0A    set bsrtap $tap=0A    set bsrlen $len=0A=
112     init_bsrstate=0A    # disable polling for the cpu TAP as it should be k=
113 ept in BYPASS =0A    poll off=0A    sample_mode=0A}=0A=0A# In this mode BSR=
114  doesn't control the outputs but can read the current=0A# pins' states, the=
115  CPU can continue to function normally =0Aproc sample_mode {} {=0A    globa=
116 l bsrtap=0A    # SAMPLE/PRELOAD=0A    irscan $bsrtap 2=0A}=0A=0A# Connect B=
117 SR to the boundary scan logic=0Aproc extest_mode {} {=0A    global bsrtap=
118 =0A    # EXTEST=0A    irscan $bsrtap 0=0A}=0A=0A# Write bsrstateout to targ=
119 et and store the result in bsrstate=0Aproc exchange_bsr {} {=0A    global b=
120 srtap bsrstate bsrstateout=0A    update_bsrstate [eval drscan [concat $bsrt=
121 ap $bsrstateout]]=0A    return $bsrstate=0A}=0A=0A# Check if particular bit=
122  is set in bsrstate=0Aproc get_bit_bsr {bit} {=0A    global bsrstate=0A    =
123 set idx [expr $bit / 32]=0A    set bit [expr $bit % 32]=0A    expr ([lindex=
124  $bsrstate [expr $idx*2 + 1]] & [expr 2**$bit]) !=3D 0=0A}=0A=0A# Resample =
125 and get bit=0Aproc sample_get_bit_bsr {bit} {=0A    exchange_bsr=0A    get_=
126 bit_bsr $bit=0A}=0A=0A# Set particular bit to "value" in bsrstateout=0Aproc=
127  set_bit_bsr {bit value} {=0A    global bsrstateout=0A    set idx [expr ($b=
128 it / 32) * 2 + 1]=0A    set bit [expr $bit % 32]=0A    set bitval [expr 2**=
129 $bit]=0A    set word [lindex $bsrstateout $idx]=0A    if {$value =3D=3D 0} =
130 {=0A    set word [format %X [expr $word & ~$bitval]]=0A    } else {=0A  set wor=
131 d [format %X [expr $word | $bitval]]=0A    }=0A    set bsrstateout [lreplac=
132 e $bsrstateout $idx $idx 0x$word]=0A    return=0A}=0A=0A# Set the bit and u=
133 pdate BSR on target =0Aproc set_bit_bsr_do {bit value} {=0A    set_bit_bsr =
134 $bit $value=0A    exchange_bsr=0A}=0A=0Aproc init_bsrstate {} {=0A    globa=
135 l bsrtap bsrlen bsrstate bsrstateout=0A    set bsrstate ""=0A    for {set i=
136  $bsrlen} {$i > 32} {incr i -32} {=0A   append bsrstate 32 " " 0xFFFFFFFF " "=
137 =0A    }=0A    if {$i > 0} {=0A append bsrstate $i " " 0xFFFFFFFF=0A    }=
138 =0A    set bsrstateout $bsrstate=0A    return=0A}=0A=0Aproc update_bsrstate=
139  {state} {=0A    global bsrstate=0A    set i 1=0A    foreach word $state {=
140 =0A     set bsrstate [lreplace $bsrstate $i $i 0x$word]=0A      incr i 2=0A    }=0A}=
141 =0A
142 --n8g4imXOkfNTN/H1
143 Content-Type: application/x-tcl
144 Content-Disposition: attachment; filename="stm32vldiscovery_bs.tcl"
145 Content-Transfer-Encoding: quoted-printable
146
147 # Example script to test STM32VLDiscovery with boundary scan=0A=0Ainit=0A=
148 =0Aecho "\n\nStarting basic STM32VLDiscovery JTAG boundary scan test\n"=0A=
149 =0Asource manual_bs.tcl=0A=0Ainit_bs stm32f1x.bs 232=0Aextest_mode=0Aexchan=
150 ge_bsr=0Aecho "All LEDs should be OFF, press Enter"=0Aread stdin 1=0A=0A# S=
151 et PC9 to output 1=0Aset_bit_bsr 72 0=0Aset_bit_bsr_do 71 1=0Aecho "Green L=
152 ED should be ON, blue LED OFF, press Enter"=0Aread stdin 1=0A=0A# Set PC8 t=
153 o output 1=0Aset_bit_bsr 75 0=0Aset_bit_bsr_do 74 1=0Aecho "Green and blue =
154 LEDs should be ON, press Enter"=0Aread stdin 1=0A=0A# Set PC9 to output 0=
155 =0Aset_bit_bsr_do 71 0=0Aecho "Blue LED should be ON, green LED OFF, press =
156 Enter"=0Aread stdin 1=0A=0A# Set PC9 to output 1=0Aset_bit_bsr_do 71 1=0Afo=
157 reach i {0 1} {=0A    echo "Green and blue LEDs should be ON, do NOT press =
158 the USER button, press Enter"=0A    read stdin 1=0A    # Read PA0 state, th=
159 ere's a pulldown on board=0A    if {[sample_get_bit_bsr 187] =3D=3D 1} {=0A=
160         echo "Button is stuck at 1: ERROR, aborting"=0A shutdown=0A     return=0A    }=
161 =0A=0A    echo "Green and blue LEDs should be ON, DO press the USER button,=
162  press Enter"=0A    read stdin 1=0A    if {[sample_get_bit_bsr 187] =3D=3D =
163 0} {=0A echo "Button is stuck at 0: ERROR, aborting"=0A shutdown=0A     return=
164 =0A    }=0A}=0A=0Aecho "All tests passed SUCCESSFULLY, exiting"=0Ashutdown=
165 =0A
166 --n8g4imXOkfNTN/H1
167 Content-Type: text/plain; charset="us-ascii"
168 MIME-Version: 1.0
169 Content-Transfer-Encoding: 7bit
170 Content-Disposition: inline
171
172 ------------------------------------------------------------------------------
173 This SF.net email is sponsored by Windows:
174
175 Build for Windows Store.
176
177 http://p.sf.net/sfu/windows-dev2dev
178 --n8g4imXOkfNTN/H1
179 Content-Type: text/plain; charset="us-ascii"
180 MIME-Version: 1.0
181 Content-Transfer-Encoding: 7bit
182 Content-Disposition: inline
183
184 _______________________________________________
185 OpenOCD-devel mailing list
186 OpenOCD-devel@lists.sourceforge.net
187 https://lists.sourceforge.net/lists/listinfo/openocd-devel
188
189 --n8g4imXOkfNTN/H1--