-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathfw_cortex_m4.sh
66 lines (52 loc) · 1.07 KB
/
fw_cortex_m4.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
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
#!/bin/sh
rproc_class_dir="/sys/class/remoteproc/remoteproc0/"
fmw_dir="/lib/firmware"
project_name=$(basename $(pwd))
fmw_name="avenger96_sensor_cluster.elf"
echo "fw_cortex_m4.sh: fmw_name=${fmw_name}"
rproc_state=`tr -d '\0' < $rproc_class_dir/state`
error() {
echo -e "$1"
exit 0
}
case $1 in
start) ;;
stop) ;;
*) echo "`basename ${0}`:usage: start | stop"
exit 1
;;
esac
#################
# Start example #
#################
if [ $1 == "start" ]
then
if [ $rproc_state == "running" ]
then
echo "Stopping running fw ..."
echo stop > $rproc_class_dir/state
fi
# Create /lib/firmware directory if not exist
if [ ! -d $fmw_dir ]
then
echo "Create $fmw_dir directory"
mkdir $fmw_dir
fi
# Copy firmware in /lib/firmware
cp lib/firmware/$fmw_name $fmw_dir/
# load and start firmware
echo $fmw_name > $rproc_class_dir/firmware
echo start > $rproc_class_dir/state
fi
################
# Stop example #
################
if [ $1 == "stop" ]
then
if [ $rproc_state == "offline" ]
then
echo "Nothing to do, no M4 fw is running"
else
echo stop > $rproc_class_dir/state
fi
fi