@@ -20,7 +20,7 @@ ELF_BINARY=""
20
20
21
21
autodetect_board () {
22
22
if [ ! -d /proc/device-tree/ ]; then
23
- echo " Proc Device tree are not available, Could not detect on which board we are" > /dev/kmsg
23
+ echo " Proc Device tree are not available, Could not detect on which board we are" > /dev/kmsg
24
24
exit 1
25
25
fi
26
26
@@ -34,10 +34,10 @@ autodetect_board() {
34
34
elif grep -q " stm32mp157" /proc/device-tree/compatible; then
35
35
BOARD=" STM32MP157_GENERIC"
36
36
else
37
- echo " Board is not an STM32MP157 BOARD" > /dev/kmsg
37
+ echo " Board is not an STM32MP157 BOARD" > /dev/kmsg
38
38
exit 1
39
39
fi
40
- echo " Board is $BOARD " > /dev/kmsg
40
+ echo " Board is $BOARD " > /dev/kmsg
41
41
}
42
42
43
43
firmware_load () {
@@ -46,42 +46,42 @@ firmware_load() {
46
46
exit 1
47
47
fi
48
48
49
- if (echo " $ELF_HASH $ELF_INSTALL_PATH " | sha256sum --status -c - 2> /dev/null); then
49
+ if (echo " $ELF_HASH $ELF_INSTALL_PATH " | sha256sum --status -c - 2> /dev/null); then
50
50
# The same firmware already exists, skip this step
51
51
echo " The same firmware is already installed. Starting..."
52
52
return 0
53
53
fi
54
54
55
55
# Decode base64-encoded binary to a temp directory and check hash
56
56
tmp_elf_file=" /tmp/$ELF_NAME "
57
- if which uudecode > /dev/null 2>&1 ; then
58
- printf " %s" " $ELF_BINARY " | uudecode -o /dev/stdout | gzip -d > " $tmp_elf_file "
57
+ if which uudecode > /dev/null 2>&1 ; then
58
+ printf " %s" " $ELF_BINARY " | uudecode -o /dev/stdout | gzip -d > " $tmp_elf_file "
59
59
else
60
- printf " %s" " $ELF_BINARY " | tail -n +2 | base64 -d - 2> /dev/null | gzip -d > " $tmp_elf_file "
60
+ printf " %s" " $ELF_BINARY " | tail -n +2 | base64 -d - 2> /dev/null | gzip -d > " $tmp_elf_file "
61
61
fi
62
62
echo " $ELF_HASH $tmp_elf_file " | sha256sum --status -c -
63
63
64
64
# Copy elf into /lib/firmware
65
65
mv $tmp_elf_file $ELF_INSTALL_PATH
66
- echo " Arduino: Executable created: $ELF_INSTALL_PATH " > /dev/kmsg
66
+ echo " Arduino: Executable created: $ELF_INSTALL_PATH " > /dev/kmsg
67
67
}
68
68
69
69
firmware_start () {
70
70
# Change the name of the firmware
71
- printf arduino.ino.elf > $REMOTEPROC_DIR /firmware
71
+ printf arduino.ino.elf > $REMOTEPROC_DIR /firmware
72
72
73
73
# Change path to found firmware
74
74
# printf /home/root >/sys/module/firmware_class/parameters/path
75
75
76
76
# Restart firmware
77
- echo " Arduino: Starting $ELF_INSTALL_PATH " > /dev/kmsg
78
- echo start > $REMOTEPROC_DIR /state 2> /dev/null || true
77
+ echo " Arduino: Starting $ELF_INSTALL_PATH " > /dev/kmsg
78
+ echo start > $REMOTEPROC_DIR /state 2> /dev/null || true
79
79
}
80
80
81
81
firmware_stop () {
82
82
# Stop the firmware
83
- echo " Arduino: Stopping $ELF_INSTALL_PATH " > /dev/kmsg
84
- echo stop > $REMOTEPROC_DIR /state 2> /dev/null || true
83
+ echo " Arduino: Stopping $ELF_INSTALL_PATH " > /dev/kmsg
84
+ echo stop > $REMOTEPROC_DIR /state 2> /dev/null || true
85
85
}
86
86
87
87
generate_packaged_script () {
@@ -96,25 +96,25 @@ generate_packaged_script() {
96
96
# Generate a copy of this script with a self-contained elf binary and its hash
97
97
# The elf binary is gzip'ed, making its size to 1/6, and then Base64-encoded
98
98
# using uuencode.
99
- head -n " $( grep -n " {%" " $this_script " | cut -d: -f1 | head -n 1) " " $this_script " > " $output_script "
100
- echo " ELF_HASH='$( sha256sum " $elf_path " | cut -d' ' -f1) '" >> " $output_script "
101
- printf " ELF_BINARY='" >> " $output_script "
102
- if which uuencode > /dev/null 2>&1 ; then
103
- gzip -c " $elf_path " | uuencode -m $ELF_NAME >> " $output_script "
99
+ head -n " $( grep -n " {%" " $this_script " | cut -d: -f1 | head -n 1) " " $this_script " > " $output_script "
100
+ echo " ELF_HASH='$( sha256sum " $elf_path " | cut -d' ' -f1) '" >> " $output_script "
101
+ printf " ELF_BINARY='" >> " $output_script "
102
+ if which uuencode > /dev/null 2>&1 ; then
103
+ gzip -c " $elf_path " | uuencode -m $ELF_NAME >> " $output_script "
104
104
else
105
- echo " begin-base64 644 $ELF_NAME " >> " $output_script "
106
- gzip -c " $elf_path " | base64 >> " $output_script "
105
+ echo " begin-base64 644 $ELF_NAME " >> " $output_script "
106
+ gzip -c " $elf_path " | base64 >> " $output_script "
107
107
fi
108
- echo " '" >> " $output_script "
109
- tail -n +" $( grep -n " %}" " $this_script " | cut -d: -f1 | head -n 1) " " $this_script " >> " $output_script "
110
- dos2unix " $output_script " 2> /dev/null
108
+ echo " '" >> " $output_script "
109
+ tail -n +" $( grep -n " %}" " $this_script " | cut -d: -f1 | head -n 1) " " $this_script " >> " $output_script "
110
+ dos2unix " $output_script " 2> /dev/null
111
111
}
112
112
113
113
systemd_install () {
114
114
mkdir -p " $( dirname $INSTALL_PATH ) "
115
115
cp " $0 " " $INSTALL_PATH "
116
116
echo " File created: $INSTALL_PATH "
117
- cat > " $SYSTEMD_SERVICE_PATH " << EOF
117
+ cat > " $SYSTEMD_SERVICE_PATH " << EOF
118
118
[Unit]
119
119
Description=Run Arduino firmware via remoteproc
120
120
After=systemd-modules-load.service
@@ -161,7 +161,7 @@ try_send() {
161
161
# Linux host must send any dummy data first to finish initialization of rpmsg
162
162
# on the coprocessor side. This message should be discarded.
163
163
# See: https://github.com/OpenAMP/open-amp/issues/182
164
- printf " DUMMY" > $RPMSG_DIR
164
+ printf " DUMMY" > $RPMSG_DIR
165
165
echo " Virtual serial $RPMSG_DIR connection established."
166
166
}
167
167
@@ -203,7 +203,7 @@ case "$1" in
203
203
;;
204
204
send-msg)
205
205
autodetect_board
206
- echo " ${@: 2 } " > $RPMSG_DIR
206
+ echo " ${@ } " | cut -c 3- > $RPMSG_DIR
207
207
;;
208
208
send-file)
209
209
autodetect_board
0 commit comments