-
Notifications
You must be signed in to change notification settings - Fork 1
287 lines (257 loc) · 10.9 KB
/
generate_firmware.yaml
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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
name: Generate Documents
on:
pull_request:
types: [opened, edited, review_requested, synchronize, review_request_removed, reopened]
branches:
- main
jobs:
job1:
name: Generate Docs
runs-on: ubuntu-20.04
permissions:
contents: read
pull-requests: write
steps:
- name: Checkout
uses: actions/[email protected]
- name: Write File
uses: DamianReeves/[email protected]
with:
# The path to the file to write
path: generate.sh
# The contents of the file
contents: |
#!/bin/bash
#./execute_test.sh $1 $2 $3 $4
# $1: task: all, gen-only, run-only
# $2: components: all, cpu_registers, programme_counter...
# $3: Platform: MG12, MG21, ZG23
# $4: Compiler: GCC, IAR
# $5: NON_SECURE_EN=1 or CRC_32=1, ...
# APP_SECURE=true or false
# Example
# With GCC
# export TOOL_DIRS=../SimplicityStudio_v5/developer/toolchains/gnu_arm/10.3_2021.10/bin
# ./execute_test.sh all invariable_memory 440165484 MG21 GCC
# With IAR
# export TOOL_DIRS=../IAR/iar_bxarm_9204/arm/bin
# ./execute_test.sh all invariable_memory 440165484 MG21 IAR
# Note:
# In case you want to build CRC32 run this command. For example
# ./execute_test.sh all invariable_memory 440165484 MG21 GCC "CRC_32=1 NON_SECURE_EN=true N_CRC_DEBUG=1 APP_SECURE=true"
# Print console log
function print
{
echo "=============== $1 ===============" | tee -a $LOG_FILE
}
# Print console log and timedate or summariz result
function print1
{
DATE="[$(date)]"
LOG="tee -a $LOG_FILE"
echo | $LOG
echo "================================================================================" | $LOG
if [ $# -ge 2 ]; then
echo "= $DATE " | $LOG
for arg in "$@"
do
echo -e "= $arg" | $LOG
done
else
echo -e "= $DATE $1" | $LOG
fi
echo "================================================================================" | $LOG
echo | $LOG
}
function gen_image
{
if [ -e $LOG_FILE ];then
rm -rf $LOG_FILE
fi
touch $LOG_FILE
pushd ../Make > /dev/null
if [[ "$1" = "all" ]]; then
print1 "Generate all components!"
print "Clean component"
log=$(make clean_all)
echo $log | tee -a $LOG_FILE
data=$(make info)
data=${data//"post bist integrated"/}
list_component=${data:17}
print $list_component
else
print "Generate only components: $1"
print "Clean component: $1"
log=$(make clean COMPONENT=$1 DERIVATIVE=$DERIVATIVE)
print "$log"
list_component="$1"
fi
print "Component list: ${list_component}"
# Get Compiler and Arguments
COMP=$2
ARG=$3
SECURE="S"
non_secure=""
if [[ "$ARG" == *"NON_SECURE_EN=true"* ]]; then
SECURE="NS"
non_secure="_NS"
fi
resultBuild=("\n======== Summariez the build results of all component ========\n")
sumResultBuild=""
for component in ${list_component}; do
print1 "Start build component: $component" "Compiler: $COMP" "Arguments: $ARG"
OUTPUT_PATH=$(pwd)/Build/$component/$DEVICE/$DERIVATIVE/$COMP/$SECURE/Out
# log=$(make clean COMPONENT=$component DERIVATIVE=efr32mg21a020f1024im32)
# echo $log | tee -a $LOG_FILE
if [ "$component" == "cpu_registers" ] && [ $DEVICE == "efr32mg24" ];then
print1 "\n==============================================================\n"
echo "Build component: $component chip: EFR32MG24 set arguments: APP_SECURE=true"
print1 "\n==============================================================\n"
log=$(make build COMPONENT=$component DERIVATIVE=$DERIVATIVE "APP_SECURE=true" COMPILER=$COMP) # >> $LOG_FILE
else
log=$(make build COMPONENT=$component DERIVATIVE=$DERIVATIVE $ARG COMPILER=$COMP) # >> $LOG_FILE
fi
echo "$log" | tee -a $LOG_FILE
result=$(tail -n 1 $LOG_FILE)
crc=""
if [ "$component" == "invariable_memory" ] || [ "$component" == "integrated" ]; then
if [[ "$ARG" == *"N_CRC_DEBUG=1"* ]]; then
use_crc_file=1
fi
if [[ "$ARG" == *"CRC_32=1"* ]]; then
crc="_crc32"
else
crc="_crc16"
fi
fi
file_out=iec60730_$component
file_out_ns=iec60730_$component$non_secure
file_out_ns_crc=iec60730_$component$non_secure$crc
if [ "$result" = "Target compiled." ]; then
print "Build successfully component: $component"
resultBuild+=("Success to build component: $component\n")
# pwd
pushd $ARTIFACT_PATH > /dev/null
print "Removing $file_out"
rm -rf $file_out.s37
rm -rf $file_out.lst
rm -rf $file_out.axf
rm -rf $file_out.hex
rm -rf $file_out.bin
print "Removing $file_out_ns"
rm -rf $file_out_ns.s37
rm -rf $file_out_ns.hex
rm -rf $file_out_ns.bin
print "Removing $file_out_ns_crc"
rm -rf $file_out_ns_crc.s37
rm -rf $file_out_ns_crc.hex
rm -rf $file_out_ns_crc.bin
popd > /dev/null
pushd $OUTPUT_PATH > /dev/null
print "Copying $file_out"
cp $file_out.s37 $ARTIFACT_PATH
if [ -f "$file_out.lst" ]; then
cp $file_out.lst $ARTIFACT_PATH
fi
cp $file_out.axf $ARTIFACT_PATH
cp $file_out.hex $ARTIFACT_PATH
cp $file_out.bin $ARTIFACT_PATH
# Copy file ns
print "Copying $file_out_ns"
if [ -f "$file_out_ns.s37" ]; then
cp $file_out_ns.s37 $ARTIFACT_PATH
fi
if [ -f "$file_out_ns.hex" ]; then
cp $file_out_ns.hex $ARTIFACT_PATH
fi
if [ -f "$file_out_ns.bin" ]; then
cp $file_out_ns.bin $ARTIFACT_PATH
fi
if [ -f "$file_out_ns.lst" ]; then
cp $file_out_ns.lst $ARTIFACT_PATH
fi
# Copy file with crc
print "Copying $file_out_ns_crc"
if [ -f "$file_out_ns_crc.s37" ]; then
cp $file_out_ns_crc.s37 $ARTIFACT_PATH
fi
if [ -f "$file_out_ns_crc.hex" ]; then
cp $file_out_ns_crc.hex $ARTIFACT_PATH
fi
if [ -f "$file_out_ns_crc.bin" ]; then
cp $file_out_ns_crc.bin $ARTIFACT_PATH
fi
popd > /dev/null
else
print "ERROR!!! Build component: $component fail"
resultBuild+=("Fail to build component: $component\n")
fi
done
for restBuild in "${resultBuild[@]}"
do
sumResultBuild="$sumResultBuild$restBuild\n"
done
# Print summariez the build results
print1 "$sumResultBuild"
popd > /dev/null
}
LOG_PATH=$(pwd)/log
LOG_FILE=$LOG_PATH/log.txt
ARTIFACT_PATH=$(pwd)/artifact
if [ "$3" == "MG21" ]; then
CHIP=EFR32MG21AXXXF1024
DERIVATIVE=efr32mg21a020f1024im32
DEVICE=efr32mg21
elif [ "$3" == "MG12" ]; then
CHIP=EFR32MG12PXXXF1024
DERIVATIVE=efr32mg12p332f1024gl125
DEVICE=efr32mg12p
elif [ "$3" == "ZG23" ]; then
CHIP=EFR32ZG23BXXXF512
DERIVATIVE=efr32zg23b010f512im48
DEVICE=efr32zg23
elif [ "$3" == "FG23" ]; then
CHIP=EFR32FG23BXXXF512
DERIVATIVE=efr32fg23b020f512im48
DEVICE=efr32fg23
elif [ "$3" == "MG24" ]; then
CHIP=EFR32MG24BXXXF1536
DERIVATIVE=efr32mg24b310f1536im48
DEVICE=efr32mg24
else
echo "Does not support platform: $3"
exit
fi
# LST_PATH=$ARTIFACT_PATH
# LST_PATH=$(pwd)/../Build/cpu_registers/efr32mg21/efr32mg21a020f1024im32/Out
if [ ! -e "artifact" ];then
mkdir -p artifact
fi
if [ ! -e "log" ];then
mkdir -p log
fi
arg=${6//"%20"/" "}
gen_image "$2" "$4" "$arg"
write-mode: overwrite
- name: Generate Firmwares
run: |
sudo -R chmod 777 .
./generate.sh $COMMAND $COMPONENT $PLATFORM $COMPILER $SECURITY
- name: Zip Release
# You may pin to the exact commit or the version.
# uses: TheDoctor0/zip-release@b57d897cb5d60cb78b51a507f63fa184cfe35554
uses: TheDoctor0/[email protected]
with:
# Filename for archive
filename: firmware.7z
# Base path for archive files
path: artifact
# Working directory before zipping
directory: .
- name: Upload artifact
uses: actions/[email protected]
with:
name: firmware
path: .
warn: Output a warning but do not fail the action
retention-days: 90