-
Notifications
You must be signed in to change notification settings - Fork 176
Expand file tree
/
Copy pathconfigure_firmware.sh
More file actions
executable file
·90 lines (79 loc) · 2.33 KB
/
configure_firmware.sh
File metadata and controls
executable file
·90 lines (79 loc) · 2.33 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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
#! /bin/bash
set -e
set -o nounset
set -o pipefail
export FW_TARGETDIR=$(pwd)/firmware
export 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
# Check if configure script exists
if [ $PLATFORM == "generic" ] || [ ! -d "$PREFIX/config/$RTOS/$PLATFORM" ]; then
if [ ! -f $PREFIX/config/$RTOS/generic/configure.sh ]; then
echo "No configuration step needed for generic platform $PLATFORM"
exit 0
fi
else
if [ ! -f $PREFIX/config/$RTOS/$PLATFORM/configure.sh ]; then
echo "No configuration step needed for $RTOS platform $PLATFORM"
exit 0
fi
fi
# Parsing micro-ROS arguments
if [ $# -lt 1 ]; then
echo "micro-ROS application name must be provided: ros2 run micro_ros_setup configure_firmware.sh [app name] [options]"
# Check if RTOS has app listing funcions and source in case
if [ -f $PREFIX/config/$RTOS/list_apps.sh ]; then
. $PREFIX/config/$RTOS/list_apps.sh
print_available_apps
fi
exit 1
fi
if [ -f $PREFIX/config/$RTOS/list_apps.sh ]; then
. $PREFIX/config/$RTOS/list_apps.sh
check_available_app $1
fi
export CONFIG_NAME=$1
shift
while [[ $# -gt 0 ]]; do
key="$1"
case $key in
-t|--transport)
export UROS_TRANSPORT="$2"
shift # past argument
shift # past value
;;
-d|--dev)
export UROS_AGENT_DEVICE="$2"
shift # past argument
shift # past value
;;
-i|--ip)
export UROS_AGENT_IP="$2"
shift # past argument
shift # past value
;;
-p|--port)
export UROS_AGENT_PORT="$2"
shift # past argument
shift # past value
;;
*) # unknown option
echo "Unknown argument $1"
exit 1
;;
esac
done
# Configure specific firmware folder if needed
if [ $PLATFORM == "generic" ] || [ ! -d "$PREFIX/config/$RTOS/$PLATFORM" ]; then
echo "Configuring firmware for $RTOS platform $PLATFORM"
exec $PREFIX/config/$RTOS/generic/configure.sh $@
else
echo "Configuring firmware for $RTOS platform $PLATFORM"
exec $PREFIX/config/$RTOS/$PLATFORM/configure.sh $@
fi