解锁
- #!/usr/bin/env bash
-
- case "$1" in
- "-dap" | "dap-link")
- echo "You choose the DAP-Link"
- INTERFACE=cmsis-dap.cfg
- ;;
- "-st" | "st-link")
- echo "You choose the ST-Link V2"
- INTERFACE=stlink-v2.cfg
- ;;
- "-j" | "j-link")
- echo "You choose the J-Link"
- INTERFACE=jlink.cfg
- ;;
- "-h" | "help" | *)
- echo -e "$0 [command] \n \
- dap-link | -dap Unlock by DAP-Link\n \
- st-link | -st Unlock by ST-Link V2\n \
- j-link | -j Unlock by J-Link\n \
- help | -h Show the help\n"
- exit
- ;;
- esac
-
- SOURCE=/usr/share/openocd/
- INTERFACE_CFG=${SOURCE}scripts/interface/${INTERFACE}
- TARGET_CFG=${SOURCE}scripts/target/stm32f1x.cfg
- PWD=$(dirname "$(readlink -f "$0")")
-
- echo "开始连接"
- openocd -f ${INTERFACE_CFG} \
- -f ${TARGET_CFG} \
- -c "init" \
- -c "halt" \
- -c "stm32f1x unlock 0" \
- -c "reset halt" \
- -c "exit"
-
下载
- #!/usr/bin/env bash
-
- case "$1" in
- "-dap" | "dap-link")
- echo "You choose the DAP-Link"
- INTERFACE=cmsis-dap.cfg
- ;;
- "-st" | "st-link")
- echo "You choose the ST-Link V2"
- INTERFACE=stlink-v2.cfg
- ;;
- "-j" | "j-link")
- echo "You choose the J-Link"
- INTERFACE=jlink.cfg
- ;;
- "-h" | "help" | *)
- echo -e "$0 [command] \n \
- dap-link | -dap Download by DAP-Link\n \
- st-link | -st Download by ST-Link V2\n \
- j-link | -j Download by J-Link\n \
- help | -h Show the help\n"
- exit
- ;;
- esac
-
-
- SOURCE=/usr/share/openocd/
- INTERFACE_CFG=${SOURCE}scripts/interface/$INTERFACE
- TARGET_CFG=${SOURCE}scripts/target/stm32f1x.cfg
- PWD=$(dirname "$(readlink -f "$0")")
- # BIN=${PWD}/build/LED.bin
- HEX=${PWD}/build/LED.hex
-
- echo "开始连接"
- openocd -f ${INTERFACE_CFG} \
- -f ${TARGET_CFG} \
- -c "init" \
- -c "reset" \
- -c "halt" \
- -c "flash erase_sector 0 0 last" \
- -c "flash write_image erase ${HEX}" \
- -c "reset" \
- -c "shutdown"
|