Skip to content

Instantly share code, notes, and snippets.

@elfmimi
Last active July 13, 2021 10:24
Show Gist options
  • Save elfmimi/098632c86a5482a4b3d48ff91467b121 to your computer and use it in GitHub Desktop.
Save elfmimi/098632c86a5482a4b3d48ff91467b121 to your computer and use it in GitHub Desktop.
JTAG Boundary-Scan Examples for OpenOCD
# OpenOCD script to demonstrate JTAG Boundary-Scan I/O
# It will update the state of LED connected to PC13 according to input level on PB2/BOOT1.
# Supports STM32F103x8 and STM32F103xB
# See STM32F1_Med_density_LQFP48.bsd
#
# Invoke it like this:
# openocd -f interface/usb-jtag.cfg -f STM32F1-PB2-to-PC13.tcl
jtag newtap stm32f1x cpu -irlen 4 -expected-id 0x3ba00477
jtag newtap stm32f1x bs -irlen 5 -expected-id 0x06410041 -expected-id 0x16410041
init
# IDCODE
irscan stm32f1x.bs 1
if ![string match ?6410041 [drscan stm32f1x.bs 32 0x00000000]] {
error "Unexpected IDCODE"
}
# SAMPLE/PRELOAD
irscan stm32f1x.bs 2
set sample [drscan stm32f1x.bs 232 0xfffFFfffffffffffffffffffffffffffffffffffffffffffffffffffff]
# EXTEST
irscan stm32f1x.bs 0
while true {
set pb2 [expr (0x[string range $sample 20 21] & 128) ? 1 : 0]
if $pb2 {
set send_data 0xfffE7fffffffffffffffffffffffffffffffffffffffffffffffffffff
} else {
set send_data 0xfffEFfffffffffffffffffffffffffffffffffffffffffffffffffffff
}
drscan stm32f1x.bs 232 $send_data
sleep 100
set sample [drscan stm32f1x.bs 232 $send_data]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment