2016-10-09 19:47:53 -04:00
|
|
|
# This script configures OpenOCD for use with an ST-Link V2 programmer/debugger
|
|
|
|
# and an STM32L4 target microcontroller.
|
|
|
|
#
|
|
|
|
# To flash your firmware:
|
|
|
|
#
|
|
|
|
# $ openocd -f openocd_stm32l4.cfg \
|
2017-01-22 14:12:37 -05:00
|
|
|
# -c "stm_flash build-BOARD/firmware0.bin 0x08000000 build-BOARD/firmware1.bin 0x08004000"
|
2016-10-09 19:47:53 -04:00
|
|
|
#
|
|
|
|
# For a gdb server on port 3333:
|
|
|
|
#
|
|
|
|
# $ openocd -f openocd_stm32l4.cfg
|
|
|
|
|
|
|
|
|
|
|
|
source [find interface/stlink-v2-1.cfg]
|
|
|
|
transport select hla_swd
|
|
|
|
source [find target/stm32l4x.cfg]
|
|
|
|
reset_config srst_only
|
|
|
|
init
|
|
|
|
|
2018-12-12 21:43:10 -05:00
|
|
|
proc stm_flash { BIN0 ADDR0 {BIN1 ""} {ADDR1 ""} } {
|
2016-10-09 19:47:53 -04:00
|
|
|
reset halt
|
|
|
|
sleep 100
|
|
|
|
wait_halt 2
|
2016-11-26 11:34:31 -05:00
|
|
|
flash write_image erase $BIN0 $ADDR0
|
2016-10-09 19:47:53 -04:00
|
|
|
sleep 100
|
2016-11-26 11:34:31 -05:00
|
|
|
verify_image $BIN0 $ADDR0
|
2016-10-09 19:47:53 -04:00
|
|
|
sleep 100
|
2018-12-12 21:43:10 -05:00
|
|
|
if {$BIN1 ne ""} {
|
|
|
|
flash write_image erase $BIN1 $ADDR1
|
|
|
|
sleep 100
|
|
|
|
verify_image $BIN1 $ADDR1
|
|
|
|
sleep 100
|
|
|
|
}
|
2016-10-09 19:47:53 -04:00
|
|
|
reset run
|
|
|
|
shutdown
|
|
|
|
}
|
|
|
|
|
|
|
|
proc stm_erase {} {
|
|
|
|
reset halt
|
|
|
|
sleep 100
|
|
|
|
stm32l4x mass_erase 0
|
|
|
|
sleep 100
|
|
|
|
shutdown
|
|
|
|
}
|