1 http://marc.info/?l=openocd-development&m=137182292914653
3 [prev in list] [next in list] [prev in thread] [next in thread]
5 List: openocd-development
6 Subject: [OpenOCD-devel] Instructions on doing (semi-)manual JTAG boundary scan with OpenOCD
7 From: Paul Fertser <fercerpav () gmail ! com>
8 Date: 2013-06-21 13:51:24
9 Message-ID: 20130621135124.GC2326 () home ! lan
10 [Download message RAW]
14 It wasn't the first time I tried and failed to find any guides on
15 using JTAG for its original purpose, so I felt like trying it on my
16 own. It's still unclear how to communicate with several different
17 devices on a chain at the same time as OpenOCD seems to require to
18 have only one TAP in non-bypass mode at a time.
20 Here go draft instructions:
22 1. You need a BSDL file for the components you're using. For STM32s
23 it's readily available from the vendor's website.
25 2. From the BSDL file you need to figure out the Boundary Scan
26 Register Length, e.g. for STM32F100 it's shown in this line:
27 attribute BOUNDARY_LENGTH of STM32F1_Low_Med_density_value_LQFP64 : entity is 232;
30 attribute BOUNDARY_REGISTER of STM32F1_Low_Med_density_value_LQFP64 : entity is
32 which describes which bits of BSR correspond to which device's ports.
34 4. Read the description of the port you're interested in. E.g. PC8
36 "75 (BC_1, *, CONTROL, 1), " &
37 "74 (BC_1, PC8, OUTPUT3, X, 75, 1, Z), " &
38 "73 (BC_4, PC8, INPUT, X), " &
40 which means that bit 73 reflects port's input (when it's configured as
41 input), bit 74 defines port's output (when it's configured as output),
42 bit 75 sets PC8 to Z-state when set to 1 and to output when set to 0.
44 5. Decide on what mode you need: in SAMPLE/PRELOAD mode the buffers
45 are disconnected from the boundary scan logic and are controlled by
46 the cpu as usual but you can still sample their values. In EXTEST mode
47 the buffers are fully controlled by the boundary scan logic. Some SoCs
48 (including STM32) allow to do boundary scan while SRST is held low,
49 that makes it impossible for CPU to interfere with the test. You can
50 control SRST state with "jtag_reset" command.
52 6. Source manual_bs.tcl (attached) and call "init_bs <bstap>
53 <bsrlength>". This should be done after "init" call.
55 7. Proceed with your tests by calling "sample_get_bit_bsr <bitn>" and
56 other functions from manual_bs.tcl
58 An example of a semi-automated boundary scan test for an
59 STM32VLDiscovery board is attached, here follows the log:
61 $ sudo openocd -f interface/raspberrypi-native.cfg -f target/stm32f1x.cfg -f stm32vldiscovery_bs.tcl
62 Open On-Chip Debugger 0.8.0-dev-00011-g7b21292-dirty (2013-05-09-23:11)
63 Licensed under GNU GPL v2
65 http://openocd.sourceforge.net/doc/doxygen/bugs.html
66 Info : only one transport option; autoselect 'jtag'
67 BCM2835 GPIO config: tck = 11, tms = 25, tdi = 10, tdi = 9
68 adapter speed: 1000 kHz
69 adapter_nsrst_delay: 100
71 cortex_m3 reset_config sysresetreq
72 Info : clock speed 1006 kHz
73 Info : JTAG tap: stm32f1x.cpu tap/device found: 0x3ba00477 (mfg: 0x23b, part: 0xba00, ver: 0x3)
74 Info : JTAG tap: stm32f1x.bs tap/device found: 0x06420041 (mfg: 0x020, part: 0x6420, ver: 0x0)
75 Info : stm32f1x.cpu: hardware has 6 breakpoints, 4 watchpoints
78 Starting basic STM32VLDiscovery JTAG boundary scan test
80 All LEDs should be OFF, press Enter
82 Green LED should be ON, blue LED OFF, press Enter
84 Green and blue LEDs should be ON, press Enter
86 Blue LED should be ON, green LED OFF, press Enter
88 Green and blue LEDs should be ON, do NOT press the USER button, press Enter
90 Green and blue LEDs should be ON, DO press the USER button, press Enter
92 Green and blue LEDs should be ON, do NOT press the USER button, press Enter
94 Green and blue LEDs should be ON, DO press the USER button, press Enter
96 All tests passed SUCCESSFULLY, exiting
97 shutdown command invoked
100 Be free, use free (http://www.gnu.org/philosophy/free-sw.html) software!
101 mailto:fercerpav@gmail.com
103 ["manual_bs.tcl" (application/x-tcl)]
105 # Init global variables to work with the boundary scan register
106 # the first argument is tap name, the second is BSR length
107 proc init_bs {tap len} {
112 # disable polling for the cpu TAP as it should be kept in BYPASS
117 # In this mode BSR doesn't control the outputs but can read the current
118 # pins' states, the CPU can continue to function normally
119 proc sample_mode {} {
125 # Connect BSR to the boundary scan logic
126 proc extest_mode {} {
132 # Write bsrstateout to target and store the result in bsrstate
133 proc exchange_bsr {} {
134 global bsrtap bsrstate bsrstateout
135 update_bsrstate [eval drscan [concat $bsrtap $bsrstateout]]
139 # Check if particular bit is set in bsrstate
140 proc get_bit_bsr {bit} {
142 set idx [expr $bit / 32]
143 set bit [expr $bit % 32]
144 expr ([lindex $bsrstate [expr $idx*2 + 1]] & [expr 2**$bit]) != 0
147 # Resample and get bit
148 proc sample_get_bit_bsr {bit} {
153 # Set particular bit to "value" in bsrstateout
154 proc set_bit_bsr {bit value} {
156 set idx [expr ($bit / 32) * 2 + 1]
157 set bit [expr $bit % 32]
158 set bitval [expr 2**$bit]
159 set word [lindex $bsrstateout $idx]
161 set word [format %X [expr $word & ~$bitval]]
163 set word [format %X [expr $word | $bitval]]
165 set bsrstateout [lreplace $bsrstateout $idx $idx 0x$word]
169 # Set the bit and update BSR on target
170 proc set_bit_bsr_do {bit value} {
171 set_bit_bsr $bit $value
175 proc init_bsrstate {} {
176 global bsrtap bsrlen bsrstate bsrstateout
178 for {set i $bsrlen} {$i > 32} {incr i -32} {
179 append bsrstate 32 " " 0xFFFFFFFF " "
182 append bsrstate $i " " 0xFFFFFFFF
184 set bsrstateout $bsrstate
188 proc update_bsrstate {state} {
191 foreach word $state {
192 set bsrstate [lreplace $bsrstate $i $i 0x$word]
197 ["stm32vldiscovery_bs.tcl" (application/x-tcl)]
199 # Example script to test STM32VLDiscovery with boundary scan
203 echo "\n\nStarting basic STM32VLDiscovery JTAG boundary scan test\n"
207 init_bs stm32f1x.bs 232
210 echo "All LEDs should be OFF, press Enter"
213 # Set PC9 to output 1
216 echo "Green LED should be ON, blue LED OFF, press Enter"
219 # Set PC8 to output 1
222 echo "Green and blue LEDs should be ON, press Enter"
225 # Set PC9 to output 0
227 echo "Blue LED should be ON, green LED OFF, press Enter"
230 # Set PC9 to output 1
233 echo "Green and blue LEDs should be ON, do NOT press the USER button, press Enter"
235 # Read PA0 state, there's a pulldown on board
236 if {[sample_get_bit_bsr 187] == 1} {
237 echo "Button is stuck at 1: ERROR, aborting"
242 echo "Green and blue LEDs should be ON, DO press the USER button, press Enter"
244 if {[sample_get_bit_bsr 187] == 0} {
245 echo "Button is stuck at 0: ERROR, aborting"
251 echo "All tests passed SUCCESSFULLY, exiting"
255 ------------------------------------------------------------------------------
256 This SF.net email is sponsored by Windows:
258 Build for Windows Store.
260 http://p.sf.net/sfu/windows-dev2dev
262 _______________________________________________
263 OpenOCD-devel mailing list
264 OpenOCD-devel@lists.sourceforge.net
265 https://lists.sourceforge.net/lists/listinfo/openocd-devel
268 [prev in list] [next in list] [prev in thread] [next in thread]
270 Configure | About | News | Add a list | Sponsored by KoreLogic