Skip to content

Commit 65bb0a2

Browse files
authored
Merge branch 'main' into satish-debug
Signed-off-by: Satish Mhaske <[email protected]>
2 parents 452a1c9 + ca980ea commit 65bb0a2

File tree

6 files changed

+375
-215
lines changed

6 files changed

+375
-215
lines changed

.github/workflows/debos.yml

Lines changed: 38 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,7 @@ defaults:
2424
working-directory: debos-recipes
2525

2626
env:
27-
BUILD_ID: ${{ github.repository }}-${{ github.run_id }}-${{ github.run_attempt }}
28-
FILESERVER_DIR: /efs/qli/metaqcom/gh-runners/quic-yocto/builds
29-
FILESERVER_URL: "https://artifactory-qdc-global.qualcomm.com/artifactory/pdlm-qcomlinux-generic-lv-fed/QualcommLinuxPrd/qualcomm-linux/meta-qcom/${BUILD_ID}"
27+
FILESERVER_URL: https://quic-yocto-fileserver-1029608027416.us-central1.run.app
3028

3129
# cancel in progress builds for this workflow triggered by the same ref
3230
concurrency:
@@ -39,7 +37,8 @@ jobs:
3937
container:
4038
image: debian:trixie
4139
volumes:
42-
- /efs/qli/metaqcom/gh-runners/quic-yocto/builds:/efs/qli/metaqcom/gh-runners/quic-yocto/builds
40+
- /srv/gh-runners/quic-yocto/builds:/fileserver-builds
41+
options: --privileged
4342
steps:
4443
- uses: actions/checkout@v4
4544
with:
@@ -49,35 +48,50 @@ jobs:
4948
# avoid an automated update while we're building
5049
- name: Update OS packages
5150
run: |
52-
set -ex
51+
set -x
5352
apt update
5453
apt -y upgrade
5554
apt -y full-upgrade
56-
apt -y install debos
55+
# debos is needed to build recipes, mtools is needed for the flash
56+
# recipe
57+
apt -y install debos mtools
5758
58-
# create a fresh container build environment to decouple the build
59-
# operating system from the github runner one; install debos
60-
- name: Setup build environment
59+
run: |
60+
set -x
61+
# start by building the root filesystem
62+
debos qualcomm-linux-debian-rootfs.yaml
63+
# debos tries KVM and UML as backends, and falls back to
64+
# building directly on the host, but that requires loop
65+
# devices; use qemu backend explicitly even if it's slower
66+
# qemu backend also requires to set scratchsize, otherwise the
67+
# whole build is done from memory and the out of memory killer
68+
# gets triggered
69+
debos -b qemu --scratchsize 4GiB -t imagetype:ufs \
70+
qualcomm-linux-debian-image.yaml
71+
debos -b qemu --scratchsize 4GiB -t imagetype:sdcard \
72+
qualcomm-linux-debian-image.yaml
73+
# build flashable files
74+
debos qualcomm-linux-debian-flash.yaml
6175
76+
- name: Stage image for publishing
6277
run: |
63-
set -ex
64-
# debos tries KVM and UML as backends, and falls back to building
65-
# directly on the host, but that requires loop devices; use
66-
# qemu backend explicitly even if it's slower
67-
# qemu backend also requires to set scratchsize, otherwise
68-
# the whole build is done from memory and the out of memory
69-
# killer gets triggered
70-
debos -b qemu --scratchsize 4GiB qualcomm-linux-debian.yaml
71-
72-
- name: Stage image for publishing
73-
run: |
74-
set -ex
78+
set -x
79+
# curl will be used to talk to fileserver; should be installed by
80+
# default
81+
apt -y install curl
7582
# github runs are only unique per repository and may also be re-run;
7683
# create an unique id with repository, run id, and run attempt
7784
id="${GITHUB_REPOSITORY}-${GITHUB_RUN_ID}-${GITHUB_RUN_ATTEMPT}"
7885
# create a directory for the current run
79-
dir="${FILESERVER_DIR}/${id}"
86+
dir="/fileserver-builds/${id}"
8087
mkdir -vp "${dir}"
81-
# Files placed under ${dir} will be published internally
82-
cp -v disk.img "${dir}"
88+
# copy output files
89+
cp -av rootfs.tar.gz "${dir}"
90+
cp -av dtbs.tar.gz "${dir}"
91+
cp -av disk-ufs.img.gz "${dir}"
92+
cp -av disk-sdcard.img.gz "${dir}"
93+
tar -cvf "${dir}"/flash.tar.gz disk-ufs.img1 disk-ufs.img2 flash_*
94+
# instruct fileserver to publish this directory
95+
url="${FILESERVER_URL}/${id}/"
96+
curl -X POST -H 'Accept: text/event-stream' "${url}"
8397

README.md

Lines changed: 63 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -13,71 +13,97 @@ main: Primary development branch. Contributors should develop submissions based
1313
## Requirements
1414

1515
[debos](https://github.com/go-debos/debos) is required to build the debos recipes. Recent debos packages should be available in Debian and Ubuntu repositories; there are
16-
[debos installation instructions](https://github.com/go-debos/debos?tab=readme-ov-file#installation-from-source-under-debian) on the project's page, notably for Docker images and to build debos from source.
16+
[debos installation instructions](https://github.com/go-debos/debos?tab=readme-ov-file#installation-from-source-under-debian) on the project's page, notably for Docker images and to build debos from source. Make sure to use at least version 1.1.5 which supports setting the sector size.
1717

18-
[qdl](https://github.com/linux-msm/qdl) is typically used for flashing. While recent versions are available in Debian and Ubuntu, make sure you have at least version 2.1 as it contains important fixes.
18+
[qdl](https://github.com/linux-msm/qdl) is typically used for flashing. While recent versions are available in Debian and Ubuntu, make sure to use at least version 2.1 as it contains important fixes.
1919

2020
## Usage
2121

22-
To build a disk image, run debos as follows:
22+
To build flashable assets, run debos as follows:
2323
```bash
24-
debos debos-recipes/qualcomm-linux-debian.yaml
24+
# build tarballs of the root filesystem and DTBs
25+
debos debos-recipes/qualcomm-linux-debian-rootfs.yaml
26+
27+
# build disk and filesystem images from the root filesystem; the default is to
28+
# build an UFS image
29+
debos debos-recipes/qualcomm-linux-debian-image.yaml
30+
31+
# build flashable assets from the DTBs and UFS filesystem images; currently these
32+
# are only built for the RB3 Gen2 Vision Kit board
33+
debos debos-recipes/qualcomm-linux-debian-flash.yaml
2534
```
2635

27-
### Build backends
36+
### Debos tips
2837

29-
By default, debos will try to pick a fast build backend; it will try to use its KVM backend ("-b kvm") when available, and otherwise an UML environment ("-b uml"). If none of these work, a solid backend is QEMU ("-b qemu"). Because the target images are arm64, this can be really slow, especially when building from another architecture such as amd64.
38+
By default, debos will try to pick a fast build backend; it will try to use its KVM backend ("-b kvm") when available, and otherwise an UML environment ("-b uml"). If none of these work, a solid backend is QEMU ("-b qemu"); because the target images are arm64, this can be really slow when building from another architecture such as amd64.
3039

3140
To build large images, the debos resource defaults might not be sufficient. Consider raising the default debos memory and scratchsize settings. This should provide a good set of minimum defaults:
3241
```bash
33-
debos --fakemachine-backend qemu --memory 1GiB --scratchsize 4GiB debos-recipes/qualcomm-linux-debian.yaml
42+
debos --fakemachine-backend qemu --memory 1GiB --scratchsize 4GiB debos-recipes/qualcomm-linux-debian-image.yaml
3443
```
3544

3645
### Build options
3746

38-
A few options are provided in the debos recipe:
39-
- image: set the output disk image filename; default: `disk.img`
40-
- imagesize: set the output disk image size; default: `4GiB`
41-
- dtb: override the firmware provided device tree with one from the linux kernel, e.g. `qcom/qcs6490-rb3gen2.dtb`; default: don't override
42-
- xfcedesktop: install a Xfce desktop environment; default: console only environment
47+
A few options are provided in the debos recipes; for the root filesystem recipe:
4348
- experimentalkernel: update the linux kernel to the version from experimental; default: don't update the kernel
49+
- xfcedesktop: install a Xfce desktop environment; default: console only environment
50+
51+
For the image recipe:
52+
- dtb: override the firmware provided device tree with one from the linux kernel, e.g. `qcom/qcs6490-rb3gen2.dtb`; default: don't override
53+
- imagetype: either `ufs` (the default) or (`sdcard`); UFS images are named disk-ufs.img and use 4096 bytes sectors and SD card images are named disk-sdcard.img and use 512 bytes sectors
54+
- imagesize: set the output disk image size; default: `4GiB`
4455

45-
These can be passed as follows:
56+
Here are some example invocations:
4657
```bash
47-
debos -t dtb:qcom/qcs6490-rb3gen2.dtb -t xfcedesktop:true -t experimentalkernel:true debos-recipes/qualcomm-linux-debian.yaml
58+
# build the root filesystem with Xfce and a kernel from experimental
59+
debos -t xfcedesktop:true -t experimentalkernel:true debos-recipes/qualcomm-linux-debian-rootfs.yaml
60+
61+
# build an image where systemd overrides the firmware device tree with the one
62+
# for RB3 Gen2
63+
debos -t dtb:qcom/qcs6490-rb3gen2.dtb debos-recipes/qualcomm-linux-debian-image.yaml
64+
65+
# build an SD card image
66+
debos -t imagetype:sdcard debos-recipes/qualcomm-linux-debian-image.yaml
4867
```
4968

5069
## Flashing Instructions
5170
### Overview
5271

53-
Once a disk image is created, it is suitable for putting on an SD card, albeit most Qualcomm boards boot from internal storage by default. The disk image can also be flashed on the internal storage of your board with [qdl](https://github.com/linux-msm/qdl).
72+
The `disk-sdcard.img` disk image can simply be written to a SD card, albeit most Qualcomm boards boot from internal storage by default. With an SD card, the board will use boot firmware from internal storage (eMMC or UFS) and do an EFI boot from the SD card if the firmware can't boot from internal storage.
5473

55-
These images don't currently ambition to provide early boot assets such as boot firmware or data for other partitions containing board specific configuration or coprocessor firmware. Instead, start by provisioning an image with these early boot assets, such as the Yocto-based Qualcomm Linux images, and then flashing a debos generated image on top. Standalone, ready to flash (but probably not Debian based) images of the boot assets are planned to be made available publicly – stay tuned!
74+
If there is no need to update the boot firmware, the `disk-ufs.img` disk image can also be flashed on the first LUN of the internal UFS storage with [qdl](https://github.com/linux-msm/qdl). Create a `rawprogram-ufs.xml` file as follows:
75+
```xml
76+
<?xml version="1.0" ?>
77+
<data>
78+
<program SECTOR_SIZE_IN_BYTES="4096" file_sector_offset="0" filename="disk-ufs.img" label="image" num_partition_sectors="0" partofsingleimage="false" physical_partition_number="0" start_sector="0"/>
79+
</data>
80+
```
81+
Put the board in "emergency download mode" (EDL; see next section) and run:
82+
```bash
83+
qdl --storage ufs prog_firehose_ddr.elf rawprogram-ufs.xml
84+
```
85+
Make sure to use `prog_firehose_ddr.elf` for the target platform, such as this [version from the QCM6490 boot binaries](https://softwarecenter.qualcomm.com/download/software/chip/qualcomm_linux-spf-1-0/qualcomm-linux-spf-1-0_test_device_public/r1.0_00058.0/qcm6490-le-1-0/common/build/ufs/bin/QCM6490_bootbinaries.zip).
5686

57-
Depending on the target board and target boot media, it's also necessary to use the right sector size for the image: typically 512B vs 4096B. SD cards and eMMC typically use the historical 512B sector size, while UFS storage uses 4096B sector size. debos has just gained support for configurable sector sizes, but that requires building it from source; alernatively, you can post-process the image with a conversation script as explained below.
87+
To flash a complete set of assets on UFS internal storage, put the board in EDL mode and run:
88+
```bash
89+
# use the RB3 Gen2 Vision Kit flashable assets
90+
cd flash_rb3gen2-vision-kit
91+
qdl --storage ufs prog_firehose_ddr.elf rawprogram[0-9].xml patch[0-9].xml
92+
```
5893

59-
### RB3 Gen2 instructions
94+
### Emergency Download Mode (EDL)
6095

61-
The RB3 Gen2 board boots from UFS by default. To flash a disk image to the UFS storage of the RB3 Gen2 board:
62-
1. provision some known good early boot assets by flashing the Yocto edition of [Qualcomm Linux](https://www.qualcomm.com/developer/software/qualcomm-linux)
63-
1. unless you've got a recent debos that supports creating images with a 4096B sector size, convert the debos disk image from 512B to 4096B sector sizes; this sample script can be used as a workaround until [debos gains support for setting the sector size](https://github.com/go-debos/debos/issues/537) but it's a britle approach which requires root, the workaround script is also full of hardcoded expectations and might need local tweaks:
64-
```bash
65-
sudo scripts/workaround-convert-sector-size disk.img disk-4096.img 4096
66-
```
67-
1. create a `rawprogram-ufs.xml` file instructing QDL to flash to the first UFS LUN (LUN0):
68-
```xml
69-
<?xml version="1.0" ?>
70-
<data>
71-
<program SECTOR_SIZE_IN_BYTES="4096" file_sector_offset="0" filename="disk-4096.img" label="image" num_partition_sectors="0" partofsingleimage="false" physical_partition_number="0" start_sector="0"/>
72-
</data>
73-
```
74-
1. put the board in "emergency download" mode (EDL) by removing any cable from the USB type-C port, and pressing the `F_DL` button while turning the power on
96+
In EDL mode, the board will receive a flashing program over its USB type-C cable, and that program will receive data to flash on the internal storage. This is a lower level mode than fastboot which is implemented by a higher-level bootloader.
97+
98+
To enter EDL mode:
99+
1. remove power to the board
100+
1. remove any cable from the USB type-C port
101+
1. on some boards, it's necessary to set some DIP switches
102+
1. press the `F_DL` button while turning the power on
75103
1. connect a cable from the flashing host to the USB type-C port on the board
76-
1. run qdl to flash the image:
77-
```bash
78-
qdl prog_firehose_ddr.elf rawprogram-ufs.xml
79-
```
80-
The `prog_firehose_ddr.elf` payload is part of the the Yocto Qualcomm Linux image download.
104+
1. run qdl to flash the board
105+
106+
NB: It's also possible to run qdl from the host while the baord is not connected, and starting the board directly in EDL mode.
81107

82108
## Development
83109

Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
architecture: arm64
2+
3+
actions:
4+
- action: download
5+
description: Download qcom-ptool
6+
url: https://github.com/qualcomm-linux/qcom-ptool/archive/refs/heads/main.tar.gz
7+
name: qcom-ptool
8+
filename: qcom-ptool.tar.gz
9+
unpack: true
10+
11+
- action: download
12+
description: Download QCM6490 boot binaries
13+
url: https://softwarecenter.qualcomm.com/download/software/chip/qualcomm_linux-spf-1-0/qualcomm-linux-spf-1-0_test_device_public/r1.0_00058.0/qcm6490-le-1-0/common/build/ufs/bin/QCM6490_bootbinaries.zip
14+
name: qcm6490_boot-binaries
15+
filename: qcm6490_boot-binaries.zip
16+
17+
- action: download
18+
description: Download RB3 Gen2 Vision Kit CDT
19+
url: https://artifacts.codelinaro.org/artifactory/codelinaro-le/Qualcomm_Linux/QCS6490/cdt/rb3gen2-vision-kit.zip
20+
name: rb3gen2-vision-kit_cdt
21+
filename: rb3gen2-vision-kit_cdt.zip
22+
23+
- action: run
24+
description: Generate flash directories for UFS boards
25+
chroot: false
26+
command: |
27+
set -eux
28+
# work dir that will be thrown away
29+
mkdir -v build
30+
31+
# path to unpacked qcom-ptool tarball
32+
QCOM_PTOOL="${ROOTDIR}/../qcom-ptool.tar.gz.d/qcom-ptool-main"
33+
34+
## platform: QCM6490
35+
# unpack boot binaries
36+
unzip -j "${ROOTDIR}/../qcm6490_boot-binaries.zip" \
37+
-d build/qcm6490_boot-binaries
38+
# generate partition files
39+
mkdir -v build/qcm6490_partitions
40+
(
41+
cd build/qcm6490_partitions
42+
conf="${QCOM_PTOOL}/platforms/qcm6490/partitions.conf"
43+
"${QCOM_PTOOL}/gen_partition.py" -i "$conf" \
44+
-o ptool-partitions.xml
45+
# partitions.conf sets --type=emmc, nand or ufs
46+
if grep -F '^--disk --type=ufs ' "${conf}"; then
47+
touch flash-ufs
48+
fi
49+
"${QCOM_PTOOL}/ptool.py" -x ptool-partitions.xml
50+
)
51+
52+
### board: RB3Gen2 Vision Kit
53+
flash_dir="${ARTIFACTDIR}/flash_rb3gen2-vision-kit"
54+
rm -rf "${flash_dir}"
55+
mkdir -v "${flash_dir}"
56+
# copy platform partition files
57+
cp --preserve=mode,timestamps -v build/qcm6490_partitions/* \
58+
"${flash_dir}"
59+
# copy platform boot binaries; these shouldn't ship partition files, but
60+
# make sure not to accidentally clobber any such file
61+
find build/qcm6490_boot-binaries \
62+
-not -name 'gpt_*' \
63+
-not -name 'patch*.xml' \
64+
-not -name 'rawprogram*.xml' \
65+
-not -name 'wipe*.xml' \
66+
-not -name 'zeros_*' \
67+
\( \
68+
-name Qualcomm-Technologies-Inc.-Proprietary \
69+
-or -name 'prog_*' \
70+
-or -name '*.bin' \
71+
-or -name '*.elf' \
72+
-or -name '*.fv' \
73+
-or -name '*.mbn' \
74+
\) \
75+
-exec cp --preserve=mode,timestamps -v '{}' "${flash_dir}" \;
76+
# unpack board CDT
77+
unzip -j "${ROOTDIR}/../rb3gen2-vision-kit_cdt.zip" \
78+
-d build/rb3gen2-vision-kit_cdt
79+
# copy just the CDT data; no partition or flashing files
80+
cp --preserve=mode,timestamps -v build/rb3gen2-vision-kit_cdt/cdt_vision_kit.bin \
81+
"${flash_dir}"
82+
83+
# update flashing files for CDT
84+
sed -i '/label="cdt"/s/filename=""/filename="cdt_vision_kit.bin"/' \
85+
"${flash_dir}"/rawprogram*.xml
86+
87+
# generate a dtb.bin FAT partition with just a single dtb for the current
88+
# board; long-term this should really be a set of dtbs and overlays as to
89+
# share dtb.bin across boards
90+
dtb_bin="${flash_dir}/dtb.bin"
91+
rm -f "${dtb_bin}"
92+
# dtb.bin is only used in UFS based boards at the moment and UFS uses a
93+
# 4k sector size, so pass -S 4096
94+
# in qcom-ptool/platforms/*/partitions.conf, dtb_a and _b partitions
95+
# are provisioned with 64MiB; create a 4MiB FAT that will comfortably fit
96+
# in these and hold the target device tree, which is 4096 KiB sized
97+
# blocks for mkfs.vfat's last argument
98+
mkfs.vfat -S 4096 -C "${dtb_bin}" 4096
99+
# RB3 Gen2 Vision Kit will probably have a more specific DTB (see
100+
# <[email protected]> on lore.kernel.org)
101+
# but for now use the core kit one
102+
dtb="qcom/qcs6490-rb3gen2.dtb"
103+
# extract board device tree from the root filesystem provided tarball
104+
tar -C build -xvf "${ARTIFACTDIR}/dtbs.tar.gz" "${dtb}"
105+
# copy into the FAT as combined-dtb.dtb
106+
mcopy -vmp -i "${dtb_bin}" "build/${dtb}" ::/combined-dtb.dtb
107+
108+
# (NB: flashing files already expect "dtb.bin" as a filename)
109+
110+
# update flashing files for ESP image;
111+
# qcom-ptool/platforms/*/partitions.conf uses filename=efi.bin for the
112+
# ESP partition on EFI capable platforms
113+
sed -i '/label="efi"/s#filename="[^"]*"#filename="../disk-ufs.img1"#' \
114+
"${flash_dir}"/rawprogram*.xml
115+
116+
# update flashing files for rootfs image;
117+
# qcom-ptool/platforms/*/partitions.conf uses filename=rootfs.img for the
118+
# rootfs partition
119+
sed -i \
120+
'/label="rootfs"/s#filename="[^"]*"#filename="../disk-ufs.img2"#' \
121+
"${flash_dir}"/rawprogram*.xml
122+
123+
# cleanup
124+
rm -rf build
125+

0 commit comments

Comments
 (0)