Skip to content

Commit 903d188

Browse files
scottrfrancisclaude
andcommitted
feat: Add librknnrt.so automatic download using reference project approach
- Modify build script to automatically install SDK and download librknnrt.so after extraction - Add fallback download in package script if librknnrt.so missing from SDK - Update README to reflect automatic librknnrt.so download - Comment librknnrt BitBake recipe as unused (manual approach preferred) - Add librknnrt.so to essential files verification in package script This implementation copies the proven approach from brightsign-npu-gaze-extension which manually downloads the Rockchip runtime library rather than using BitBake. The manual approach is simpler and more reliable for this binary-only library. Fixes missing librknnrt.so that was causing OpenCV DNN import errors. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 10dfd32 commit 903d188

File tree

5 files changed

+56
-5
lines changed

5 files changed

+56
-5
lines changed

.claude/settings.local.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,10 @@
7979
"Bash(./run_yolox_test.sh:*)",
8080
"Bash(./brightsign-x86_64-cobra-toolchain-9.1.52.sh:*)",
8181
"Bash(nm:*)",
82-
"Bash(git stash pop:*)"
82+
"Bash(git stash pop:*)",
83+
"Bash(gh release create:*)",
84+
"Bash(gh auth:*)",
85+
"Bash(git stash push:*)"
8386
],
8487
"deny": []
8588
}

README.md

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Python CV development extension for BrightSign digital signage players (embedded
66

77
__Provides__: Python 3.8, OpenCV, PyTorch, ONNX, RKNN toolkit, scientific computing stack and an extensible Python development environment
88

9-
__Target__: Enterprise edge CV applications (audience analytics, interactive displays, retail analytics)
9+
__Target__: Enterprise edge CV applications (audience analytics, interactive displays, retail analytics)
1010

1111
__Key requirement__: x86_64 development host (Apple Silicon incompatible due to RKNN toolchain)
1212

@@ -62,12 +62,20 @@ __Time__: 60-90 min | __Prerequisites__: Docker, git, x86_64 host, BrightSign pl
6262
# Build extension (30-60 min)
6363
git clone git@github.com:brightsign/python-cv-dev-extension.git
6464
cd python-cv-dev-extension
65+
66+
```
67+
68+
```bash
6569
./setup && ./build --extract-sdk
6670

6771
# Package (5 min)
6872
./brightsign-x86_64-cobra-toolchain-*.sh -d ./sdk -y
6973
./package
7074

75+
```
76+
77+
```bash
78+
7179
# Deploy & validate
7280
# Transfer .zip via DWS, install via SSH, then:
7381
export PLAYER_IP=${PLAYER_IP:-192.168.1.100} # Replace with your player IP
@@ -759,7 +767,7 @@ if [ ! -d "sdk/sysroots/aarch64-oe-linux/usr/lib/python3.8/site-packages/torch"
759767
fi
760768
```
761769

762-
**Note**: The Rockchip RKNN runtime library (`librknnrt.so`) and Python packages are automatically included through BitBake recipes - no manual patching required.
770+
**Note**: The Rockchip RKNN runtime library (`librknnrt.so`) is automatically downloaded during SDK installation. Python packages are included through BitBake recipes.
763771

764772
### Docker Image Management
765773

@@ -832,7 +840,7 @@ python3 -c "import cv2, pandas, torch, numpy; print('Core packages working')"
832840

833841
The extension provides packages through two mechanisms:
834842

835-
**✅ SDK-Built Packages (Always Available)**
843+
__✅ SDK-Built Packages (Always Available)__
836844
These are built into the extension and available immediately after sourcing `setup_python_env`:
837845

838846
```python

bsoe-recipes/meta-bs/recipes-open/librknnrt/librknnrt_2.3.2.bb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
# NOTE: This recipe is currently unused as librknnrt.so is downloaded manually
2+
# during SDK installation (similar to the reference project approach).
3+
# The manual download approach is simpler and more reliable for this binary-only library.
4+
15
SUMMARY = "RKNN Runtime Library for Rockchip NPU"
26
DESCRIPTION = "Runtime library for executing RKNN models on Rockchip NPU hardware"
37
HOMEPAGE = "https://github.com/airockchip/rknn-toolkit2"

build

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,28 @@ if [ $? -eq 0 ]; then
229229
echo "✅ SDK extracted to ${SCRIPT_DIR}/${SDK_BASENAME}"
230230
# Clean up the copy in srv
231231
rm -f "$SDK_FILE"
232+
233+
# Also install and patch SDK if requested
234+
echo "Installing SDK to ./sdk directory..."
235+
if "${SCRIPT_DIR}/${SDK_BASENAME}" -d "${SCRIPT_DIR}/sdk" -y; then
236+
echo "✅ SDK installed to ./sdk"
237+
238+
# Patch SDK with Rockchip libraries (same as reference project)
239+
echo "Adding librknnrt.so to SDK..."
240+
cd "${SCRIPT_DIR}/sdk/sysroots/aarch64-oe-linux/usr/lib"
241+
if [ ! -f "librknnrt.so" ]; then
242+
if wget -q https://github.com/airockchip/rknn-toolkit2/raw/v2.3.2/rknpu2/runtime/Linux/librknn_api/aarch64/librknnrt.so; then
243+
echo "✅ librknnrt.so downloaded to SDK"
244+
else
245+
echo "⚠️ Failed to download librknnrt.so - continuing anyway"
246+
fi
247+
else
248+
echo "✅ librknnrt.so already present in SDK"
249+
fi
250+
cd "${SCRIPT_DIR}"
251+
else
252+
echo "⚠️ SDK installation failed - SDK installer is available for manual installation"
253+
fi
232254
else
233255
echo "❌ SDK file not found in /srv directory"
234256
echo " Expected: ${SCRIPT_DIR}/srv/brightsign-x86_64-*-toolchain-*.sh"

package

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,20 @@ copy_sdk_components() {
160160
cd - > /dev/null
161161
fi
162162

163-
# Copy libraries
163+
# Ensure librknnrt.so is present (fallback if not in SDK)
164+
if [ ! -f "$sdk_sysroot/usr/lib/librknnrt.so" ]; then
165+
warn "librknnrt.so not found in SDK, downloading..."
166+
if wget -q -O "$sdk_sysroot/usr/lib/librknnrt.so" \
167+
https://github.com/airockchip/rknn-toolkit2/raw/v2.3.2/rknpu2/runtime/Linux/librknn_api/aarch64/librknnrt.so; then
168+
success "librknnrt.so downloaded successfully"
169+
else
170+
error "Failed to download librknnrt.so - NPU functionality may not work"
171+
fi
172+
else
173+
log "librknnrt.so found in SDK"
174+
fi
175+
176+
# Copy libraries (including librknnrt.so)
164177
log "Copying libraries (this may take a few minutes)..."
165178
cp -r "$sdk_sysroot/usr/lib" install/usr/
166179

@@ -456,6 +469,7 @@ verify_structure() {
456469
"sh/cleanup-extension"
457470
"sh/setup_python_env"
458471
"usr/bin/python3"
472+
"usr/lib/librknnrt.so"
459473
)
460474

461475
for file in "${essential_files[@]}"; do

0 commit comments

Comments
 (0)