Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
76 changes: 8 additions & 68 deletions debos-recipes/qualcomm-linux-debian-flash.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -334,74 +334,14 @@ actions:
(
cd build/ptool/{{ $platform }}
conf="${QCOM_PTOOL}/platforms/{{ $platform }}/partitions.conf"
contents="${QCOM_PTOOL}/platforms/{{ $platform }}/contents.xml.in"
disk_type="unknown"
# make a copy of partitions.conf; infer storage type from lines
# like:
# --disk --type=ufs --size=137438953472 ...
# or:
# --disk --type=emmc --size=76841669632 ...
# and patch/add filenames for partitions from lines like:
# --partition --lun=4 --name=dtb_a ... --filename=dtb.bin
# or without filename like:
# --partition --lun=3 --name=cdt --size=128KB --type-guid=...
# for data from the following table
#
# |--------|--------------|-------------------|-----------------|
# | data | ptool name | ptool filename | debos filename |
# |--------|--------------|-------------------|-----------------|
# | ESP | efi | efi.bin | disk-media.img1 |
# | rootfs | rootfs | rootfs.img | disk-media.img2 |
# | DTBs | dtb_a, dtb_b | dtb.bin | dtb.bin |
# | CDTs | cdt | unset / per board | from download |
# |--------|--------------|-------------------|-----------------|
while read line; do
case "$line" in
# detect storage type
"--disk "*)
disk_type="$(echo "$line" | sed -n 's/.*--type=\([^ ]*\).*/\1/p')"
case $disk_type in
emmc|nvme)
esp="../disk-sdcard.img1"
rootfs="../disk-sdcard.img2"
;;
ufs)
esp="../disk-ufs.img1"
rootfs="../disk-ufs.img2"
;;
spinor)
# spinor carries firmware only; no OS efi/rootfs partitions
esp=""
rootfs=""
;;
*)
echo "unsupported disk type $disk_type"
exit 1
;;
esac
echo "$disk_type" >disk_type
;;
# read partitions
"--partition "*)
name="$(echo "$line" | sed -n 's/.*--name=\([^ ]*\).*/\1/p')"
filename=""
case "$name" in
dtb_a|dtb_b) filename="dtb.bin";;
efi) filename="$esp";;
rootfs) filename="$rootfs";;
{{- if $board.cdt_download }}
cdt) filename="$(basename {{ $board.cdt_filename }})";;
{{- end }}
esac
# override/set filename
if [ -n "$filename" ]; then
line="$(echo "$line" | sed 's/ --filename=[^ ]*//')"
line="${line} --filename=${filename}"
fi
;;
esac
echo "$line"
done <"$conf" >partitions.conf

{{- if $board.cdt_download }}
../override-partition-conf.sh "{{ $board.cdt_filename }}" <"$conf" >partitions.conf
{{- else }}
../override-partition-conf.sh "" <"$conf" >partitions.conf
{{- end }}

contents="${QCOM_PTOOL}/platforms/${PLATFORM}/contents.xml.in"
# generate ptool-partitions.xml from partitions.conf
"${QCOM_PTOOL}/gen_partition.py" -i partitions.conf \
-o ptool-partitions.xml
Expand Down
85 changes: 85 additions & 0 deletions override-partition-conf.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
#!/bin/sh

set -eux

CDT_FILENAME="$1"

disk_type="unknown"

# make a copy of partitions.conf; infer storage type from lines
# like:
# --disk --type=ufs --size=137438953472 ...
# or:
# --disk --type=emmc --size=76841669632 ...
# and patch/add filenames for partitions from lines like:
# --partition --lun=4 --name=dtb_a ... --filename=dtb.bin
# or without filename like:
# --partition --lun=3 --name=cdt --size=128KB --type-guid=...
# for data from the following table
#
# |--------|--------------|-------------------|-----------------|
# | data | ptool name | ptool filename | debos filename |
# |--------|--------------|-------------------|-----------------|
# | ESP | efi | efi.bin | disk-media.img1 |
# | rootfs | rootfs | rootfs.img | disk-media.img2 |
# | DTBs | dtb_a, dtb_b | dtb.bin | dtb.bin |
# | CDTs | cdt | unset / per board | from download |
# |--------|--------------|-------------------|-----------------|

while read line; do
case "$line" in
# detect storage type
"--disk "*)
disk_type="$(echo "$line" | sed -n 's/.*--type=\([^ ]*\).*/\1/p')"
case $disk_type in
emmc|nvme)
esp="../disk-sdcard.img1"
rootfs="../disk-sdcard.img2"
;;
ufs)
esp="../disk-ufs.img1"
rootfs="../disk-ufs.img2"
;;
spinor)
# spinor carries firmware only; no OS efi/rootfs partitions
esp=""
rootfs=""
;;
*)
echo "unsupported disk type $disk_type"
exit 1
;;
esac
echo "$disk_type" >disk_type
;;
# read partitions
"--partition "*)
name="$(echo "$line" | sed -n 's/.*--name=\([^ ]*\).*/\1/p')"
filename=""
case "$name" in
dtb_a|dtb_b)
filename="dtb.bin"
;;
efi)
filename="$esp"
;;
rootfs)
filename="$rootfs"
;;
cdt)
if [ -n "${CDT_FILENAME}" ]; then
filename="$(basename "${CDT_FILENAME}")"
else
echo "cdt partition found but missing cdt_filename, skipping"
fi
;;
esac
# override/set filename
if [ -n "$filename" ]; then
line="$(echo "$line" | sed 's/ --filename=[^ ]*//')"
line="${line} --filename=${filename}"
fi
;;
esac
echo "$line"
done
Loading