Skip to content

Commit 1939dbd

Browse files
authored
Merge pull request #142 from lool/gen-contents-xml
Generate contents.xml flash files for Axiom
2 parents 4b78afb + 6ab99f0 commit 1939dbd

File tree

1 file changed

+72
-32
lines changed

1 file changed

+72
-32
lines changed

debos-recipes/qualcomm-linux-debian-flash.yaml

Lines changed: 72 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ actions:
3838
)
3939
"cdt_filename" "cdt_vision_kit.bin"
4040
"dtb" "qcom/qcs6490-rb3gen2.dtb"
41-
"disk_image_type" "ufs"
4241
)}}
4342
{{- end }}
4443
{{- if eq $build_qcs8300 "true" }}
@@ -62,7 +61,6 @@ actions:
6261
)
6362
"cdt_filename" "cdt_ride_sx.bin"
6463
"dtb" "qcom/qcs8300-ride.dtb"
65-
"disk_image_type" "ufs"
6664
)}}
6765
{{- end }}
6866
{{- if eq $build_qcs9100 "true" }}
@@ -86,7 +84,6 @@ actions:
8684
)
8785
"cdt_filename" "cdt_ride_sx.bin"
8886
"dtb" "qcom/qcs9100-ride-r3.dtb"
89-
"disk_image_type" "ufs"
9087
)}}
9188
{{- end }}
9289
{{- if eq $build_rb1 "true" }}
@@ -101,7 +98,6 @@ actions:
10198
"filename" "qrb2210-rb1_rescue-image.zip"
10299
"sha256sum" "c75b6c63eb24c8ca36dad08ba4d4e93f3f4cd7dce60cf1b6dfb5790dc181cc3d"
103100
)
104-
"disk_image_type" "sdcard"
105101
"u_boot_file" .u_boot_rb1
106102
)}}
107103
{{- end }}
@@ -157,19 +153,81 @@ actions:
157153
mv build/{{ $board.name }}_boot-binaries/unpack/*/* build/{{ $board.name }}_boot-binaries
158154
rmdir -v build/{{ $board.name }}_boot-binaries/unpack/* build/{{ $board.name }}_boot-binaries/unpack
159155

160-
# generate partition files
161-
mkdir -v build/{{ $board.platform }}_partitions
156+
# generate ptool files - various XML files for flashing, GPT data etc.
157+
mkdir -v build/{{ $board.platform }}_ptool
162158
(
163-
cd build/{{ $board.platform }}_partitions
159+
cd build/{{ $board.platform }}_ptool
164160
conf="${QCOM_PTOOL}/platforms/{{ $board.platform }}/partitions.conf"
165-
"${QCOM_PTOOL}/gen_partition.py" -i "$conf" \
161+
contents="${QCOM_PTOOL}/platforms/{{ $board.platform }}/contents.xml.in"
162+
disk_type="unknown"
163+
# make a copy of partitions.conf; infer storage type from lines
164+
# like:
165+
# --disk --type=ufs --size=137438953472 ...
166+
# or:
167+
# --disk --type=emmc --size=76841669632 ...
168+
# and patch/add filenames for partitions from lines like:
169+
# --partition --lun=4 --name=dtb_a ... --filename=dtb.bin
170+
# or without filename like:
171+
# --partition --lun=3 --name=cdt --size=128KB --type-guid=...
172+
# for data from the following table
173+
#
174+
# |--------|--------------|-------------------|-----------------|
175+
# | data | ptool name | ptool filename | debos filename |
176+
# |--------|--------------|-------------------|-----------------|
177+
# | ESP | efi | efi.bin | disk-media.img1 |
178+
# | rootfs | rootfs | rootfs.img | disk-media.img2 |
179+
# | DTBs | dtb_a, dtb_b | dtb.bin | dtb.bin |
180+
# | CDTs | cdt | unset / per board | from download |
181+
# |--------|--------------|-------------------|-----------------|
182+
while read line; do
183+
case "$line" in
184+
# detect storage type
185+
"--disk "*)
186+
disk_type="$(echo "$line" | sed -n 's/.*--type=\([^ ]*\).*/\1/p')"
187+
case $disk_type in
188+
"emmc")
189+
touch flash-emmc
190+
esp="../disk-sdcard.img1"
191+
rootfs="../disk-sdcard.img2"
192+
;;
193+
"ufs")
194+
touch flash-ufs
195+
esp="../disk-ufs.img1"
196+
rootfs="../disk-ufs.img2"
197+
;;
198+
esac
199+
;;
200+
# read partitions
201+
"--partition "*)
202+
name="$(echo "$line" | sed -n 's/.*--name=\([^ ]*\).*/\1/p')"
203+
filename=""
204+
case "$name" in
205+
dtb_a|dtb_b) filename="dtb.bin";;
206+
efi) filename="$esp";;
207+
rootfs) filename="$rootfs";;
208+
{{- if $board.cdt_download }}
209+
cdt) filename={{ $board.cdt_filename }};;
210+
{{- end }}
211+
esac
212+
# override/set filename
213+
if [ -n "$filename" ]; then
214+
line="$(echo "$line" | sed 's/ --filename=[^ ]*//')"
215+
line="${line} --filename=${filename}"
216+
fi
217+
;;
218+
esac
219+
echo "$line"
220+
done <"$conf" >partitions.conf
221+
# generate ptool-partitions.xml from partitions.conf
222+
"${QCOM_PTOOL}/gen_partition.py" -i partitions.conf \
166223
-o ptool-partitions.xml
167-
# partitions.conf sets --type=emmc, nand or ufs
168-
if grep -F '^--disk --type=ufs ' "${conf}"; then
169-
touch flash-ufs
170-
elif grep -F '^--disk --type=emmc ' "${conf}"; then
171-
touch flash-emmc
224+
# generate contents.xml from ptool-partitions.xml and contents.xml.in
225+
if [ -e "$contents" ]; then
226+
"${QCOM_PTOOL}/gen_contents.py" -p ptool-partitions.xml \
227+
-t "$contents" \
228+
-o contents.xml
172229
fi
230+
# generate flashing files from qcom-partitions.xml
173231
"${QCOM_PTOOL}/ptool.py" -x ptool-partitions.xml
174232
)
175233

@@ -178,7 +236,7 @@ actions:
178236
rm -rf "${flash_dir}"
179237
mkdir -v "${flash_dir}"
180238
# copy platform partition files
181-
cp --preserve=mode,timestamps -v build/{{ $board.platform }}_partitions/* \
239+
cp --preserve=mode,timestamps -v build/{{ $board.platform }}_ptool/* \
182240
"${flash_dir}"
183241
# remove BLANK_GPT and WIPE_PARTITIONS files as it's common for people
184242
# to run "qdl rawprogram*.xml", mistakingly including these; perhaps
@@ -219,10 +277,6 @@ actions:
219277
# copy just the CDT data; no partition or flashing files
220278
cp --preserve=mode,timestamps -v build/{{ $board.name }}_cdt/{{ $board.cdt_filename }} \
221279
"${flash_dir}"
222-
223-
# update flashing files for CDT
224-
sed -i '/label="cdt"/s/filename=""/filename="{{ $board.cdt_filename }}"/' \
225-
"${flash_dir}"/rawprogram*.xml
226280
{{- end }}
227281

228282
{{- if $board.dtb }}
@@ -242,21 +296,7 @@ actions:
242296
tar -C build -xvf "${ARTIFACTDIR}/dtbs.tar.gz" "{{ $board.dtb }}"
243297
# copy into the FAT as combined-dtb.dtb
244298
mcopy -vmp -i "${dtb_bin}" "build/{{ $board.dtb }}" ::/combined-dtb.dtb
245-
# (NB: flashing files already expect "dtb.bin" as a filename)
246299
{{- end }}
247-
248-
# update flashing files for ESP image;
249-
# qcom-ptool/platforms/*/partitions.conf uses filename=efi.bin for the
250-
# ESP partition on EFI capable platforms
251-
sed -i '/label="efi"/s#filename="[^"]*"#filename="../disk-{{ $board.disk_image_type }}.img1"#' \
252-
"${flash_dir}"/rawprogram*.xml
253-
254-
# update flashing files for rootfs image;
255-
# qcom-ptool/platforms/*/partitions.conf uses filename=rootfs.img for the
256-
# rootfs partition
257-
sed -i \
258-
'/label="rootfs"/s#filename="[^"]*"#filename="../disk-{{ $board.disk_image_type }}.img2"#' \
259-
"${flash_dir}"/rawprogram*.xml
260300
{{- end }}
261301

262302
# cleanup

0 commit comments

Comments
 (0)