-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpackage_corellium_RD1-AE_V1.1.1.sh
More file actions
244 lines (201 loc) · 6.2 KB
/
package_corellium_RD1-AE_V1.1.1.sh
File metadata and controls
244 lines (201 loc) · 6.2 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
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
#
# SPDX-FileCopyrightText: <text>Copyright 2025 Arm Limited and/or its
# affiliates <[email protected]></text>
#
# SPDX-License-Identifier: MIT
#! /bin/bash
# Initialize variables
type=""
distro=""
output=""
input=""
version="1.1.1"
firmware_name=""
verbose=false
# Function to display help
show_help() {
echo "Usage: $0 [options]"
echo "Options:"
echo " -t <type> Type of the package (accepted values: baremetal, virtualization, systemready-glibc)"
echo " -d <distro> Distribution (required if type is systemready-glibc)"
echo " -f <firmware> Firmware name"
echo " -o <output> Output path (optional)"
echo " -i <input> Input path (optional)"
echo " -v, Verbose"
echo " -h, Display this help message"
}
# Parse command-line arguments
while getopts ":t:d:o:i:f:vh" opt; do
case $opt in
t)
type=$OPTARG
if [[ "$type" != "baremetal" && "$type" != "virtualization" && "$type" != "systemready-glibc" ]]; then
echo "Invalid type: $type"
echo " "
show_help
exit 1
fi
;;
d)
distro=$OPTARG
if [[ "$distro" != "fedora" && "$distro" != "opensuse" && "$distro" != "debian" ]]; then
echo "Invalid distro: $distro"
echo " "
show_help
exit 1
fi
;;
o)
output=$OPTARG
;;
i)
input=$OPTARG
;;
v)
verbose=true
;;
f)
firmware_name=$OPTARG
;;
h)
show_help
exit 0
;;
\?)
echo "Invalid option: -$OPTARG" >&2
show_help
exit 1
;;
:)
echo "Option -$OPTARG requires an argument." >&2
show_help
exit 1
;;
esac
done
# Shift off the options and optional --.
shift $((OPTIND-1))
# Check if the mandatory -t option is provided
if [[ -z "$type" ]]; then
echo "Error: Option -t (type) is mandatory."
show_help
exit 1
fi
# Check if distro is provided when type is systemready-glibc
if [[ "$type" == "systemready-glibc" && -z "$distro" ]]; then
echo "Option -d (distro) is required when type is systemready-glibc."
show_help
exit 1
fi
if [[ -z "$firmware_name" ]]; then
package_name="${type}-${version}.coreimg"
else
package_name=$firmware_name
fi
if [[ -z "$input" ]]; then
input=build/tmp_${type}/deploy/images/fvp-rd-kronos
fi
if [[ -z "$output" ]]; then
output=${input}
fi
# Use the variables
echo "Type: $type"
echo "Distro: $distro"
echo "Output: $output"
echo "Input: $input"
echo "Version: $version"
echo "Firmware Name: $package_name"
START_PATH=$(pwd)
if [[ "$verbose" == true ]]; then
# option for cp
OPT="-v"
# option for zip
OPT_ZIP="-v"
else
OPT=""
OPT_ZIP=""
fi
ZIP_CMD=" zip "
#First rename the files
cp ${OPT} ${input}/rse-flash-image.img ${output}/boot_flash
cp ${OPT} ${input}/ap-flash-image.img ${output}/ap_flash
if [ -f ${input}/efi-capsule-update-disk-image-fvp-rd-kronos.img ]; then
# The file exists, so copy it
cp ${OPT} ${input}/efi-capsule-update-disk-image-fvp-rd-kronos.img ${output}/sdcard
elif [ -f ${input}/arm-systemready-linux-distros-${distro}*.iso ]; then
# The file exists, so copy it
cp ${OPT} ${input}/arm-systemready-linux-distros-${distro}*.iso ${output}/sdcard
else
# The file does not exist
truncate --size 4GiB ${output}/sdcard
fi
cp ${OPT} ${input}/rse-nvm-image.img ${output}/lcm_otp
if [ "${type}" = "baremetal" ] || [ "${type}" = "virtualization" ]; then
cp ${OPT} ${input}/${type}-image-fvp-rd-kronos.wic ${output}/virtio_0
else
cp ${OPT} ${input}/arm-systemready-linux-distros-${distro}*.wic ${output}/virtio_0
fi
cp ${OPT} ${input}/encrypted_dm_provisioning_bundle.bin ${output}/
cp ${OPT} ${input}/encrypted_cm_provisioning_bundle_0.bin ${output}/
cp ${OPT} ${input}/rse-rom-image.img ${output}/
# First, we need to pack the ROM and the CM/DM provisioning firmware bundles into a nested archive.
# These firmware components of the RD-1 AE are expected to be loaded into memory at specific addresses by a "debugger", or by the platform model.
# This nested archive contains scatter-gather instructions for how and where to load the relevant components.
# The resulting archive is just called `firmware`.
pushd ${output}
# AVH error : Error checking file: Sorry, the firmware package you uploaded does not support the selected device.
cat << EOF > load.txt
name:rse-rom-image.img load:0x11000000
name:encrypted_cm_provisioning_bundle_0.bin load:0x31000000
name:encrypted_dm_provisioning_bundle.bin load:0x31080000
EOF
${ZIP_CMD} ${OPT_ZIP} firmware.zip \
load.txt \
encrypted_cm_provisioning_bundle_0.bin \
encrypted_dm_provisioning_bundle.bin \
rse-rom-image.img
# Somehow it still produces firmware.zip , so remove the .zip
mv firmware.zip firmware
# Generate the package header
INFO_FILE=Info.json
cat << EOF > ${INFO_FILE}
{
"Build": "${type}",
"Version": "${version}",
"Type": "iot",
"DeviceIdentifier": "kronos-nosys",
"UniqueIdentifier": "${package_name}"
}
EOF
# Those binaries need to be extracted from a existing KronosV1.0 AVH firmware package.
cp ${OPT} ${START_PATH}/arm_cmn_0 arm_cmn_0
cp ${OPT} ${START_PATH}/arm_ni_710ae_10 arm_ni_710ae_10
cp ${OPT} ${START_PATH}/arm_ni_710ae_11 arm_ni_710ae_11
cp ${OPT} ${START_PATH}/arm_ni_710ae_12 arm_ni_710ae_12
cp ${OPT} ${START_PATH}/arm_ni_tower_0 arm_ni_tower_0
cp ${OPT} ${START_PATH}/arm_ni_tower_1 arm_ni_tower_1
cp ${OPT} ${START_PATH}/arm_ni_tower_2 arm_ni_tower_2
cp ${OPT} ${START_PATH}/arm_ni_tower_3 arm_ni_tower_3
cp ${OPT} ${START_PATH}/arm_ni_tower_4 arm_ni_tower_4
cp ${OPT} ${START_PATH}/arm_ni_tower_5 arm_ni_tower_5
cp ${OPT} ${START_PATH}/arm_ni_tower_6 arm_ni_tower_6
time ${ZIP_CMD} ${OPT_ZIP} ${START_PATH}/${package_name} \
${INFO_FILE} \
firmware\
ap_flash \
boot_flash \
virtio_0 \
sdcard \
lcm_otp \
arm_cmn_0 \
arm_ni_710ae_10 \
arm_ni_710ae_11 \
arm_ni_710ae_12 \
arm_ni_tower_0 \
arm_ni_tower_1 \
arm_ni_tower_2 \
arm_ni_tower_3 \
arm_ni_tower_4 \
arm_ni_tower_5 \
arm_ni_tower_6
popd