-
Notifications
You must be signed in to change notification settings - Fork 145
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
openocd: added script to reset devices (#399)
(cherry picked from commit 7a2aeaf)
- Loading branch information
1 parent
2b326a3
commit fcf4459
Showing
11 changed files
with
230 additions
and
0 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
EXTENSIONS_DIR=$FW_TARGETDIR/freertos_apps/microros_nucleo_f446re_extensions | ||
|
||
pushd $EXTENSIONS_DIR > /dev/null | ||
|
||
echo "Resetting firmware for $RTOS platform $PLATFORM" | ||
if lsusb -d 0483:374b; then | ||
ST_INTERFACE=interface/stlink-v2-1.cfg | ||
elif lsusb -d 0483:3748; then | ||
ST_INTERFACE=interface/stlink-v2.cfg | ||
else | ||
# TODO: add stlink v3, should it be stlink.cfg ? | ||
echo "Error. Unsuported OpenOCD USB programmer" | ||
exit 1 | ||
fi | ||
openocd -f $ST_INTERFACE -f target/stm32f4x.cfg -c init -c "reset halt" -c "reset" -c "exit" | ||
|
||
popd > /dev/null |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
EXTENSIONS_DIR=$FW_TARGETDIR/freertos_apps/microros_nucleo_f446ze_extensions | ||
|
||
pushd $EXTENSIONS_DIR > /dev/null | ||
|
||
echo "Resetting firmware for $RTOS platform $PLATFORM" | ||
if lsusb -d 0483:374b; then | ||
ST_INTERFACE=interface/stlink-v2-1.cfg | ||
elif lsusb -d 0483:3748; then | ||
ST_INTERFACE=interface/stlink-v2.cfg | ||
else | ||
# TODO: add stlink v3, should it be stlink.cfg ? | ||
echo "Error. Unsuported OpenOCD USB programmer" | ||
exit 1 | ||
fi | ||
openocd -f $ST_INTERFACE -f target/stm32f4x.cfg -c init -c "reset halt" -c "reset" -c "exit" | ||
|
||
popd > /dev/null |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
EXTENSIONS_DIR=$FW_TARGETDIR/freertos_apps/microros_nucleo_f746zg_extensions | ||
|
||
pushd $EXTENSIONS_DIR > /dev/null | ||
|
||
echo "Resetting firmware for $RTOS platform $PLATFORM" | ||
if lsusb -d 0483:374b; then | ||
ST_INTERFACE=interface/stlink-v2-1.cfg | ||
elif lsusb -d 0483:3748; then | ||
ST_INTERFACE=interface/stlink-v2.cfg | ||
else | ||
# TODO: add stlink v3, should it be stlink.cfg ? | ||
echo "Error. Unsuported OpenOCD USB programmer" | ||
exit 1 | ||
fi | ||
openocd -f $ST_INTERFACE -f target/stm32f4x.cfg -c init -c "reset halt" -c "reset" -c "exit" | ||
|
||
popd > /dev/null |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
EXTENSIONS_DIR=$FW_TARGETDIR/freertos_apps/microros_nucleo_f767zi_extensions | ||
|
||
pushd $EXTENSIONS_DIR > /dev/null | ||
|
||
echo "Resetting firmware for $RTOS platform $PLATFORM" | ||
if lsusb -d 0483:374b; then | ||
ST_INTERFACE=interface/stlink-v2-1.cfg | ||
elif lsusb -d 0483:3748; then | ||
ST_INTERFACE=interface/stlink-v2.cfg | ||
else | ||
# TODO: add stlink v3, should it be stlink.cfg ? | ||
echo "Error. Unsuported OpenOCD USB programmer" | ||
exit 1 | ||
fi | ||
openocd -f $ST_INTERFACE -f target/stm32f4x.cfg -c init -c "reset halt" -c "reset" -c "exit" | ||
|
||
popd > /dev/null |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
OLIMEX_EXTENSIONS_DIR=$FW_TARGETDIR/freertos_apps/microros_olimex_e407_extensions | ||
|
||
pushd $OLIMEX_EXTENSIONS_DIR > /dev/null | ||
|
||
if lsusb -d 15BA:002a; then | ||
PROGRAMMER=interface/ftdi/olimex-arm-usb-tiny-h.cfg | ||
elif lsusb -d 15BA:0003;then | ||
PROGRAMMER=interface/ftdi/olimex-arm-usb-ocd.cfg | ||
elif lsusb -d 15BA:002b;then | ||
PROGRAMMER=interface/ftdi/olimex-arm-usb-ocd-h.cfg | ||
else | ||
echo "Error. Unsuported OpenOCD USB programmer" | ||
exit 1 | ||
fi | ||
|
||
openocd -f $PROGRAMMER -f target/stm32f4x.cfg -c init -c "reset halt" -c "reset" -c "exit" | ||
|
||
popd > /dev/null | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
echo "Nothing to reset: running in host mode" | ||
echo "Use 'RMW_IMPLEMENTATION=rmw_microxrcedds ros2 run micro_ros_demos_rcl int32_subscriber' to start with examples" |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#! /bin/bash | ||
|
||
set -e | ||
set -o nounset | ||
set -o pipefail | ||
|
||
|
||
pushd $FW_TARGETDIR/NuttX > /dev/null | ||
|
||
if [ "$PLATFORM" = "olimex-stm32-e407" ]; then | ||
echo "Resetting firmware for $RTOS platform $PLATFORM" | ||
|
||
if lsusb -d 15BA:002a; then | ||
PROGRAMMER=interface/ftdi/olimex-arm-usb-tiny-h.cfg | ||
elif lsusb -d 15BA:0003;then | ||
PROGRAMMER=interface/ftdi/olimex-arm-usb-ocd.cfg | ||
elif lsusb -d 15BA:002b;then | ||
PROGRAMMER=interface/ftdi/olimex-arm-usb-ocd-h.cfg | ||
elif lsusb -d 0483:3748;then | ||
PROGRAMMER=interface/stlink-v2.cfg | ||
else | ||
echo "Error. Unsuported OpenOCD USB programmer" | ||
exit 1 | ||
fi | ||
|
||
openocd -f $PROGRAMMER -f target/stm32f4x.cfg -c init -c "reset halt" -c "reset" -c "exit" | ||
else | ||
echo "Unrecognized board: $PLATFORM" | ||
exit 1 | ||
fi | ||
|
||
popd > /dev/null |
Empty file.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
pushd $FW_TARGETDIR > /dev/null | ||
|
||
ZEPHYR_BUILD_DIR="$FW_TARGETDIR/build/zephyr" | ||
|
||
# Host platform (=native_posix) is special, as resetting is stopping and re-executing the binary | ||
if [ "$PLATFORM" = "host" ]; then | ||
|
||
# TODO: stop the previous process | ||
$ZEPHYR_BUILD_DIR/zephyr.exe | ||
|
||
else | ||
|
||
# These boards need special openocd rules | ||
RESET_OPENOCD=false | ||
if [ "$PLATFORM" = "olimex-stm32-e407" ]; then | ||
|
||
RESET_OPENOCD=true | ||
OPENOCD_TARGET="stm32f4x.cfg" | ||
if lsusb -d 15BA:002a; then | ||
OPENOCD_PROGRAMMER=interface/ftdi/olimex-arm-usb-tiny-h.cfg | ||
elif lsusb -d 15BA:0003;then | ||
OPENOCD_PROGRAMMER=interface/ftdi/olimex-arm-usb-ocd.cfg | ||
elif lsusb -d 15BA:002b;then | ||
OPENOCD_PROGRAMMER=interface/ftdi/olimex-arm-usb-ocd-h.cfg | ||
else | ||
echo "Error: Unsuported OpenOCD USB programmer" | ||
exit 1 | ||
fi | ||
|
||
elif [ "$PLATFORM" = "nucleo_f446re" ]; then | ||
|
||
RESET_OPENOCD=true | ||
OPENOCD_TARGET="stm32f4x.cfg" | ||
|
||
if lsusb -d 0483:374b;then | ||
OPENOCD_PROGRAMMER=interface/stlink-v2-1.cfg | ||
else | ||
echo "Error: Unsupported OpenOCD programmer" | ||
exit 1 | ||
fi | ||
|
||
elif [ "$PLATFORM" = "nucleo_h743zi" ]; then | ||
|
||
RESET_OPENOCD=true | ||
OPENOCD_TARGET="stm32h7x.cfg" | ||
|
||
if lsusb -d 0483:374e;then | ||
OPENOCD_PROGRAMMER=interface/stlink.cfg | ||
else | ||
echo "Error: Unsupported OpenOCD programmer" | ||
exit 1 | ||
fi | ||
|
||
fi | ||
|
||
|
||
|
||
if [ "$RESET_OPENOCD" = true ]; then | ||
|
||
openocd -f $OPENOCD_PROGRAMMER -f target/$OPENOCD_TARGET \ | ||
-c init \ | ||
-c "reset halt" \ | ||
-c "reset run; exit" | ||
|
||
else | ||
|
||
echo "Error: Resetting device is only supported with OpenOCD" | ||
exit 1 | ||
|
||
fi | ||
|
||
fi | ||
|
||
popd > /dev/null |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
#! /bin/bash | ||
|
||
set -e | ||
set -o nounset | ||
set -o pipefail | ||
|
||
FW_TARGETDIR=$(pwd)/firmware | ||
PREFIX=$(ros2 pkg prefix micro_ros_setup) | ||
|
||
# Checking if firmware exists | ||
if [ -d $FW_TARGETDIR ]; then | ||
RTOS=$(head -n1 $FW_TARGETDIR/PLATFORM) | ||
PLATFORM=$(head -n2 firmware/PLATFORM | tail -n1) | ||
else | ||
echo "Firmware folder not found. Please use ros2 run micro_ros_setup create_firmware_ws.sh to create a new project." | ||
exit 1 | ||
fi | ||
|
||
# Reset specific firmware | ||
if [ $PLATFORM != "generic" ] && [ -d "$PREFIX/config/$RTOS/generic" ]; then | ||
if [ -f $PREFIX/config/$RTOS/generic/reset.sh ]; then | ||
echo "Resetting firmware for $RTOS platform $PLATFORM" | ||
. $PREFIX/config/$RTOS/generic/reset.sh | ||
else | ||
echo "No reset step found for $RTOS platform $PLATFORM" | ||
fi | ||
else | ||
if [ -f $PREFIX/config/$RTOS/$PLATFORM/reset.sh ]; then | ||
echo "Resetting firmware for $RTOS platform $PLATFORM" | ||
. $PREFIX/config/$RTOS/$PLATFORM/reset.sh | ||
else | ||
echo "No reset step found for $RTOS platform $PLATFORM" | ||
fi | ||
fi |