openocd jtag pin toggle
authorPaul Fertser <fercerpav@gmail.com>
Sat, 11 Jun 2016 09:03:06 +0000 (11:03 +0200)
committerDobrica Pavlinusic <dpavlin@rot13.org>
Sat, 11 Jun 2016 09:03:06 +0000 (11:03 +0200)
openocd-jtag/README [new file with mode: 0644]
openocd-jtag/manual_bs.tcl [new file with mode: 0644]
openocd-jtag/msg-137182292914653.raw [new file with mode: 0644]
openocd-jtag/stm32vldiscovery_bs.tcl [new file with mode: 0644]

diff --git a/openocd-jtag/README b/openocd-jtag/README
new file mode 100644 (file)
index 0000000..4e65574
--- /dev/null
@@ -0,0 +1,270 @@
+http://marc.info/?l=openocd-development&m=137182292914653
+
+[prev in list] [next in list] [prev in thread] [next in thread] 
+
+List:       openocd-development
+Subject:    [OpenOCD-devel] Instructions on doing (semi-)manual JTAG boundary scan with OpenOCD
+From:       Paul Fertser <fercerpav () gmail ! com>
+Date:       2013-06-21 13:51:24
+Message-ID: 20130621135124.GC2326 () home ! lan
+[Download message RAW]
+
+Hi,
+
+It wasn't the first time I tried and failed to find any guides on
+using JTAG for its original purpose, so I felt like trying it on my
+own. It's still unclear how to communicate with several different
+devices on a chain at the same time as OpenOCD seems to require to
+have only one TAP in non-bypass mode at a time.
+
+Here go draft instructions:
+
+1. You need a BSDL file for the components you're using. For STM32s
+it's readily available from the vendor's website.
+
+2. From the BSDL file you need to figure out the Boundary Scan
+Register Length, e.g. for STM32F100 it's shown in this line:
+attribute BOUNDARY_LENGTH of STM32F1_Low_Med_density_value_LQFP64 : entity is 232;
+
+3. It's followed by
+attribute BOUNDARY_REGISTER of STM32F1_Low_Med_density_value_LQFP64 : entity is
+
+which describes which bits of BSR correspond to which device's ports.
+
+4. Read the description of the port you're interested in. E.g. PC8
+is described by
+      "75       (BC_1,  *,              CONTROL,        1),                             " &
+      "74       (BC_1,  PC8,            OUTPUT3,        X,      75,     1,      Z),     " &
+      "73       (BC_4,  PC8,            INPUT,          X),                             " &          
+
+which means that bit 73 reflects port's input (when it's configured as
+input), bit 74 defines port's output (when it's configured as output),
+bit 75 sets PC8 to Z-state when set to 1 and to output when set to 0.  
+
+5. Decide on what mode you need: in SAMPLE/PRELOAD mode the buffers
+are disconnected from the boundary scan logic and are controlled by
+the cpu as usual but you can still sample their values. In EXTEST mode
+the buffers are fully controlled by the boundary scan logic. Some SoCs
+(including STM32) allow to do boundary scan while SRST is held low,
+that makes it impossible for CPU to interfere with the test. You can
+control SRST state with "jtag_reset" command.
+
+6. Source manual_bs.tcl (attached) and call "init_bs <bstap>
+<bsrlength>". This should be done after "init" call.
+
+7. Proceed with your tests by calling "sample_get_bit_bsr <bitn>" and
+other functions from manual_bs.tcl
+
+An example of a semi-automated boundary scan test for an
+STM32VLDiscovery board is attached, here follows the log:
+
+$ sudo openocd -f interface/raspberrypi-native.cfg -f target/stm32f1x.cfg -f stm32vldiscovery_bs.tcl 
+Open On-Chip Debugger 0.8.0-dev-00011-g7b21292-dirty (2013-05-09-23:11)
+Licensed under GNU GPL v2
+For bug reports, read
+        http://openocd.sourceforge.net/doc/doxygen/bugs.html
+Info : only one transport option; autoselect 'jtag'
+BCM2835 GPIO config: tck = 11, tms = 25, tdi = 10, tdi = 9
+adapter speed: 1000 kHz
+adapter_nsrst_delay: 100
+jtag_ntrst_delay: 100
+cortex_m3 reset_config sysresetreq
+Info : clock speed 1006 kHz
+Info : JTAG tap: stm32f1x.cpu tap/device found: 0x3ba00477 (mfg: 0x23b, part: 0xba00, ver: 0x3)
+Info : JTAG tap: stm32f1x.bs tap/device found: 0x06420041 (mfg: 0x020, part: 0x6420, ver: 0x0)
+Info : stm32f1x.cpu: hardware has 6 breakpoints, 4 watchpoints
+
+
+Starting basic STM32VLDiscovery JTAG boundary scan test
+
+All LEDs should be OFF, press Enter
+
+Green LED should be ON, blue LED OFF, press Enter
+
+Green and blue LEDs should be ON, press Enter
+
+Blue LED should be ON, green LED OFF, press Enter
+
+Green and blue LEDs should be ON, do NOT press the USER button, press Enter
+
+Green and blue LEDs should be ON, DO press the USER button, press Enter
+
+Green and blue LEDs should be ON, do NOT press the USER button, press Enter
+
+Green and blue LEDs should be ON, DO press the USER button, press Enter
+
+All tests passed SUCCESSFULLY, exiting
+shutdown command invoked
+
+-- 
+Be free, use free (http://www.gnu.org/philosophy/free-sw.html) software!
+mailto:fercerpav@gmail.com
+
+["manual_bs.tcl" (application/x-tcl)]
+
+# Init global variables to work with the boundary scan register
+# the first argument is tap name, the second is BSR length
+proc init_bs {tap len} {
+    global bsrtap bsrlen
+    set bsrtap $tap
+    set bsrlen $len
+    init_bsrstate
+    # disable polling for the cpu TAP as it should be kept in BYPASS 
+    poll off
+    sample_mode
+}
+
+# In this mode BSR doesn't control the outputs but can read the current
+# pins' states, the CPU can continue to function normally 
+proc sample_mode {} {
+    global bsrtap
+    # SAMPLE/PRELOAD
+    irscan $bsrtap 2
+}
+
+# Connect BSR to the boundary scan logic
+proc extest_mode {} {
+    global bsrtap
+    # EXTEST
+    irscan $bsrtap 0
+}
+
+# Write bsrstateout to target and store the result in bsrstate
+proc exchange_bsr {} {
+    global bsrtap bsrstate bsrstateout
+    update_bsrstate [eval drscan [concat $bsrtap $bsrstateout]]
+    return $bsrstate
+}
+
+# Check if particular bit is set in bsrstate
+proc get_bit_bsr {bit} {
+    global bsrstate
+    set idx [expr $bit / 32]
+    set bit [expr $bit % 32]
+    expr ([lindex $bsrstate [expr $idx*2 + 1]] & [expr 2**$bit]) != 0
+}
+
+# Resample and get bit
+proc sample_get_bit_bsr {bit} {
+    exchange_bsr
+    get_bit_bsr $bit
+}
+
+# Set particular bit to "value" in bsrstateout
+proc set_bit_bsr {bit value} {
+    global bsrstateout
+    set idx [expr ($bit / 32) * 2 + 1]
+    set bit [expr $bit % 32]
+    set bitval [expr 2**$bit]
+    set word [lindex $bsrstateout $idx]
+    if {$value == 0} {
+       set word [format %X [expr $word & ~$bitval]]
+    } else {
+       set word [format %X [expr $word | $bitval]]
+    }
+    set bsrstateout [lreplace $bsrstateout $idx $idx 0x$word]
+    return
+}
+
+# Set the bit and update BSR on target 
+proc set_bit_bsr_do {bit value} {
+    set_bit_bsr $bit $value
+    exchange_bsr
+}
+
+proc init_bsrstate {} {
+    global bsrtap bsrlen bsrstate bsrstateout
+    set bsrstate ""
+    for {set i $bsrlen} {$i > 32} {incr i -32} {
+       append bsrstate 32 " " 0xFFFFFFFF " "
+    }
+    if {$i > 0} {
+       append bsrstate $i " " 0xFFFFFFFF
+    }
+    set bsrstateout $bsrstate
+    return
+}
+
+proc update_bsrstate {state} {
+    global bsrstate
+    set i 1
+    foreach word $state {
+       set bsrstate [lreplace $bsrstate $i $i 0x$word]
+       incr i 2
+    }
+}
+
+["stm32vldiscovery_bs.tcl" (application/x-tcl)]
+
+# Example script to test STM32VLDiscovery with boundary scan
+
+init
+
+echo "\n\nStarting basic STM32VLDiscovery JTAG boundary scan test\n"
+
+source manual_bs.tcl
+
+init_bs stm32f1x.bs 232
+extest_mode
+exchange_bsr
+echo "All LEDs should be OFF, press Enter"
+read stdin 1
+
+# Set PC9 to output 1
+set_bit_bsr 72 0
+set_bit_bsr_do 71 1
+echo "Green LED should be ON, blue LED OFF, press Enter"
+read stdin 1
+
+# Set PC8 to output 1
+set_bit_bsr 75 0
+set_bit_bsr_do 74 1
+echo "Green and blue LEDs should be ON, press Enter"
+read stdin 1
+
+# Set PC9 to output 0
+set_bit_bsr_do 71 0
+echo "Blue LED should be ON, green LED OFF, press Enter"
+read stdin 1
+
+# Set PC9 to output 1
+set_bit_bsr_do 71 1
+foreach i {0 1} {
+    echo "Green and blue LEDs should be ON, do NOT press the USER button, press Enter"
+    read stdin 1
+    # Read PA0 state, there's a pulldown on board
+    if {[sample_get_bit_bsr 187] == 1} {
+       echo "Button is stuck at 1: ERROR, aborting"
+       shutdown
+       return
+    }
+
+    echo "Green and blue LEDs should be ON, DO press the USER button, press Enter"
+    read stdin 1
+    if {[sample_get_bit_bsr 187] == 0} {
+       echo "Button is stuck at 0: ERROR, aborting"
+       shutdown
+       return
+    }
+}
+
+echo "All tests passed SUCCESSFULLY, exiting"
+shutdown
+
+
+------------------------------------------------------------------------------
+This SF.net email is sponsored by Windows:
+
+Build for Windows Store.
+
+http://p.sf.net/sfu/windows-dev2dev
+
+_______________________________________________
+OpenOCD-devel mailing list
+OpenOCD-devel@lists.sourceforge.net
+https://lists.sourceforge.net/lists/listinfo/openocd-devel
+
+
+[prev in list] [next in list] [prev in thread] [next in thread] 
+
+Configure | About | News | Add a list | Sponsored by KoreLogic
diff --git a/openocd-jtag/manual_bs.tcl b/openocd-jtag/manual_bs.tcl
new file mode 100644 (file)
index 0000000..5898ed2
--- /dev/null
@@ -0,0 +1,92 @@
+# Init global variables to work with the boundary scan register
+# the first argument is tap name, the second is BSR length
+proc init_bs {tap len} {
+    global bsrtap bsrlen
+    set bsrtap $tap
+    set bsrlen $len
+    init_bsrstate
+    # disable polling for the cpu TAP as it should be kept in BYPASS 
+    poll off
+    sample_mode
+}
+
+# In this mode BSR doesn't control the outputs but can read the current
+# pins' states, the CPU can continue to function normally 
+proc sample_mode {} {
+    global bsrtap
+    # SAMPLE/PRELOAD
+    irscan $bsrtap 2
+}
+
+# Connect BSR to the boundary scan logic
+proc extest_mode {} {
+    global bsrtap
+    # EXTEST
+    irscan $bsrtap 0
+}
+
+# Write bsrstateout to target and store the result in bsrstate
+proc exchange_bsr {} {
+    global bsrtap bsrstate bsrstateout
+    update_bsrstate [eval drscan [concat $bsrtap $bsrstateout]]
+    return $bsrstate
+}
+
+# Check if particular bit is set in bsrstate
+proc get_bit_bsr {bit} {
+    global bsrstate
+    set idx [expr $bit / 32]
+    set bit [expr $bit % 32]
+    expr ([lindex $bsrstate [expr $idx*2 + 1]] & [expr 2**$bit]) != 0
+}
+
+# Resample and get bit
+proc sample_get_bit_bsr {bit} {
+    exchange_bsr
+    get_bit_bsr $bit
+}
+
+# Set particular bit to "value" in bsrstateout
+proc set_bit_bsr {bit value} {
+    global bsrstateout
+    set idx [expr ($bit / 32) * 2 + 1]
+    set bit [expr $bit % 32]
+    set bitval [expr 2**$bit]
+    set word [lindex $bsrstateout $idx]
+    if {$value == 0} {
+       set word [format %X [expr $word & ~$bitval]]
+    } else {
+       set word [format %X [expr $word | $bitval]]
+    }
+    set bsrstateout [lreplace $bsrstateout $idx $idx 0x$word]
+    return
+}
+
+# Set the bit and update BSR on target 
+proc set_bit_bsr_do {bit value} {
+    set_bit_bsr $bit $value
+    exchange_bsr
+}
+
+proc init_bsrstate {} {
+    global bsrtap bsrlen bsrstate bsrstateout
+    set bsrstate ""
+    for {set i $bsrlen} {$i > 32} {incr i -32} {
+       append bsrstate 32 " " 0xFFFFFFFF " "
+    }
+    if {$i > 0} {
+       append bsrstate $i " " 0xFFFFFFFF
+    }
+    set bsrstateout $bsrstate
+    return
+}
+
+proc update_bsrstate {state} {
+    global bsrstate
+    set i 1
+    foreach word $state {
+       set bsrstate [lreplace $bsrstate $i $i 0x$word]
+       incr i 2
+    }
+}
+
diff --git a/openocd-jtag/msg-137182292914653.raw b/openocd-jtag/msg-137182292914653.raw
new file mode 100644 (file)
index 0000000..5056cc2
--- /dev/null
@@ -0,0 +1,189 @@
+From dpavlin@nuc.tv Sat Jan 23 13:37:33 2016
+To: root@nuc.tv
+Auto-Submitted: auto-generated
+Subject: *** SECURITY information for nuc.tv ***
+Status: RO
+Content-Length: 8647
+Lines: 180
+
+--n8g4imXOkfNTN/H1
+Content-Type: text/plain; charset=us-ascii
+Content-Disposition: inline
+
+Hi,
+
+It wasn't the first time I tried and failed to find any guides on
+using JTAG for its original purpose, so I felt like trying it on my
+own. It's still unclear how to communicate with several different
+devices on a chain at the same time as OpenOCD seems to require to
+have only one TAP in non-bypass mode at a time.
+
+Here go draft instructions:
+
+1. You need a BSDL file for the components you're using. For STM32s
+it's readily available from the vendor's website.
+
+2. From the BSDL file you need to figure out the Boundary Scan
+Register Length, e.g. for STM32F100 it's shown in this line:
+attribute BOUNDARY_LENGTH of STM32F1_Low_Med_density_value_LQFP64 : entity is 232;
+
+3. It's followed by
+attribute BOUNDARY_REGISTER of STM32F1_Low_Med_density_value_LQFP64 : entity is
+
+which describes which bits of BSR correspond to which device's ports.
+
+4. Read the description of the port you're interested in. E.g. PC8
+is described by
+      "75       (BC_1,  *,              CONTROL,        1),                             " &
+      "74       (BC_1,  PC8,            OUTPUT3,        X,      75,     1,      Z),     " &
+      "73       (BC_4,  PC8,            INPUT,          X),                             " &          
+
+which means that bit 73 reflects port's input (when it's configured as
+input), bit 74 defines port's output (when it's configured as output),
+bit 75 sets PC8 to Z-state when set to 1 and to output when set to 0.  
+
+5. Decide on what mode you need: in SAMPLE/PRELOAD mode the buffers
+are disconnected from the boundary scan logic and are controlled by
+the cpu as usual but you can still sample their values. In EXTEST mode
+the buffers are fully controlled by the boundary scan logic. Some SoCs
+(including STM32) allow to do boundary scan while SRST is held low,
+that makes it impossible for CPU to interfere with the test. You can
+control SRST state with "jtag_reset" command.
+
+6. Source manual_bs.tcl (attached) and call "init_bs <bstap>
+<bsrlength>". This should be done after "init" call.
+
+7. Proceed with your tests by calling "sample_get_bit_bsr <bitn>" and
+other functions from manual_bs.tcl
+
+An example of a semi-automated boundary scan test for an
+STM32VLDiscovery board is attached, here follows the log:
+
+$ sudo openocd -f interface/raspberrypi-native.cfg -f target/stm32f1x.cfg -f stm32vldiscovery_bs.tcl 
+Open On-Chip Debugger 0.8.0-dev-00011-g7b21292-dirty (2013-05-09-23:11)
+Licensed under GNU GPL v2
+For bug reports, read
+        http://openocd.sourceforge.net/doc/doxygen/bugs.html
+Info : only one transport option; autoselect 'jtag'
+BCM2835 GPIO config: tck = 11, tms = 25, tdi = 10, tdi = 9
+adapter speed: 1000 kHz
+adapter_nsrst_delay: 100
+jtag_ntrst_delay: 100
+cortex_m3 reset_config sysresetreq
+Info : clock speed 1006 kHz
+Info : JTAG tap: stm32f1x.cpu tap/device found: 0x3ba00477 (mfg: 0x23b, part: 0xba00, ver: 0x3)
+Info : JTAG tap: stm32f1x.bs tap/device found: 0x06420041 (mfg: 0x020, part: 0x6420, ver: 0x0)
+Info : stm32f1x.cpu: hardware has 6 breakpoints, 4 watchpoints
+
+
+Starting basic STM32VLDiscovery JTAG boundary scan test
+
+All LEDs should be OFF, press Enter
+
+Green LED should be ON, blue LED OFF, press Enter
+
+Green and blue LEDs should be ON, press Enter
+
+Blue LED should be ON, green LED OFF, press Enter
+
+Green and blue LEDs should be ON, do NOT press the USER button, press Enter
+
+Green and blue LEDs should be ON, DO press the USER button, press Enter
+
+Green and blue LEDs should be ON, do NOT press the USER button, press Enter
+
+Green and blue LEDs should be ON, DO press the USER button, press Enter
+
+All tests passed SUCCESSFULLY, exiting
+shutdown command invoked
+
+-- 
+Be free, use free (http://www.gnu.org/philosophy/free-sw.html) software!
+mailto:fercerpav@gmail.com
+
+--n8g4imXOkfNTN/H1
+Content-Type: application/x-tcl
+Content-Disposition: attachment; filename="manual_bs.tcl"
+Content-Transfer-Encoding: quoted-printable
+
+# Init global variables to work with the boundary scan register=0A# the fir=
+st argument is tap name, the second is BSR length=0Aproc init_bs {tap len} =
+{=0A    global bsrtap bsrlen=0A    set bsrtap $tap=0A    set bsrlen $len=0A=
+    init_bsrstate=0A    # disable polling for the cpu TAP as it should be k=
+ept in BYPASS =0A    poll off=0A    sample_mode=0A}=0A=0A# In this mode BSR=
+ doesn't control the outputs but can read the current=0A# pins' states, the=
+ CPU can continue to function normally =0Aproc sample_mode {} {=0A    globa=
+l bsrtap=0A    # SAMPLE/PRELOAD=0A    irscan $bsrtap 2=0A}=0A=0A# Connect B=
+SR to the boundary scan logic=0Aproc extest_mode {} {=0A    global bsrtap=
+=0A    # EXTEST=0A    irscan $bsrtap 0=0A}=0A=0A# Write bsrstateout to targ=
+et and store the result in bsrstate=0Aproc exchange_bsr {} {=0A    global b=
+srtap bsrstate bsrstateout=0A    update_bsrstate [eval drscan [concat $bsrt=
+ap $bsrstateout]]=0A    return $bsrstate=0A}=0A=0A# Check if particular bit=
+ is set in bsrstate=0Aproc get_bit_bsr {bit} {=0A    global bsrstate=0A    =
+set idx [expr $bit / 32]=0A    set bit [expr $bit % 32]=0A    expr ([lindex=
+ $bsrstate [expr $idx*2 + 1]] & [expr 2**$bit]) !=3D 0=0A}=0A=0A# Resample =
+and get bit=0Aproc sample_get_bit_bsr {bit} {=0A    exchange_bsr=0A    get_=
+bit_bsr $bit=0A}=0A=0A# Set particular bit to "value" in bsrstateout=0Aproc=
+ set_bit_bsr {bit value} {=0A    global bsrstateout=0A    set idx [expr ($b=
+it / 32) * 2 + 1]=0A    set bit [expr $bit % 32]=0A    set bitval [expr 2**=
+$bit]=0A    set word [lindex $bsrstateout $idx]=0A    if {$value =3D=3D 0} =
+{=0A   set word [format %X [expr $word & ~$bitval]]=0A    } else {=0A  set wor=
+d [format %X [expr $word | $bitval]]=0A    }=0A    set bsrstateout [lreplac=
+e $bsrstateout $idx $idx 0x$word]=0A    return=0A}=0A=0A# Set the bit and u=
+pdate BSR on target =0Aproc set_bit_bsr_do {bit value} {=0A    set_bit_bsr =
+$bit $value=0A    exchange_bsr=0A}=0A=0Aproc init_bsrstate {} {=0A    globa=
+l bsrtap bsrlen bsrstate bsrstateout=0A    set bsrstate ""=0A    for {set i=
+ $bsrlen} {$i > 32} {incr i -32} {=0A  append bsrstate 32 " " 0xFFFFFFFF " "=
+=0A    }=0A    if {$i > 0} {=0A        append bsrstate $i " " 0xFFFFFFFF=0A    }=
+=0A    set bsrstateout $bsrstate=0A    return=0A}=0A=0Aproc update_bsrstate=
+ {state} {=0A    global bsrstate=0A    set i 1=0A    foreach word $state {=
+=0A    set bsrstate [lreplace $bsrstate $i $i 0x$word]=0A      incr i 2=0A    }=0A}=
+=0A
+--n8g4imXOkfNTN/H1
+Content-Type: application/x-tcl
+Content-Disposition: attachment; filename="stm32vldiscovery_bs.tcl"
+Content-Transfer-Encoding: quoted-printable
+
+# Example script to test STM32VLDiscovery with boundary scan=0A=0Ainit=0A=
+=0Aecho "\n\nStarting basic STM32VLDiscovery JTAG boundary scan test\n"=0A=
+=0Asource manual_bs.tcl=0A=0Ainit_bs stm32f1x.bs 232=0Aextest_mode=0Aexchan=
+ge_bsr=0Aecho "All LEDs should be OFF, press Enter"=0Aread stdin 1=0A=0A# S=
+et PC9 to output 1=0Aset_bit_bsr 72 0=0Aset_bit_bsr_do 71 1=0Aecho "Green L=
+ED should be ON, blue LED OFF, press Enter"=0Aread stdin 1=0A=0A# Set PC8 t=
+o output 1=0Aset_bit_bsr 75 0=0Aset_bit_bsr_do 74 1=0Aecho "Green and blue =
+LEDs should be ON, press Enter"=0Aread stdin 1=0A=0A# Set PC9 to output 0=
+=0Aset_bit_bsr_do 71 0=0Aecho "Blue LED should be ON, green LED OFF, press =
+Enter"=0Aread stdin 1=0A=0A# Set PC9 to output 1=0Aset_bit_bsr_do 71 1=0Afo=
+reach i {0 1} {=0A    echo "Green and blue LEDs should be ON, do NOT press =
+the USER button, press Enter"=0A    read stdin 1=0A    # Read PA0 state, th=
+ere's a pulldown on board=0A    if {[sample_get_bit_bsr 187] =3D=3D 1} {=0A=
+       echo "Button is stuck at 1: ERROR, aborting"=0A shutdown=0A     return=0A    }=
+=0A=0A    echo "Green and blue LEDs should be ON, DO press the USER button,=
+ press Enter"=0A    read stdin 1=0A    if {[sample_get_bit_bsr 187] =3D=3D =
+0} {=0A        echo "Button is stuck at 0: ERROR, aborting"=0A shutdown=0A     return=
+=0A    }=0A}=0A=0Aecho "All tests passed SUCCESSFULLY, exiting"=0Ashutdown=
+=0A
+--n8g4imXOkfNTN/H1
+Content-Type: text/plain; charset="us-ascii"
+MIME-Version: 1.0
+Content-Transfer-Encoding: 7bit
+Content-Disposition: inline
+
+------------------------------------------------------------------------------
+This SF.net email is sponsored by Windows:
+
+Build for Windows Store.
+
+http://p.sf.net/sfu/windows-dev2dev
+--n8g4imXOkfNTN/H1
+Content-Type: text/plain; charset="us-ascii"
+MIME-Version: 1.0
+Content-Transfer-Encoding: 7bit
+Content-Disposition: inline
+
+_______________________________________________
+OpenOCD-devel mailing list
+OpenOCD-devel@lists.sourceforge.net
+https://lists.sourceforge.net/lists/listinfo/openocd-devel
+
+--n8g4imXOkfNTN/H1--
diff --git a/openocd-jtag/stm32vldiscovery_bs.tcl b/openocd-jtag/stm32vldiscovery_bs.tcl
new file mode 100644 (file)
index 0000000..8f024c2
--- /dev/null
@@ -0,0 +1,54 @@
+# Example script to test STM32VLDiscovery with boundary scan
+
+init
+
+echo "\n\nStarting basic STM32VLDiscovery JTAG boundary scan test\n"
+
+source manual_bs.tcl
+
+init_bs stm32f1x.bs 232
+extest_mode
+exchange_bsr
+echo "All LEDs should be OFF, press Enter"
+read stdin 1
+
+# Set PC9 to output 1
+set_bit_bsr 72 0
+set_bit_bsr_do 71 1
+echo "Green LED should be ON, blue LED OFF, press Enter"
+read stdin 1
+
+# Set PC8 to output 1
+set_bit_bsr 75 0
+set_bit_bsr_do 74 1
+echo "Green and blue LEDs should be ON, press Enter"
+read stdin 1
+
+# Set PC9 to output 0
+set_bit_bsr_do 71 0
+echo "Blue LED should be ON, green LED OFF, press Enter"
+read stdin 1
+
+# Set PC9 to output 1
+set_bit_bsr_do 71 1
+foreach i {0 1} {
+    echo "Green and blue LEDs should be ON, do NOT press the USER button, press Enter"
+    read stdin 1
+    # Read PA0 state, there's a pulldown on board
+    if {[sample_get_bit_bsr 187] == 1} {
+       echo "Button is stuck at 1: ERROR, aborting"
+       shutdown
+       return
+    }
+
+    echo "Green and blue LEDs should be ON, DO press the USER button, press Enter"
+    read stdin 1
+    if {[sample_get_bit_bsr 187] == 0} {
+       echo "Button is stuck at 0: ERROR, aborting"
+       shutdown
+       return
+    }
+}
+
+echo "All tests passed SUCCESSFULLY, exiting"
+shutdown