-
Notifications
You must be signed in to change notification settings - Fork 177
Expand file tree
/
Copy pathflash_firmware.sh
More file actions
executable file
·36 lines (31 loc) · 1.06 KB
/
flash_firmware.sh
File metadata and controls
executable file
·36 lines (31 loc) · 1.06 KB
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
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
export DEVICE_NAME=${1:-/dev/ttyUSB0}
# Flash specific firmware folder if needed
if [ $PLATFORM == "generic" ] || [ ! -d "$PREFIX/config/$RTOS/$PLATFORM" ]; then
if [ -f $PREFIX/config/$RTOS/generic/flash.sh ]; then
echo "Flashing firmware for $RTOS platform $PLATFORM"
. $PREFIX/config/$RTOS/generic/flash.sh
else
echo "No flash step found for $RTOS platform $PLATFORM"
fi
else
if [ -f $PREFIX/config/$RTOS/$PLATFORM/flash.sh ]; then
echo "Flashing firmware for $RTOS platform $PLATFORM"
. $PREFIX/config/$RTOS/$PLATFORM/flash.sh
else
echo "No flash step found for $RTOS platform $PLATFORM"
fi
fi