Skip to content
Draft
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
5 changes: 4 additions & 1 deletion Runner/config/pkg_command_map.conf
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,9 @@ centos:pgrep=procps-ng
centos:killall=psmisc
centos:lsmod=kmod
centos:modprobe=kmod
centos:dtc=dtc
centos:fdtdump=dtc
centos:diff=diffutils

# ---------------------------------------------------------------------------
# Common opkg provider mappings.
Expand Down Expand Up @@ -527,7 +530,7 @@ centos:Sensors:ssc_drva_test=qcom-sensors-test-core qcom-sensors-test-apps

debian:package-set:camera-nhx=camx-dkms camx-glymur libcamx-glymur1 camx-firmware-glymur camx-nhx
ubuntu:package-set:camera-nhx=camx-dkms camx-glymur libcamx-glymur1 camx-firmware-glymur camx-nhx
centos:package-set:camera-nhx=camx-dkms camx-firmware-kodiak camx-kodiak libcamx-kodiak1
centos:package-set:camera-nhx=camx-dkms camx-firmware-kodiak camx-kodiak libcamx-kodiak1 dtc diffutils

# Qualcomm Iris video overlay. Debian and Ubuntu use the public DKMS package,
# whose post-install flow builds, registers, and loads iris_vpu. CentOS uses
Expand Down
64 changes: 46 additions & 18 deletions Runner/suites/Multimedia/Camera/Camera_NHX/README_Camera_NHX.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,12 @@ Snapshot JSON files are currently expected only for targets where the files are

2. **Dependency checks**
- Uses `check_dependencies` from `functestlib.sh` to ensure required commands exist.
- Uses `dtc` when available and requires `diff` for checksum comparison.
- The CentOS `--overlay` package set includes `dtc` and `diffutils`, which provide `dtc`, `fdtdump`, and `diff`.

3. **CAMX proprietary prechecks**
- Device-tree presence checks for CAMX/camera patterns, including downstream CAMX-style nodes such as:
- Decodes the active runtime tree with `dtc -I fs -O dts` from the resolved `/sys/firmware/devicetree/base` or `/proc/device-tree` root.
- Uses enabled runtime nodes, rather than text matches in the full DTS, as authoritative CAMX evidence. Downstream CAMX-style nodes include:
- `qcom,cam-sensor`
- `qcom,cam-gmsl-sensor`
- `qcom,cam-gmsl-deserializer`
Expand All @@ -74,7 +77,8 @@ Snapshot JSON files are currently expected only for targets where the files are
- `qcom,csiphy`
- `qcom,cam-tpg1031`
- `qcom,camera`
- `fdtdump` scan for camera-related nodes through `lib_camera.sh`
- Retains line-numbered camera and sensor matches from the decoded DTS for diagnosis. These artifacts can include disabled nodes and are not used alone to declare the CAMX runtime active.
- Uses `fdtdump` only as optional secondary raw-FDT evidence.
- Camera kernel module detection and loaded-state validation, including `camera_x1e80100` on Glymur
- ICP firmware presence check (`CAMERA_ICP`)
- `dmesg` scan for camera warnings/errors
Expand Down Expand Up @@ -110,24 +114,26 @@ Snapshot JSON files are currently expected only for targets where the files are

## Desktop CAMX overlay flow

Yocto and meta-qcom LAVA images keep their image-provided camera stack and do
not use this flow. On Debian and Ubuntu, an explicit overlay request installs
the `camera-nhx` package set:
On Debian and Ubuntu, an explicit overlay request ensures the complete mapped
`camera-nhx` package set:

```text
camx-dkms camx-glymur libcamx-glymur1 camx-firmware-glymur camx-nhx
```

On CentOS Stream 10, the runner follows the Qualcomm overlay installation
guide and installs the Kodiak package set:
On CentOS Stream 10, the runner ensures the complete mapped Kodiak package set:

```text
camx-dkms camx-firmware-kodiak camx-kodiak libcamx-kodiak1
camx-dkms camx-firmware-kodiak camx-kodiak libcamx-kodiak1 dtc diffutils
```

Before a missing CentOS package is installed, the shared package provider
ensures EPEL and both `qualcomm-linux-aarch64` and
`qualcomm-linux-noarch` repositories are enabled, then refreshes DNF metadata.
Ubuntu uses the APT sources already configured in the image. Debian may use the
Qualcomm `qli-staging` source. CentOS prepares EPEL and the Qualcomm Linux
`aarch64` and `noarch` RPM repositories before installation. Yocto does not use
this package-recovery flow and continues with its image-provided camera stack.
The runner passes the complete mapped package list to the shared package
provider instead of selecting a suite-local subset. If package recovery fails,
the explicit `--overlay` request reports FAIL with the complete required list.

`--overlay` requires the CAMX FIT DTB and uses the compatibility name `camx`.
The same requirement can be stated explicitly with `--fit-dtb camx`:
Expand All @@ -153,10 +159,23 @@ reboot
```

If the CAMX FIT DTB is already selected, the test continues with runtime DT and
camera-module checks. A loaded board-specific camera module is used as runtime
evidence that the current boot has activated the CAMX camera stack. If EFI is
set to `camx` but the module is not loaded, the test records SKIP and asks the
operator to reboot manually. The test never issues a reboot itself.
camera-module checks. Qualcomm UEFI uses SoC and board identifiers from CDT to
select a compatible FIT configuration. Linux does not expose the firmware's
raw CDT decision directly, so the test validates its result: EFI selection,
the decoded active runtime tree, enabled downstream CamX nodes, and the loaded
board-specific camera module. This is generic across FIT-enabled Qualcomm SoCs
and does not hardcode a SoC-to-DTB table in the test.

The implementation follows the public Qualcomm FIT metadata flow documented in
[`qcom-dtb-metadata`](https://github.com/qualcomm-linux/qcom-dtb-metadata/blob/main/Documentation.md)
and generated by the public
[`meta-qcom` FIT image class](https://github.com/qualcomm-linux/meta-qcom/blob/master/classes-recipe/dtb-fit-image.bbclass).

If EFI is set to `camx` but the active runtime tree has no enabled downstream
CamX nodes, the test records FAIL because the selected FIT configuration and
the running tree disagree. If the enabled nodes are present but the camera
module is not loaded, the test records SKIP and asks the operator to reboot
manually. The test never issues a reboot itself.

---

Expand Down Expand Up @@ -295,8 +314,9 @@ NHX JSON argument
Options:

```text
--overlay Install the optional Camera NHX CAMX package set on Debian,
Ubuntu, or CentOS and ensure the CAMX FIT DTB is selected.
--overlay Verify the Camera NHX CAMX package set on Debian, Ubuntu,
or CentOS, install missing packages, and ensure the CAMX
FIT DTB is selected.

--fit-dtb NAME Select NAME as the FIT DTB compatibility name for the next
boot. Requires --overlay on a supported desktop distro.
Expand Down Expand Up @@ -342,11 +362,17 @@ Created under the test directory:

- Logs:
- `logs/Camera_NHX_<timestamp>.log`
- `logs/Camera_NHX_dtc_<timestamp>.log`
- `logs/dmesg_<timestamp>/dmesg_snapshot.log`
- `logs/dmesg_<timestamp>/dmesg_errors.log` when matches exist

- Out files:
- `out/Camera_NHX_summary_<timestamp>.txt`
- `out/Camera_NHX_running_<timestamp>.dts`, when `dtc` is available
- `out/Camera_NHX_runtime_camera_<timestamp>.log`, when `dtc` is available
- `out/Camera_NHX_runtime_sensors_<timestamp>.log`, when `dtc` is available
- `out/Camera_NHX_enabled_camx_nodes_<timestamp>.log`
- `out/Camera_NHX_enabled_sensor_nodes_<timestamp>.log`
- Dump list file, usually under `out/nhx_<timestamp>/`
- Checksum file(s), when checksum tool/helper is available

Expand Down Expand Up @@ -463,6 +489,8 @@ run:
### FAIL

- Any PASS condition is not met
- Explicit `--overlay` package recovery fails or leaves the mapped package set incomplete
- EFI selects `camx`, but the active runtime DT has no enabled downstream CamX nodes
- NHX reports one or more failed cases
- Final Report is missing/unparseable
- No dumps are detected
Expand All @@ -475,7 +503,7 @@ run:
- The CAMX FIT DTB selection was written and a manual reboot is required before validation
- EFI selects `camx`, but the board-specific camera module is not loaded, so a manual reboot is required
- `VendorDtbOverlays` is unavailable when `--overlay` was requested
- `fdtdump` is not available or camera node evidence is inconclusive
- No enabled downstream CamX node exists when `camx` was not explicitly selected
- Requested `--json` file is not found
- Requested JSON filename is ambiguous and `--target` was not supplied
- JSON staging under `/etc/camera/test/NHX` fails
Expand Down
168 changes: 126 additions & 42 deletions Runner/suites/Multimedia/Camera/Camera_NHX/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,12 @@ SUMMARY_TXT="$OUT_DIR/${TESTNAME}_summary_${TS}.txt"
DMESG_DIR="$LOG_DIR/dmesg_${TS}"
CAMX_EFI_LOG="$LOG_DIR/${TESTNAME}_camx_efi_${TS}.log"
CAMX_EFI_LIST_LOG="$LOG_DIR/${TESTNAME}_camx_efi_list_${TS}.log"
RUNNING_DTS="$OUT_DIR/${TESTNAME}_running_${TS}.dts"
RUNNING_DTS_WARNINGS="$LOG_DIR/${TESTNAME}_dtc_${TS}.log"
CAMERA_DTS_MATCHES="$OUT_DIR/${TESTNAME}_runtime_camera_${TS}.log"
SENSOR_DTS_MATCHES="$OUT_DIR/${TESTNAME}_runtime_sensors_${TS}.log"
CAMX_DT_NODES_LOG="$OUT_DIR/${TESTNAME}_enabled_camx_nodes_${TS}.log"
SENSOR_DT_NODES_LOG="$OUT_DIR/${TESTNAME}_enabled_sensor_nodes_${TS}.log"

NHX_OUTDIR="$OUT_DIR/nhx_${TS}"

Expand Down Expand Up @@ -110,9 +116,9 @@ usage() {
Usage: $0 [--overlay] [--fit-dtb NAME] [--json JSON_FILE] [--target TARGET] [--help]

Options:
--overlay Install the Camera NHX CAMX package set on supported
Debian, Ubuntu, or CentOS images and ensure the CAMX FIT
DTB is selected for boot.
--overlay Verify the Camera NHX CAMX package set on supported Debian,
Ubuntu, or CentOS images, install missing packages, and
ensure the CAMX FIT DTB is selected for boot.
--fit-dtb NAME Select this FIT DTB compatibility name for the next boot.
Camera_NHX supports camx, which is the --overlay default.
This option requires --overlay.
Expand Down Expand Up @@ -216,6 +222,8 @@ fi
if [ "$OVERLAY_REQUESTED" -eq 1 ]; then
for required_helper in \
pkg_provider_init \
pkg_detect_os_id \
pkg_lookup_package_set \
pkg_ensure_optional_package_set_present \
pkg_verify_package_set_installed; do
if ! command -v "$required_helper" >/dev/null 2>&1; then
Expand All @@ -226,20 +234,40 @@ if [ "$OVERLAY_REQUESTED" -eq 1 ]; then
done

pkg_provider_init
CAMX_OVERLAY_OS_ID="$(pkg_detect_os_id 2>/dev/null || true)"
CAMX_APT_SOURCE="none"

if [ "$CAMX_OVERLAY_OS_ID" = "debian" ]; then
CAMX_APT_SOURCE="qli-staging"
fi

CAMX_PACKAGES="$(pkg_lookup_package_set camera-nhx 2>/dev/null || true)"
if [ -z "$CAMX_PACKAGES" ]; then
log_skip "$TESTNAME SKIP - no Camera NHX package-set mapping is available, os=${CAMX_OVERLAY_OS_ID:-unknown} action=add-a-camera-nhx-package-set-mapping-for-this-os"
echo "$TESTNAME SKIP" >"$RES_FILE"
exit 0
fi

log_info "Ensuring complete Camera NHX package set, os=${CAMX_OVERLAY_OS_ID:-unknown} packages=$CAMX_PACKAGES"

if ! pkg_ensure_optional_package_set_present \
camera-nhx \
qli-staging \
"$CAMX_APT_SOURCE" \
auto \
--overlay; then
log_fail "$TESTNAME FAIL - failed to ensure Camera NHX CAMX package set"
log_fail "$TESTNAME FAIL - --overlay package-set installation failed, os=${CAMX_OVERLAY_OS_ID:-unknown} packages=$CAMX_PACKAGES action=verify-configured-package-repositories-and-package-availability"
echo "$TESTNAME FAIL" >"$RES_FILE"
exit 0
fi

if ! pkg_verify_package_set_installed camera-nhx; then
log_fail "$TESTNAME FAIL - Camera NHX package recovery completed but the required package set is still incomplete, os=${CAMX_OVERLAY_OS_ID:-unknown} packages=$CAMX_PACKAGES"
echo "$TESTNAME FAIL" >"$RES_FILE"
exit 0
fi

log_pass "Camera NHX CAMX package set is ready"

CAMX_OVERLAY_OS_ID="$(pkg_detect_os_id 2>/dev/null || true)"
case "$CAMX_OVERLAY_OS_ID" in
debian|ubuntu|centos)
for required_helper in \
Expand Down Expand Up @@ -300,14 +328,14 @@ if [ "$OVERLAY_REQUESTED" -eq 1 ]; then
;;
esac
else
log_info "Camera NHX overlay package installation not requested"
log_info "Camera NHX overlay package recovery not requested"
fi

# -----------------------------------------------------------------------------
# Deps check
# -----------------------------------------------------------------------------
deps_list="date awk sed grep tee wc ls find stat rm tr head tail dmesg sort fdtdump mkfifo sha256sum md5sum cksum diff cp mkdir"
if ! check_dependencies "$deps_list"; then
deps_list="date awk sed grep tee wc ls find stat rm tr head tail sort mkfifo sha256sum md5sum cksum diff cp mkdir"
if ! CHECK_DEPS_RECOVER=0 check_dependencies "$deps_list"; then
log_skip "$TESTNAME SKIP missing one or more dependencies: $deps_list"
echo "$TESTNAME SKIP" >"$RES_FILE"
exit 0
Expand Down Expand Up @@ -340,51 +368,107 @@ log_info "NHX runner selected, path=$NHX_RUNNER source=$NHX_RUNNER_SOURCE"
# -----------------------------------------------------------------------------
log_info "Checking CAMX proprietary prerequisites before running NHX"

log_info "DT check"

PATTERNS="qcom,cam-sensor qcom,cam-gmsl-sensor qcom,cam-gmsl-deserializer qcom,eeprom qcom,cci qcom,csiphy qcom,cam-tpg1031 qcom,camera qcom,cam camera_kt cam-req-mgr cam-cpas cam-jpeg cam-ife cam-icp camera0-thermal"
found_any=0
missing_list=""
log_info "Decoding the active runtime device tree"

for pat in $PATTERNS; do
out="$(dt_confirm_node_or_compatible "$pat" 2>/dev/null || true)"
if [ -n "$out" ]; then
printf '%s\n' "$out"
found_any=1
else
if [ -n "$missing_list" ]; then
missing_list="$missing_list, $pat"
else
missing_list="$pat"
camx_dump_runtime_dts "$RUNNING_DTS" "$RUNNING_DTS_WARNINGS"
DTC_RC=$?
case "$DTC_RC" in
0)
log_pass "Active runtime DT decoded to $RUNNING_DTS"
if [ -s "$RUNNING_DTS_WARNINGS" ]; then
log_warn "dtc reported non-fatal warnings, retained in $RUNNING_DTS_WARNINGS"
fi
fi
done
;;
2)
: >"$RUNNING_DTS_WARNINGS"
: >"$CAMERA_DTS_MATCHES"
: >"$SENSOR_DTS_MATCHES"
log_warn "dtc is not available in the image, continuing with enabled runtime-node validation"
;;
3)
: >"$RUNNING_DTS_WARNINGS"
: >"$CAMERA_DTS_MATCHES"
: >"$SENSOR_DTS_MATCHES"
log_warn "No readable runtime device-tree root is exposed under procfs or sysfs"
;;
*)
: >"$CAMERA_DTS_MATCHES"
: >"$SENSOR_DTS_MATCHES"
log_warn "Active runtime DT decoding failed, continuing with enabled runtime-node validation, inspect $RUNNING_DTS_WARNINGS"
;;
esac

if [ "$found_any" -ne 1 ]; then
log_skip "$TESTNAME SKIP missing DT patterns $missing_list"
echo "$TESTNAME SKIP" >"$RES_FILE"
exit 0
if [ "$DTC_RC" -eq 0 ]; then
camx_extract_runtime_dts_evidence \
"$RUNNING_DTS" \
"$CAMERA_DTS_MATCHES" \
"$SENSOR_DTS_MATCHES"
fi

RUNTIME_DT_ROOT="$(dt_runtime_root 2>/dev/null || true)"
RUNTIME_DT_MODEL="$(dt_property_text "$RUNTIME_DT_ROOT" model 2>/dev/null || true)"
RUNTIME_DT_COMPATIBLE="$(dt_property_text "$RUNTIME_DT_ROOT" compatible 2>/dev/null || true)"
log_info "Runtime DT model: ${RUNTIME_DT_MODEL:-unavailable}"
log_info "Runtime DT compatible: ${RUNTIME_DT_COMPATIBLE:-unavailable}"
if [ "$DTC_RC" -eq 0 ]; then
log_info "[CAMX-CDT-FIT] efi_camx_selected=$CAMX_FIT_DTB_SELECTED active_dt=$RUNNING_DTS"
log_info "Runtime camera DTS matches retained in $CAMERA_DTS_MATCHES"
log_info "Runtime sensor DTS matches retained in $SENSOR_DTS_MATCHES"
else
log_info "[CAMX-CDT-FIT] efi_camx_selected=$CAMX_FIT_DTB_SELECTED active_dt=unavailable"
fi

log_info "fdtdump camera nodes sample"

FDT_MATCHES="$(camx_fdtdump_has_cam_nodes 2>/dev/null)"
rc=$?
if [ "$rc" -ne 0 ]; then
if [ "$rc" -eq 2 ]; then
log_skip "$TESTNAME SKIP fdtdump not available"
CAMX_DT_NODES="$(camx_list_enabled_runtime_nodes)"
: >"$CAMX_DT_NODES_LOG"
if [ -n "$CAMX_DT_NODES" ]; then
printf '%s\n' "$CAMX_DT_NODES" >"$CAMX_DT_NODES_LOG"
fi
if [ -z "$CAMX_DT_NODES" ]; then
if [ "$CAMX_FIT_DTB_SELECTED" -eq 1 ]; then
log_fail "$TESTNAME FAIL - VendorDtbOverlays selects camx but the active runtime DT has no enabled downstream CamX nodes, verify the CDT-selected FIT configuration and rebooted image"
echo "$TESTNAME FAIL" >"$RES_FILE"
else
log_skip "$TESTNAME SKIP fdtdump did not show conclusive camera nodes"
log_skip "$TESTNAME SKIP - the active runtime DT has no enabled downstream CamX nodes, provision a CAMX-capable FIT configuration selected by CDT"
echo "$TESTNAME SKIP" >"$RES_FILE"
fi
echo "$TESTNAME SKIP" >"$RES_FILE"
exit 0
fi

printf '%s\n' "$FDT_MATCHES" | while IFS= read -r l; do
if [ -n "$l" ]; then
log_info " $l"
printf '%s\n' "$CAMX_DT_NODES" | while IFS= read -r camx_node; do
if [ -n "$camx_node" ]; then
log_info "Enabled CamX DT node: $camx_node"
fi
done
log_pass "Active runtime DT exposes enabled downstream CamX nodes"

SENSOR_DT_NODES="$(camx_list_enabled_sensor_nodes)"
: >"$SENSOR_DT_NODES_LOG"
if [ -n "$SENSOR_DT_NODES" ]; then
printf '%s\n' "$SENSOR_DT_NODES" >"$SENSOR_DT_NODES_LOG"
printf '%s\n' "$SENSOR_DT_NODES" | while IFS= read -r sensor_node; do
if [ -n "$sensor_node" ]; then
log_info "Enabled camera sensor DT node: $sensor_node"
fi
done
else
log_warn "No enabled IMX, OV, AR, CamX sensor, or GMSL sensor nodes were found, NHX execution remains authoritative"
fi

log_info "Checking optional raw FDT camera evidence"

FDT_MATCHES="$(camx_fdtdump_has_cam_nodes 2>/dev/null)"
rc=$?
if [ "$rc" -eq 0 ]; then
printf '%s\n' "$FDT_MATCHES" | while IFS= read -r fdt_match; do
if [ -n "$fdt_match" ]; then
log_info "Raw FDT camera match: $fdt_match"
fi
done
elif [ "$rc" -eq 2 ]; then
log_warn "Optional fdtdump command is unavailable, continuing with enabled runtime-node evidence"
else
log_warn "Optional raw FDT scan did not find camera nodes, continuing with enabled runtime DT evidence"
fi

log_info "driver load checks"

Expand Down
Loading
Loading