Create a gist now

Instantly share code, notes, and snippets.

@jcw /burn.sh
Created Mar 7, 2017

What would you like to do?
OpenOCD setup on Raspberry Pi
#!/bin/sh
# Upload to attached µC via SWD.
case "$2" in
"") echo "need target type (f1x/l0) and name of image to burn as args"
exit 1 ;;
esac
TARGET=$1 IMAGE=$2 /usr/local/bin/openocd
#!/bin/sh
# Upload to attached µC via Serial & GPIO for RESET/BOOT0.
case "$2" in
"") echo "need target type (f1x/l0) and name of image to burn as args"
exit 1 ;;
esac
case "$1" in
l0) extra="-e 254" ;;
esac
stm32flash -i 23,-18,18:-23,-18,18 $extra -w images-$1/$2.hex /dev/ttyAMA0
# OpenOCD configuration for Rasberry Pi, with GPIO as SWD
# see http://jeelabs.org/article/1710c/
source rpi-native.cfg
transport select swd
if {[info exists ::env(TARGET)]} {
source [find target/stm32$::env(TARGET).cfg]
} else {
source [find target/stm32l0.cfg]
}
# did not yet manage to make a working setup using srst
reset_config srst_only srst_push_pull
#reset_config srst_only
#reset_config srst_nogate
#reset_config none
gdb_memory_map disable
adapter_nsrst_delay 100
adapter_nsrst_assert_width 100
init
#targets
#reset halt
if {[info exists ::env(TARGET)] && [info exists ::env(IMAGE)]} {
program images-$::env(TARGET)/$::env(IMAGE).hex 0x8000000 verify reset exit
}
# Config for using Raspberry Pi's expansion header
# This is for RasPi 1's - others need a different bcm2835gpio_peripheral_base
interface bcm2835gpio
bcm2835gpio_peripheral_base 0x20000000
# These depend on system clock, calibrated for stock 700MHz
bcm2835gpio_speed_coeffs 146203 36
# Header pin numbers: SWCLK - 22, SWDIO - 18
bcm2835gpio_swd_nums 25 24
# Header pin number: SRST - 12
bcm2835gpio_srst_num 18
#reset_config srst_only srst_push_pull
reset_config none
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment