Skip to content

Commit 1873819

Browse files
committed
Add gdsp_remoteproc test script and README for Lemans platform
This commit introduces a test script to validate gpdsp0 and gpdsp1 remoteproc functionality on the Lemans platform. It includes start/stop/restart checks and logs results in a standardized format. A detailed README is also added to document usage, expected output, and prerequisites. Signed-off-by: Sai-teja573 <122cs0573@nitrkl.ac.in>
1 parent a7d3701 commit 1873819

File tree

3 files changed

+193
-0
lines changed

3 files changed

+193
-0
lines changed
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
# gdsp_remoteproc Test
2+
3+
© Qualcomm Technologies, Inc. and/or its subsidiaries.
4+
SPDX-License-Identifier: BSD-3-Clause-Clear
5+
6+
## Overview
7+
8+
This test case validates the functionality of the **GPDSP (General Purpose DSP)** firmware loading and control on the **Lemans** platform. It specifically targets:
9+
10+
- `gpdsp0`
11+
- `gpdsp1`
12+
13+
The script ensures that each GPDSP remote processor:
14+
- Is currently running
15+
- Can be stopped successfully
16+
- Can be restarted and returns to the running state
17+
18+
This is essential for verifying the stability and control of DSP subsystems on Qualcomm-based platforms.
19+
20+
## Usage
21+
22+
### Instructions
23+
24+
1. **Transfer the Script**: Use `scp` or any file transfer method to copy the script to the Lemans target device.
25+
2. **Navigate to the Script Directory**: SSH into the device and go to the directory where the script is located.
26+
3. **Run the Script**:
27+
```sh
28+
./run.sh
29+
```
30+
---
31+
#### Quick Example
32+
```
33+
git clone <this-repo>
34+
cd <this-repo>
35+
scp -r common Runner user@target_device_ip:<Path in device>
36+
ssh user@target_device_ip
37+
cd <Path in device>/Runner && ./run-test.sh gdsp_remoteproc
38+
```
39+
---
40+
## Prerequisites
41+
1. The device must expose `/sys/class/remoteproc/remoteproc*/firmware and /state` interfaces.
42+
2. Root access may be required to write to remoteproc state files.
43+
3. The firmware names must include gpdsp0 and gpdsp1.
44+
---
45+
## Result Format
46+
Test result will be saved in `gdsp_remoteproc.res` as:
47+
## Output
48+
A .res file is generated in the same directory:
49+
50+
`gdsp_remoteproc PASS` OR `gdsp_remoteproc FAIL`
51+
52+
## Sample Log
53+
```
54+
Output
55+
56+
[INFO] 1970-01-01 03:56:11 - ------------------------------------------------------------------------------
57+
[INFO] 1970-01-01 03:56:11 - -------------------Starting gdsp_remoteproc Testcase----------------------------
58+
[INFO] 1970-01-01 03:56:11 - === Test Initialization ===
59+
[INFO] 1970-01-01 03:56:11 - Found gpdsp0 at /sys/class/remoteproc/remoteproc3
60+
[PASS] 1970-01-01 03:56:11 - gpdsp0 stop successful
61+
[INFO] 1970-01-01 03:56:11 - Restarting gpdsp0
62+
[PASS] 1970-01-01 03:56:12 - gpdsp0 PASS
63+
[INFO] 1970-01-01 03:56:12 - Found gpdsp1 at /sys/class/remoteproc/remoteproc4
64+
[PASS] 1970-01-01 03:56:12 - gpdsp1 stop successful
65+
[INFO] 1970-01-01 03:56:12 - Restarting gpdsp1
66+
[PASS] 1970-01-01 03:56:12 - gpdsp1 PASS
67+
[INFO] 1970-01-01 03:56:12 - -------------------Completed gdsp_remoteproc Testcase----------------------------
68+
```
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
#!/bin/sh
2+
3+
# Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries.
4+
# SPDX-License-Identifier: BSD-3-Clause-Clear
5+
6+
# Robustly find and source init_env
7+
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
8+
INIT_ENV=""
9+
SEARCH="$SCRIPT_DIR"
10+
while [ "$SEARCH" != "/" ]; do
11+
if [ -f "$SEARCH/init_env" ]; then
12+
INIT_ENV="$SEARCH/init_env"
13+
break
14+
fi
15+
SEARCH=$(dirname "$SEARCH")
16+
done
17+
18+
if [ -z "$INIT_ENV" ]; then
19+
echo "[ERROR] Could not find init_env (starting at $SCRIPT_DIR)" >&2
20+
exit 1
21+
fi
22+
23+
if [ -z "$__INIT_ENV_LOADED" ]; then
24+
# shellcheck disable=SC1090
25+
. "$INIT_ENV"
26+
fi
27+
# shellcheck disable=SC1090,SC1091
28+
. "$TOOLS/functestlib.sh"
29+
30+
TESTNAME="gdsp_remoteproc"
31+
test_path=$(find_test_case_by_name "$TESTNAME")
32+
cd "$test_path" || exit 1
33+
res_file="./$TESTNAME.res"
34+
35+
log_info "-----------------------------------------------------------------------------------------"
36+
log_info "-------------------Starting $TESTNAME Testcase----------------------------"
37+
log_info "=== Test Initialization ==="
38+
39+
for gdsp_firmware in gpdsp0 gpdsp1; do
40+
log_info "Processing $gdsp_firmware"
41+
rproc_path=$(get_remoteproc_path_by_firmware "$gdsp_firmware")
42+
if [ -z "$rproc_path" ]; then
43+
log_fail "$gdsp_firmware remoteproc path not found"
44+
echo "$TESTNAME FAIL" > "$res_file"
45+
exit 1
46+
fi
47+
48+
log_info "Found $gdsp_firmware remoteproc at $rproc_path"
49+
50+
state=$(get_remoteproc_state "$rproc_path")
51+
if [ "$state" != "running" ]; then
52+
log_fail "$gdsp_firmware not running initially"
53+
echo "$TESTNAME FAIL" > "$res_file"
54+
exit 1
55+
fi
56+
57+
if ! stop_remoteproc "$rproc_path"; then
58+
log_fail "$gdsp_firmware stop failed"
59+
echo "$TESTNAME FAIL" > "$res_file"
60+
exit 1
61+
else
62+
log_pass "$gdsp_firmware stop successful"
63+
fi
64+
65+
log_info "Restarting $gdsp_firmware"
66+
if ! start_remoteproc "$rproc_path"; then
67+
log_fail "$gdsp_firmware start failed"
68+
echo "$TESTNAME FAIL" > "$res_file"
69+
exit 1
70+
fi
71+
72+
log_pass "$gdsp_firmware PASS"
73+
done
74+
75+
echo "$TESTNAME PASS" > "$res_file"
76+
log_info "-------------------Completed $TESTNAME Testcase----------------------------"
77+
exit 0

Runner/utils/functestlib.sh

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -391,3 +391,51 @@ weston_start() {
391391
fi
392392
}
393393

394+
# Find the remoteproc path for a given firmware substring (e.g., "adsp", "cdsp", "gdsp").
395+
get_remoteproc_path_by_firmware() {
396+
name="$1"
397+
local idx path
398+
# List all remoteproc firmware nodes, match name, and return the remoteproc path
399+
idx=$(cat /sys/class/remoteproc/remoteproc*/firmware 2>/dev/null | grep -n "$name" | cut -d: -f1 | head -n1)
400+
[ -z "$idx" ] && return 1
401+
idx=$((idx - 1))
402+
path="/sys/class/remoteproc/remoteproc${idx}"
403+
[ -d "$path" ] && echo "$path" && return 0
404+
return 1
405+
}
406+
407+
# Get current remoteproc state
408+
get_remoteproc_state() {
409+
rproc_path="$1"
410+
[ -f "$rproc_path/state" ] && cat "$rproc_path/state"
411+
}
412+
413+
# Wait until remoteproc reaches a given state (with retries)
414+
wait_remoteproc_state() {
415+
rproc_path="$1"
416+
target="$2"
417+
retries="${3:-6}"
418+
i=0
419+
while [ $i -lt "$retries" ]; do
420+
state=$(get_remoteproc_state "$rproc_path")
421+
[ "$state" = "$target" ] && return 0
422+
sleep 1
423+
i=$((i+1))
424+
done
425+
return 1
426+
}
427+
428+
# Stop remoteproc (wait for "offline")
429+
stop_remoteproc() {
430+
rproc_path="$1"
431+
echo stop > "$rproc_path/state"
432+
wait_remoteproc_state "$rproc_path" "offline" 6
433+
}
434+
435+
# Start remoteproc (wait for "running")
436+
start_remoteproc() {
437+
rproc_path="$1"
438+
echo start > "$rproc_path/state"
439+
wait_remoteproc_state "$rproc_path" "running" 6
440+
}
441+

0 commit comments

Comments
 (0)