-
Notifications
You must be signed in to change notification settings - Fork 1
/
flash.sh
executable file
·36 lines (29 loc) · 1002 Bytes
/
flash.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#! /bin/bash
set -e
set -o nounset
set -o pipefail
EXTENSIONS_DIR=./extension/src/freertos_apps/microros_nucleo_f767zi_extensions
RTOS=freertos
PLATFORM=nucleo_f767zi
USE_STFLASH=false
pushd $EXTENSIONS_DIR > /dev/null
if [ -f build/micro-ROS.bin ]; then
echo "Flashing firmware for $RTOS platform $PLATFORM"
if [$USE_STFLASH = true]; then
st-flash --reset write build/micro-ROS.bin 0x8000000
else
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/stm32f7x.cfg -c init -c "reset halt" -c "flash write_image erase build/micro-ROS.bin 0x08000000" -c "reset" -c "exit"
fi
else
echo "build/micro-ROS.bin not found: please compile before flashing."
fi
popd > /dev/null