Last active
July 13, 2021 10:24
-
-
Save elfmimi/098632c86a5482a4b3d48ff91467b121 to your computer and use it in GitHub Desktop.
JTAG Boundary-Scan Examples for OpenOCD
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// JTAG Boundary-Scan command sequence to blink LED connected to PC13 | |
// Supports STM32F103x8 and STM32F103xB | |
// See STM32F1_Med_density_LQFP48.bsd | |
// | |
// Invoke it like this: | |
// openocd -f interface/usb-jtag.cfg -f target/stm32f1x.cfg -c "init; svf -tap stm32f1x.bs test3.svf quiet" -c exit | |
SIR 5 TDI (01); // IDCODE | |
SDR 32 TDI(00000000) TDO (06410041) MASK (0fffffff) ; | |
SIR 5 TDI (02); // SAMPLE/PRELOAD | |
SDR 232 TDI (fffE7fffffffffffffffffffffffffffffffffffffffffffffffffffff); | |
SIR 5 TDI (00); // EXTEST | |
RUNTEST 500000 TCK; | |
SDR 232 TDI (fffEFfffffffffffffffffffffffffffffffffffffffffffffffffffff); | |
RUNTEST 500000 TCK; | |
SDR 232 TDI (fffE7fffffffffffffffffffffffffffffffffffffffffffffffffffff); | |
RUNTEST 500000 TCK; | |
SDR 232 TDI (fffEFfffffffffffffffffffffffffffffffffffffffffffffffffffff); | |
RUNTEST 500000 TCK; | |
SDR 232 TDI (fffE7fffffffffffffffffffffffffffffffffffffffffffffffffffff); | |
RUNTEST 500000 TCK; | |
SDR 232 TDI (fffFFfffffffffffffffffffffffffffffffffffffffffffffffffffff); | |
SIR 5 TDI (1F); // BYPASS |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# OpenOCD script to blink LED connected to PC13 | |
# Supports STM32F103x8 and STM32F103xB | |
# See STM32F1_Med_density_LQFP48.bsd | |
# | |
# Invoke it like this: | |
# openocd -f interface/usb-jtag.cfg -f STM32F1-blink-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 | |
drscan stm32f1x.bs 232 0xfffFFfffffffffffffffffffffffffffffffffffffffffffffffffffff | |
# EXTEST | |
irscan stm32f1x.bs 0 | |
while true { | |
drscan stm32f1x.bs 232 0xfffE7fffffffffffffffffffffffffffffffffffffffffffffffffffff | |
sleep 500 | |
drscan stm32f1x.bs 232 0xfffEFfffffffffffffffffffffffffffffffffffffffffffffffffffff | |
sleep 500 | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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