Skip to content

Commit 33f59bf

Browse files
committed
fix(debos/flash): Pack SPI-NOR under respective target-storage directory
- Place platform *_spinor directories under the corresponding target storage directory (emmc/ufs/nvme). - Rename SPI-NOR filenames and paths in spinor/content.xml to match the respective images. - Update the README to mention required build dependencies. - Centralize the disk-type detection logic into get-rawprogram-filename. Signed-off-by: Vishwas Udupa <vudupa@qti.qualcomm.com>
1 parent a026136 commit 33f59bf

6 files changed

Lines changed: 74 additions & 4 deletions

File tree

.github/workflows/debos.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ jobs:
7272

7373
# mtools is needed for the flash recipe
7474
- name: Install debos and dependencies of the recipes and local tests
75-
run: apt -y install debian-archive-keyring debos make mmdebstrap mtools python3-pexpect python3-pytest qemu-efi-aarch64 qemu-system-arm
75+
run: apt -y install debian-archive-keyring debos make mmdebstrap mtools python3-pexpect python3-pytest qemu-efi-aarch64 qemu-system-arm xmlstarlet python3-defusedxml
7676

7777
- name: Setup local APT repo
7878
run: |

.github/workflows/static-checks.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ jobs:
3939
runs-on: ubuntu-latest
4040
steps:
4141
- name: Install Pylint and dependencies
42-
run: sudo apt update && sudo apt -y install file pylint python3-voluptuous
42+
run: sudo apt update && sudo apt -y install file pylint python3-voluptuous python3-defusedxml
4343

4444
- uses: actions/checkout@v6
4545
with:

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,12 @@ scripts/build-linux-deb.py --linux-next kernel-configs/*.config
7979

8080
### Build the image
8181

82+
Building the image requires the following build-dependencies:
83+
84+
```bash
85+
apt -y install debian-archive-keyring make mmdebstrap mtools python3-pexpect python3-pytest qemu-efi-aarch64 qemu-system-arm xmlstarlet python3-defusedxml
86+
```
87+
8288
To build flashable assets for all supported boards, follow these steps:
8389

8490
1. build tarballs of the root filesystem and DTBs

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

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -439,6 +439,35 @@ actions:
439439
fi
440440
{{- end }}
441441

442+
# copy each spinor flash dir into its parent storage flash dirs;
443+
# storage types are read from product_info/chipid in contents.xml
444+
for spinor_dir in "${ARTIFACTDIR}"/flash_*_spinor; do
445+
contents_xml="${spinor_dir}/contents.xml"
446+
[ -f "${contents_xml}" ] || continue
447+
spinor_dir_name="$(basename "${spinor_dir}")"
448+
board="${spinor_dir_name#flash_}"; board="${board%_spinor}"
449+
xmlstarlet sel -t -m "//product_info/chipid" -v "@storage_type" -n "${contents_xml}" | \
450+
tr '[:upper:]' '[:lower:]' | sort -u | \
451+
while read -r storage; do
452+
[ "${storage}" = "spinor" ] && continue
453+
target_dir="${ARTIFACTDIR}/flash_${board}_${storage}"
454+
[ -d "${target_dir}" ] || continue
455+
cp --preserve=all --no-dereference -av "${spinor_dir}/." "${target_dir}/spinor/"
456+
efi_img=$("${RECIPEDIR}/../scripts/get-rawprogram-filename.py" efi "${target_dir}/rawprogram0.xml")
457+
rootfs_img=$("${RECIPEDIR}/../scripts/get-rawprogram-filename.py" rootfs "${target_dir}/rawprogram0.xml")
458+
# fix file_path (../->../../) then rename efi.bin/rootfs.img
459+
copied_contents="${target_dir}/spinor/contents.xml"
460+
if [ -f "${copied_contents}" ]; then
461+
xmlstarlet ed -L \
462+
-u "//*[@storage_type='${storage}'][file_name/text()='efi.bin']/file_path[text()='../']" -v "../../" \
463+
-u "//*[@storage_type='${storage}']/file_name[text()='efi.bin']" -v "${efi_img}" \
464+
-u "//*[@storage_type='${storage}'][file_name/text()='rootfs.img']/file_path[text()='../']" -v "../../" \
465+
-u "//*[@storage_type='${storage}']/file_name[text()='rootfs.img']" -v "${rootfs_img}" \
466+
"${copied_contents}"
467+
fi
468+
done
469+
done
470+
442471
# cleanup
443472
rm -rf build
444473

scripts/bundle-flash-dirs.sh

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,12 @@ for d in flash_*
1515
do
1616
rawprogram0="$d/rawprogram0.xml"
1717
echo "examining $rawprogram0"
18-
if grep disk-sdcard "$rawprogram0"
18+
rootfs_img=$("$(dirname "$0")"/get-rawprogram-filename.py rootfs "$rawprogram0")
19+
if echo "$rootfs_img" | grep -q disk-sdcard
1920
then
2021
echo "choosing emmc"
2122
target=emmc
22-
elif grep disk-ufs "$rawprogram0"
23+
elif echo "$rootfs_img" | grep -q disk-ufs
2324
then
2425
echo "choosing ufs"
2526
target=ufs

scripts/get-rawprogram-filename.py

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#!/usr/bin/env python3
2+
# Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries.
3+
# SPDX-License-Identifier: BSD-3-Clause
4+
#
5+
# Print the filename attribute of a <program> element by label from a
6+
# rawprogram XML file generated by qcom-ptool.
7+
#
8+
# Usage: get-rawprogram-filename.py <label> <rawprogram0.xml>
9+
#
10+
# Example:
11+
# $ python3 get-rawprogram-filename.py rootfs rawprogram0.xml
12+
# disk-ufs.img2
13+
14+
import sys
15+
import defusedxml.ElementTree as ET
16+
17+
if len(sys.argv) != 3:
18+
print(f"Usage: {sys.argv[0]} <label> <rawprogram0.xml>", file=sys.stderr)
19+
sys.exit(1)
20+
21+
label, xml_file = sys.argv[1], sys.argv[2]
22+
23+
root = ET.parse(xml_file).getroot()
24+
e = root.find(f".//program[@label='{label}']")
25+
if e is None:
26+
print(f"error: no <program label='{label}'> found in {xml_file}",
27+
file=sys.stderr)
28+
sys.exit(1)
29+
30+
filename = e.get("filename")
31+
# Strip any leading ../ path components
32+
while filename.startswith("../"):
33+
filename = filename[3:]
34+
print(filename)

0 commit comments

Comments
 (0)