Skip to content

Commit 04419fc

Browse files
committed
refactor: debos: data-driven flash recipe
Rewrite flash recipe to use a data-driven approach to board definitions instead of duplicating logic for each board. Signed-off-by: Loïc Minier <[email protected]>
1 parent a772d94 commit 04419fc

File tree

1 file changed

+89
-127
lines changed

1 file changed

+89
-127
lines changed

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

Lines changed: 89 additions & 127 deletions
Original file line numberDiff line numberDiff line change
@@ -14,41 +14,73 @@ actions:
1414
filename: qcom-ptool.tar.gz
1515
unpack: true
1616

17+
{{- $boards := list }}
18+
{{- if eq $build_qcm6490 "true" }}
19+
{{- $boards = append $boards (dict
20+
"name" "qcs6490-rb3gen2-vision-kit"
21+
"silicon_family" "qcm6490"
22+
"platform" "qcs6490-rb3gen2"
23+
"boot_binaries_download" (dict
24+
"description" "QCM6490 boot binaries"
25+
"url" "https://softwarecenter.qualcomm.com/download/software/chip/qualcomm_linux-spf-1-0/qualcomm-linux-spf-1-0_test_device_public/r1.0_00095.0/qcm6490-le-1-0/common/build/ufs/bin/QCM6490_bootbinaries.zip"
26+
"name" "qcm6490_boot-binaries"
27+
"filename" "qcm6490_boot-binaries.zip"
28+
"sha256sum" "9c100d7b184ecf0ab9c4be71a8bb7c243fdc79a64380ca3025024dd2b14c5078"
29+
)
30+
"cdt_download" (dict
31+
"description" "RB3 Gen2 Vision Kit CDT"
32+
"url" "https://artifacts.codelinaro.org/artifactory/codelinaro-le/Qualcomm_Linux/QCS6490/cdt/rb3gen2-vision-kit.zip"
33+
"name" "qcs6490-rb3gen2-vision-kit_cdt"
34+
"filename" "qcs6490-rb3gen2-vision-kit_cdt.zip"
35+
"sha256sum" "a339e297b454c4dc3805fe8cd11d6d8dcb801aa8f0c2dc691561c2785019fa3c"
36+
)
37+
"cdt_filename" "cdt_vision_kit.bin"
38+
"dtb" "qcom/qcs6490-rb3gen2.dtb"
39+
"disk_image_type" "ufs"
40+
)}}
41+
{{- end }}
1742
{{- if eq $build_rb1 "true" }}
18-
# TODO: consider switching to https://releases.linaro.org/96boards/rb1/qualcomm/firmware/RB1_firmware_20231124-v4.zip instead
19-
- action: download
20-
description: Download RB1 rescue image
21-
url: https://releases.linaro.org/96boards/rb1/linaro/rescue/23.12/rb1-bootloader-emmc-linux-47528.zip
22-
name: qrb2210-rb1_rescue-image.zip
23-
filename: qrb2210-rb1_rescue-image.zip
24-
- action: run
25-
description: Verify download
26-
chroot: false
27-
command: echo c75b6c63eb24c8ca36dad08ba4d4e93f3f4cd7dce60cf1b6dfb5790dc181cc3d ${ROOTDIR}/../qrb2210-rb1_rescue-image.zip|sha256sum --strict -c -
43+
{{- $boards = append $boards (dict
44+
"name" "qrb2210-rb1"
45+
"silicon_family" "qcm2290"
46+
"platform" "qrb2210-rb1"
47+
"boot_binaries_download" (dict
48+
"description" "RB1 rescue image"
49+
"url" "https://releases.linaro.org/96boards/rb1/linaro/rescue/23.12/rb1-bootloader-emmc-linux-47528.zip"
50+
"name" "qrb2210-rb1_rescue-image"
51+
"filename" "qrb2210-rb1_rescue-image.zip"
52+
"sha256sum" "c75b6c63eb24c8ca36dad08ba4d4e93f3f4cd7dce60cf1b6dfb5790dc181cc3d"
53+
)
54+
"disk_image_type" "sdcard"
55+
"u_boot_file" .u_boot_rb1
56+
)}}
2857
{{- end }}
2958

30-
{{- if eq $build_qcm6490 "true" }}
59+
{{- range $board := $boards }}
3160
- action: download
32-
description: Download QCM6490 boot binaries
33-
url: https://softwarecenter.qualcomm.com/download/software/chip/qualcomm_linux-spf-1-0/qualcomm-linux-spf-1-0_test_device_public/r1.0_00095.0/qcm6490-le-1-0/common/build/ufs/bin/QCM6490_bootbinaries.zip
34-
name: qcm6490_boot-binaries
35-
filename: qcm6490_boot-binaries.zip
61+
description: Download of {{ $board.boot_binaries_download.description }}
62+
url: {{ $board.boot_binaries_download.url }}
63+
name: {{ $board.boot_binaries_download.name }}
64+
filename: {{ $board.boot_binaries_download.filename }}
3665
- action: run
37-
description: Verify download
66+
description: Verify SHA256 sum of {{ $board.boot_binaries_download.description }}
3867
chroot: false
39-
command: echo 9c100d7b184ecf0ab9c4be71a8bb7c243fdc79a64380ca3025024dd2b14c5078 ${ROOTDIR}/../qcm6490_boot-binaries.zip|sha256sum --strict -c -
40-
{{- end }}
41-
42-
{{- if eq $build_qcm6490 "true" }}
68+
command:
69+
echo "{{ $board.boot_binaries_download.sha256sum }} ${ROOTDIR}/../{{ $board.boot_binaries_download.filename }}" |
70+
sha256sum --strict -c -
71+
{{- if $board.cdt_download }}
4372
- action: download
44-
description: Download RB3 Gen2 Vision Kit CDT
45-
url: https://artifacts.codelinaro.org/artifactory/codelinaro-le/Qualcomm_Linux/QCS6490/cdt/rb3gen2-vision-kit.zip
46-
name: qcs6490-rb3gen2-vision-kit_cdt
47-
filename: qcs6490-rb3gen2-vision-kit_cdt.zip
73+
description: Download of {{ $board.cdt_download.description }}
74+
url: {{ $board.cdt_download.url }}
75+
name: {{ $board.cdt_download.name }}
76+
filename: {{ $board.cdt_download.filename }}
4877
- action: run
49-
description: Verify download
78+
description: Verify SHA256 sum of {{ $board.cdt_download.description }}
5079
chroot: false
51-
command: echo a339e297b454c4dc3805fe8cd11d6d8dcb801aa8f0c2dc691561c2785019fa3c ${ROOTDIR}/../qcs6490-rb3gen2-vision-kit_cdt.zip|sha256sum --strict -c -
80+
command:
81+
echo "{{ $board.cdt_download.sha256sum }} ${ROOTDIR}/../{{ $board.cdt_download.filename }}" |
82+
sha256sum --strict -c -
83+
{{- end }}
5284
{{- end }}
5385

5486
- action: run
@@ -62,18 +94,20 @@ actions:
6294
# path to unpacked qcom-ptool tarball
6395
QCOM_PTOOL="${ROOTDIR}/../qcom-ptool.tar.gz.d/qcom-ptool-main"
6496
65-
{{- if eq $build_rb1 "true" }}
66-
## silicon family: qcm2290
67-
# use RB1 rescue image as there are no qcm2290 boot binaries published
68-
unzip -j "${ROOTDIR}/../qrb2210-rb1_rescue-image.zip" \
69-
-d build/qrb2210-rb1_rescue-image
97+
{{- range $board := $boards }}
98+
### board: {{ $board.name }}
99+
### platform: {{ $board.platform }}
100+
### silicon family: {{ $board.silicon_family }}
101+
102+
# unpack boot binaries
103+
unzip -j "${ROOTDIR}/../{{ $board.boot_binaries_download.filename }}" \
104+
-d build/{{ $board.name }}_boot-binaries
70105

71-
### platform: qrb2210-rb1
72106
# generate partition files
73-
mkdir -v build/qrb2210-rb1_partitions
107+
mkdir -v build/{{ $board.platform }}_partitions
74108
(
75-
cd build/qrb2210-rb1_partitions
76-
conf="${QCOM_PTOOL}/platforms/qrb2210-rb1/partitions.conf"
109+
cd build/{{ $board.platform }}_partitions
110+
conf="${QCOM_PTOOL}/platforms/{{ $board.platform }}/partitions.conf"
77111
"${QCOM_PTOOL}/gen_partition.py" -i "$conf" \
78112
-o ptool-partitions.xml
79113
# partitions.conf sets --type=emmc, nand or ufs
@@ -85,12 +119,12 @@ actions:
85119
"${QCOM_PTOOL}/ptool.py" -x ptool-partitions.xml
86120
)
87121

88-
#### board: qrb2210-rb1
89-
flash_dir="${ARTIFACTDIR}/flash_qrb2210-rb1"
122+
# create board-specific flash directory
123+
flash_dir="${ARTIFACTDIR}/flash_{{ $board.name }}"
90124
rm -rf "${flash_dir}"
91125
mkdir -v "${flash_dir}"
92126
# copy platform partition files
93-
cp --preserve=mode,timestamps -v build/qrb2210-rb1_partitions/* \
127+
cp --preserve=mode,timestamps -v build/{{ $board.platform }}_partitions/* \
94128
"${flash_dir}"
95129
# remove BLANK_GPT and WIPE_PARTITIONS files as it's common for people
96130
# to run "qdl rawprogram*.xml", mistakingly including these; perhaps
@@ -100,7 +134,7 @@ actions:
100134
rm -v "${flash_dir}"/rawprogram*_WIPE_PARTITIONS.xml
101135
# copy silicon family boot binaries; these shouldn't ship partition
102136
# files, but make sure not to accidentally clobber any such file
103-
find build/qrb2210-rb1_rescue-image \
137+
find build/{{ $board.name }}_boot-binaries \
104138
-not -name 'gpt_*' \
105139
-not -name 'patch*.xml' \
106140
-not -name 'rawprogram*.xml' \
@@ -116,96 +150,28 @@ actions:
116150
-or -name '*.mbn' \
117151
\) \
118152
-exec cp --preserve=mode,timestamps -v '{}' "${flash_dir}" \;
119-
# copy RB1 U-Boot binary to boot.img;
153+
{{- if $board.u_boot_file }}
154+
# copy U-Boot binary to boot.img;
120155
# qcom-ptool/platforms/*/partitions.conf uses filename=boot.img
121156
# boot_a and boot_b partitions
122-
cp --preserve=mode,timestamps -v "${ARTIFACTDIR}/{{- .u_boot_rb1 -}}" \
157+
cp --preserve=mode,timestamps -v "${ARTIFACTDIR}/{{ $board.u_boot_file }}" \
123158
"${flash_dir}/boot.img"
159+
{{- end }}
124160

125-
# update flashing files for ESP image;
126-
# qcom-ptool/platforms/*/partitions.conf uses filename=efi.bin for the
127-
# ESP partition on EFI capable platforms
128-
sed -i '/label="efi"/s#filename="[^"]*"#filename="../disk-sdcard.img1"#' \
129-
"${flash_dir}"/rawprogram*.xml
130-
131-
# update flashing files for rootfs image;
132-
# qcom-ptool/platforms/*/partitions.conf uses filename=rootfs.img for the
133-
# rootfs partition
134-
sed -i \
135-
'/label="rootfs"/s#filename="[^"]*"#filename="../disk-sdcard.img2"#' \
136-
"${flash_dir}"/rawprogram*.xml
137-
138-
# TODO: there is currently no dtb.bin alike system with the RB1 firmware
139-
140-
# TODO: currently not providing CDT; it's present in
141-
# RB1_firmware_20231124-v4.zip but not in
142-
# rb1-bootloader-emmc-linux-47528.zip
143-
{{- end }}
144-
145-
{{- if eq $build_qcm6490 "true" }}
146-
## silicon family: qcm6490
147-
# unpack boot binaries
148-
unzip -j "${ROOTDIR}/../qcm6490_boot-binaries.zip" \
149-
-d build/qcm6490_boot-binaries
150-
151-
### platform: qcs6490-rb3gen2
152-
# generate partition files
153-
mkdir -v build/qcs6490-rb3gen2_partitions
154-
(
155-
cd build/qcs6490-rb3gen2_partitions
156-
conf="${QCOM_PTOOL}/platforms/qcs6490-rb3gen2/partitions.conf"
157-
"${QCOM_PTOOL}/gen_partition.py" -i "$conf" \
158-
-o ptool-partitions.xml
159-
# partitions.conf sets --type=emmc, nand or ufs
160-
if grep -F '^--disk --type=ufs ' "${conf}"; then
161-
touch flash-ufs
162-
elif grep -F '^--disk --type=emmc ' "${conf}"; then
163-
touch flash-emmc
164-
fi
165-
"${QCOM_PTOOL}/ptool.py" -x ptool-partitions.xml
166-
)
167-
#### board qcs6490-rb3gen2-vision-kit
168-
flash_dir="${ARTIFACTDIR}/flash_qcs6490-rb3gen2-vision-kit"
169-
rm -rf "${flash_dir}"
170-
mkdir -v "${flash_dir}"
171-
# copy platform partition files
172-
cp --preserve=mode,timestamps -v build/qcs6490-rb3gen2_partitions/* \
173-
"${flash_dir}"
174-
# remove BLANK_GPT and WIPE_PARTITIONS files as it's common for people
175-
# to run "qdl rawprogram*.xml", mistakingly including these; perhaps
176-
# ptool should have a flag not to generate these; note that there are
177-
# wipe_rawprogram*.xml files still
178-
rm -v "${flash_dir}"/rawprogram*_BLANK_GPT.xml
179-
rm -v "${flash_dir}"/rawprogram*_WIPE_PARTITIONS.xml
180-
# copy silicon family boot binaries; these shouldn't ship partition
181-
# files, but make sure not to accidentally clobber any such file
182-
find build/qcm6490_boot-binaries \
183-
-not -name 'gpt_*' \
184-
-not -name 'patch*.xml' \
185-
-not -name 'rawprogram*.xml' \
186-
-not -name 'wipe*.xml' \
187-
-not -name 'zeros_*' \
188-
\( \
189-
-name LICENSE \
190-
-or -name Qualcomm-Technologies-Inc.-Proprietary \
191-
-or -name 'prog_*' \
192-
-or -name '*.bin' \
193-
-or -name '*.elf' \
194-
-or -name '*.fv' \
195-
-or -name '*.mbn' \
196-
\) \
197-
-exec cp --preserve=mode,timestamps -v '{}' "${flash_dir}" \;
161+
{{- if $board.cdt_download }}
198162
# unpack board CDT
199-
unzip -j "${ROOTDIR}/../qcs6490-rb3gen2-vision-kit_cdt.zip" \
200-
-d build/qcs6490-rb3gen2-vision-kit_cdt
163+
unzip -j "${ROOTDIR}/../{{ $board.cdt_download.filename }}" \
164+
-d build/{{ $board.name }}_cdt
201165
# copy just the CDT data; no partition or flashing files
202-
cp --preserve=mode,timestamps -v build/qcs6490-rb3gen2-vision-kit_cdt/cdt_vision_kit.bin \
166+
cp --preserve=mode,timestamps -v build/{{ $board.name }}_cdt/{{ $board.cdt_filename }} \
203167
"${flash_dir}"
204168

205169
# update flashing files for CDT
206-
sed -i '/label="cdt"/s/filename=""/filename="cdt_vision_kit.bin"/' \
170+
sed -i '/label="cdt"/s/filename=""/filename="{{ $board.cdt_filename }}"/' \
207171
"${flash_dir}"/rawprogram*.xml
172+
{{- end }}
208173

174+
{{- if $board.dtb }}
209175
# generate a dtb.bin FAT partition with just a single dtb for the current
210176
# board; long-term this should really be a set of dtbs and overlays as to
211177
# share dtb.bin across boards
@@ -218,28 +184,24 @@ actions:
218184
# in these and hold the target device tree, which is 4096 KiB sized
219185
# blocks for mkfs.vfat's last argument
220186
mkfs.vfat -S 4096 -C "${dtb_bin}" 4096
221-
# RB3 Gen2 Vision Kit will probably have a more specific DTB (see
222-
# <[email protected]> on lore.kernel.org)
223-
# but for now use the core kit one
224-
dtb="qcom/qcs6490-rb3gen2.dtb"
225187
# extract board device tree from the root filesystem provided tarball
226-
tar -C build -xvf "${ARTIFACTDIR}/dtbs.tar.gz" "${dtb}"
188+
tar -C build -xvf "${ARTIFACTDIR}/dtbs.tar.gz" "{{ $board.dtb }}"
227189
# copy into the FAT as combined-dtb.dtb
228-
mcopy -vmp -i "${dtb_bin}" "build/${dtb}" ::/combined-dtb.dtb
229-
190+
mcopy -vmp -i "${dtb_bin}" "build/{{ $board.dtb }}" ::/combined-dtb.dtb
230191
# (NB: flashing files already expect "dtb.bin" as a filename)
192+
{{- end }}
231193

232194
# update flashing files for ESP image;
233195
# qcom-ptool/platforms/*/partitions.conf uses filename=efi.bin for the
234196
# ESP partition on EFI capable platforms
235-
sed -i '/label="efi"/s#filename="[^"]*"#filename="../disk-ufs.img1"#' \
197+
sed -i '/label="efi"/s#filename="[^"]*"#filename="../disk-{{ $board.disk_image_type }}.img1"#' \
236198
"${flash_dir}"/rawprogram*.xml
237199

238200
# update flashing files for rootfs image;
239201
# qcom-ptool/platforms/*/partitions.conf uses filename=rootfs.img for the
240202
# rootfs partition
241203
sed -i \
242-
'/label="rootfs"/s#filename="[^"]*"#filename="../disk-ufs.img2"#' \
204+
'/label="rootfs"/s#filename="[^"]*"#filename="../disk-{{ $board.disk_image_type }}.img2"#' \
243205
"${flash_dir}"/rawprogram*.xml
244206
{{- end }}
245207

0 commit comments

Comments
 (0)