Skip to main content

SDK Related - FAQ

Navigation bar

Current SDK Information​

This is a YOLOv5 object detection stream processing project based on Rockchip RV1126B.

By looking at the project structure and key files, the following information can be obtained:

Warning

CAM126 / CAM126B-P note the difference

Go to CAM126 SDK | Go to CAM126B-P SDK


📁 RV1126BP SDK Linux V1.1.0 updated version V1.2.1​

Information

New version V1.2.1 with some updated drivers is already provided; you can choose to download it.

Link: https://pan.baidu.com/s/1Br7GJm_1y5o274LQgSFmJw?pwd=fanc

Extraction code: fanc


Build Method Reference​

Compile CAM126B-P Firmware


📋 Project Summary​

ItemContent
Project typeRockchip RV1126B platform embedded development + AI vision (YOLOv5)
Core chipRV1126B (Rockchip's AIoT SoC with NPU)
AI modelYOLOv5 (object detection)
OS / build systemBuildroot, Debian, Ubuntu, Yocto (multi-OS support)
Key filesMakefile, build.sh, kernel, rkflash.sh, RV1126B_YOLOV5_STREAM_PLAN.md

📁 Main Directory Structure Description​

DirectoryPurpose
app/Application code (may include YOLOv5 inference, video stream processing, etc.)
buildroot/Buildroot build system configuration
debian/, ubuntu/, yocto/Root filesystems for different Linux distributions
device/Device tree, board-level configuration
docs/Project documentation
external/Third-party dependency libraries
hal/Hardware abstraction layer (Rockchip HAL)
kernel-6.1/Linux kernel source (version 6.1)
prebuilts/Prebuilt toolchain / binaries
rkbin/Rockchip firmware / binaries (BL31, DDR init, etc.)
rtos/Real-time OS components (RV1126B usually has an MCU core)
tools/Tool scripts
u-boot/U-Boot boot loader

🔍 Key File Notes​

  • RV1126B_YOLOV5_STREAM_PLAN.md — probably the core description / plan document of this project; it is recommended to read this file first to understand the project goals.
  • build.sh — main build script.
  • rkflash.sh — flashing script (flashes firmware to the RV1126B board).
  • kernel — probably a symbolic link to kernel-6.1.

Common Code Locations​

RV1126BP SDK Linux V1.1.0​

Usually choose the current standard SDK

Streaming function is already provided

Link: https://pan.baidu.com/s/1Br7GJm_1y5o274LQgSFmJw?pwd=fanc Extraction code: fanc

IPC Source Code​

LocationPurpose
app/rkipc/src/rv1126b_ipc/RV1126B IPC main program (main.c, video/, resolution ini)
app/rkipc/common/Common modules (encoding, network, OSD, storage, ISP, etc.)
external/Underlying dependencies (camera_engine_rkaiq, mpp, etc.)
buildroot/configs/rockchip_rv1126b_ipc_defconfigIPC product defconfig
buildroot/board/rockchip/rv1126b/fs-overlay-ipc/Startup scripts and other overlays

How to modify:

  • Business logic → rv1126b_ipc/ + common/
  • Resolution / stream parameters → rkipc-*.ini
  • Boot startup → fs-overlay-ipc/etc/init.d/S99rkipc → RkLunch-buildroot.sh
  • After modification, in the SDK root: ./build.sh (or rebuild the rkipc package separately)

WEB Frontend​

LocationPurpose
app/ipcweb-backend/www-rkipc/Frontend static pages (Angular build output, .js.gz / .css.gz)
app/ipcweb-backend/src/Web backend API (*_api.cpp, rest_api.cpp)
app/ipcweb-backend/ipcweb-env-*/etc4oem/nginx/Nginx configuration

Deployment path on the device: /usr/www (installed by buildroot's ipcweb-backend.mk).

How to modify:

  • Change pages / UI: the SDK only contains the compiled www-rkipc, no Angular source; you need to request the frontend project from Rockchip, or can only directly modify static resources (hard to maintain)
  • Change API / functions: modify ipcweb-backend/src/*_api.cpp; the backend communicates with rkipc via socket
  • After modification, rebuild the ipcweb-backend package and flash

Relationship: Browser → Nginx → entry.cgi (ipcweb-backend) → socket → rkipc


IVA Human / Face​

  1. Algorithm library (closed source, can only call API)
PathContent
external/iva/librockiva/rockiva-rv1126b-Linux/include/API header files
rockiva_common.hType definitions: ROCKIVA_OBJECT_TYPE_PERSON / FACE
rockiva_det_api.hObject detection
rockiva_ba_api.hBehavior analysis (regional intrusion, etc.)
rockiva_face_api.hFace recognition / comparison (currently not used by rkipc)
external/iva/librockiva/.../lib*.soPrebuilt libraries
external/iva/models/rockiva_data_rv1126b/Models (iva_object_detection_*.data)
  1. Application layer (source modifiable; RV1126B IPC is mainly here)
PathPurpose
app/rkipc/common/rockiva/rockiva.cInitialization, model selection, detection type configuration (human + face)
app/rkipc/src/rv1126b_ipc/video/video.cSend frames to IVA, draw human / face boxes
app/rkipc/src/rv1126b_ipc/rkipc-*.ini[event.regional_invasion] parameters
external/samples/example/common/sample_comm_iva.cOfficial sample

Web-side regional intrusion configuration: app/ipcweb-backend/src/event_api.cpp


  1. How the current IPC uses human / face

rkipc uses BA (behavior analysis) + detection, not a separate face recognition module:

  • rockiva_model_type = big → ROCKIVA_DET_MODEL_CLS8 (includes human, face, car, etc.)
  • small/medium → ROCKIVA_DET_MODEL_PFP (human, face, pet)
  • Enabled at the same time in the rule:
	initParams.baRules.areaInBreakRule[0].objType =
ROCKIVA_OBJECT_TYPE_BITMASK(ROCKIVA_OBJECT_TYPE_PERSON);
initParams.baRules.areaInBreakRule[0].objType |=
ROCKIVA_OBJECT_TYPE_BITMASK(ROCKIVA_OBJECT_TYPE_FACE);

Boxes are drawn in video.c: one color for human, another for face.


  1. How it should be modified
RequirementWhere to modify
Switch / sensitivity / detection region[event.regional_invasion] in rkipc-*.ini
Model size (accuracy / performance)rockiva_model_type (big/small/medium) in ini
Only detect human, not faceRemove the ROCKIVA_OBJECT_TYPE_FACE bitmask in rockiva.c
Change box color / styleROCKIVA_OBJECT_TYPE_PERSON/FACE branches in rv1126b_ipc/video/video.c
Change algorithm thresholds / rule logicsense, minObjSize, alertTime, etc. in rockiva.c
Face recognition / comparison (1:N)You need to integrate rockiva_face_api.h yourself (ROCKIVA_FACE_Init, etc.); not integrated in current rkipc
Change the detection model itselfYou can only replace the .data under models/ or request a new library from Rockchip; no source

After modification, rebuild the rkipc and iva packages and flash. Models are installed to /usr/lib/ on the device (consistent with rockiva_model_path in the ini).

Two Distortion Correction Methods​

There is lens distortion correction related code.
RV1126B-P uses the same software as RV1126B (the rv1126bp_ipc defconfig's RK_BUILDROOT_BASE_CFG="rv1126b_ipc"); the distortion correction logic is shared.

ModeDescriptionHardware / module
LDCHHorizontal lens distortion correction (lightweight)ISP / RKAIQ
FECDistortion correction based on calibration files (fisheye / high-distortion lenses)GDC + calibration ini

Both default to close.


Code Locations​

Application layer (mainly modify here)

FilePurpose
app/rkipc/common/isp/rv1126b/isp.crk_isp_set_distortion_correction(), rk_isp_set_ldch_level(), rk_isp_set_fec_level()
app/rkipc/src/rv1126b_ipc/video/video.cCreate GDC channel for FEC, load fec_ini_file
app/rkipc/src/rv1126b_ipc/rkipc-*.iniConfiguration items
app/ipcweb-backend/src/image_api.cppWeb setting of distortion parameters

Underlying algorithm / driver

PathPurpose
external/camera_engine_rkaiq/rkaiq/include/uAPI2/rk_aiq_uapi1_rv1126b.hrk_aiq_uapi_setLdchEn, setLdchCorrectLevel, setFecEn, etc.
external/camera_engine_rkaiq/IspFec/fec_calib/*.iniLens calibration files (installed to /usr/share/fec_calib/)
external/camera_engine_rkaiq/rkaiq/algos/afec/FEC algorithm
kernel-6.1/drivers/media/platform/rockchip/fec/FEC kernel driver

Documentation

  • app/rkipc/docs/Rockchip_Developer_Guide_Linux_RKIPC_CN.md (RV1126B IPC data flow, FEC/LDCH description)

Usage​

1. Modify ini (most direct)​

In [isp.0.enhancement] of app/rkipc/src/rv1126b_ipc/rkipc-xxx-buildroot.ini:

distortion_correction = LDCH   ; or FEC / close
ldch_level = 50 ; 0~100, only valid for LDCH
fec_level = 50 ; 0~100, only valid for FEC
fec_ini_file = /usr/share/fec_calib/sc450ai_CRK4F4209_ldc.ini ; required for FEC

Existing calibration file examples:

  • sc450ai_CRK4F4209_ldc.ini
  • sc850sl_CMK-OT2115-PC1_ldc.ini
  • imx415_CMK-OT1948-PV1_ldc.ini
  • sc200ai_CRK2F3537-V2_ldc.ini

2. Web Page​

Image enhancement → sDistortionCorrection (FEC / LDCH / close) + iLdchLevel / iFecLevel

3. Runtime API​

rk_isp_set_distortion_correction(0, "LDCH");  // or "FEC"
rk_isp_set_ldch_level(0, 50);
rk_isp_set_fec_level(0, 50);

Note: Switching distortion_correction triggers rk_video_restart() to rebuild the video pipeline.

4. Data Flow Difference Between FEC and LDCH​

  • LDCH: VI → VPSS online (low overhead)
  • FEC: VI → GDC → VPSS offline (requires fec_ini_file, higher overhead)

When FEC is enabled, video.c goes through rkipc_vi_gdc_vpss_init().


How to Change Lenses / Use a New RV1126B-P Board​

  1. Ordinary low-distortion lens → use LDCH, just adjust ldch_level.
  2. High-distortion / fisheye → use FEC; you need to generate a calibration ini for the new lens (external/camera_engine_rkaiq/IspFec/ toolchain), place it in /usr/share/fec_calib/ and specify the path in the ini.
  3. Fine coefficients can also be configured in the ldc section of the RKAIQ IQ JSON (sw_ldcC_lensDistor_coeff, etc.).

RV1126B-P board-level differences are mainly in kernel-6.1/arch/arm64/boot/dts/rockchip/rv1126bp-evb*.dts, unrelated to the distortion algorithm itself.

System Debugging​

NPU Load Viewing​

NPU Frequency Adjustment​

root@rv1126bp-buildroot:/sys/class/devfreq# cat 21f40000.rkvenc/available_governors 
venc_ondemand rknpu_ondemand userspace simple_ondemand
root@rv1126bp-buildroot:/sys/class/devfreq# cat 22000000.npu/available_governors
venc_ondemand rknpu_ondemand userspace simple_ondemand

The devfreq node corresponding to the NPU is 22000000.npu. The video encoder 21f40000.rkvenc node can be ignored.

The available frequency scaling policies (governors) you listed are:

  • venc_ondemand: dedicated to video encoding (not suitable for NPU)
  • rknpu_ondemand: recommended, automatically scales frequency according to NPU load
  • userspace: manually fixed frequency
  • simple_ondemand: general load-based scaling

In most cases just keep this policy; the NPU automatically lowers frequency when idle and raises frequency during inference:

echo rknpu_ondemand > /sys/class/devfreq/22000000.npu/governor

Then check whether the current policy takes effect:

cat /sys/class/devfreq/22000000.npu/governor

🔧 Manually fixed frequency (for debugging)​

  1. View the supported frequency list:

    cat /sys/class/devfreq/22000000.npu/available_frequencies

    According to RV1126 specs, common levels are 300MHz, 400MHz, 500MHz, 600MHz, 700MHz, 800MHz, etc. (subject to actual output).

  2. Switch to userspace mode:

    echo userspace > /sys/class/devfreq/22000000.npu/governor
  3. Set the target frequency (for example 600000000 Hz):

    echo 600000000 > /sys/class/devfreq/22000000.npu/userspace/set_freq
  4. Confirm the current frequency:

    cat /sys/class/devfreq/22000000.npu/cur_freq

📌 Notes​

  • After manually fixing the frequency, the NPU will no longer automatically adjust according to load, which may cause overheating or unnecessary power consumption; it is recommended to restore rknpu_ondemand after debugging.
  • If your application runs models with the RKNN API, usually the driver automatically manages the frequency and no manual adjustment is needed. Intervention is only needed for performance stress testing or power optimization.

If you want to view the currently actually running frequency (even after adjustment via devfreq), you can still use the debugfs path you found before:

cat /sys/kernel/debug/clk/clk_npu_pll/clk_rate

Or directly read devfreq's cur_freq.


Device Information Query / Setting​

The answer first: For this 10.0.0.102 (RV1126B-P / rkipc / IMX415), it is most convenient to query / set via HTTP CGI; the main stream is currently 3840×2160, and white balance is already autoWhiteBalance by default.

Resolution​

Query resolution

# Current encoding resolution (main / sub stream)
curl -s http://10.0.0.102/cgi-bin/entry.cgi/video
curl -s http://10.0.0.102/cgi-bin/entry.cgi/video/0 # main stream
curl -s http://10.0.0.102/cgi-bin/entry.cgi/video/1 # sub stream

# Board-side configuration file (equivalent)
adb -s 10.0.0.102:5555 shell "grep -E '^(width|height|stream_type|output_data)' /userdata/rkipc.ini | head -40"

# Actual sensor output (low level)
adb -s 10.0.0.102:5555 shell "media-ctl -p -d /dev/media1 | grep -E 'fmt:|crop'"

Description:
/video returns sResolution (e.g. 3840*2160). Main stream options within this device's capabilities: 3840*2160, 2880*1616, 1920*1080, 1280*720, 960*540, 640*360, 320*240; sub stream: 1280*720, 640*480, 352*288, 320*240.

Set resolution

# Change main stream to 1920*1080 (example; PUT changes encoding parameters immediately)
curl -s -X PUT http://10.0.0.102/cgi-bin/entry.cgi/video/0 \
-H 'Content-Type: application/json' \
-d '{
"id": 0,
"sStreamType": "mainStream",
"sResolution": "1920*1080",
"sFrameRate": "30",
"sFrameRateIn": "30",
"sOutputDataType": "H.265",
"sRCMode": "VBR",
"sRCQuality": "highest",
"sSmart": "open",
"sGOPMode": "normalP",
"sH264Profile": "high",
"sVideoType": "compositeStream",
"iMaxRate": 4096,
"iMinRate": 0,
"iTargetRate": 0,
"iGOP": 60,
"iStreamSmooth": 50
}'

# Or modify the configuration and restart rkipc
adb -s 10.0.0.102:5555 shell '
sed -i "s/^width = 3840/width = 1920/; s/^height = 2160/height = 1080/" /userdata/rkipc.ini
# Note: the sed above also changes other sections such as jpeg; it is safer to change only the [video.0] section
killall rkipc; /usr/bin/RkLunch.sh &
'

Description: Web/CGI uses PUT /video/0 (main) or /video/1 (sub); the sResolution field format is width*height. After modification, confirm with GET /video/0; the stream URL is still rtsp://10.0.0.102:554/live/0.


White Balance / Image Parameters​

Query white balance

# White balance
curl -s http://10.0.0.102/cgi-bin/entry.cgi/image/0/white-blance

# Image overview (including white balance, exposure, brightness / contrast, etc.)
curl -s http://10.0.0.102/cgi-bin/entry.cgi/image/0
# or
curl -s http://10.0.0.102/cgi-bin/entry.cgi/image/white-blance

Description: The current device is already in automatic white balance: sWhiteBlanceStyle=autoWhiteBalance. Options: autoWhiteBalance, manualWhiteBalance, lockingWhiteBalance, fluorescentLamp, incandescent, warmLight, naturalLight.

Set white balance (enable automatic)

curl -s -X PUT http://10.0.0.102/cgi-bin/entry.cgi/image/0/white-blance \
-H 'Content-Type: application/json' \
-d '{
"sWhiteBlanceStyle": "autoWhiteBalance",
"iWhiteBalanceRed": 50,
"iWhiteBalanceGreen": 50,
"iWhiteBalanceBlue": 50
}'

Manual white balance example

curl -s -X PUT http://10.0.0.102/cgi-bin/entry.cgi/image/0/white-blance \
-H 'Content-Type: application/json' \
-d '{
"sWhiteBlanceStyle": "manualWhiteBalance",
"iWhiteBalanceRed": 50,
"iWhiteBalanceGreen": 50,
"iWhiteBalanceBlue": 50
}'

Description: You can also change the entire set of image parameters at once: PUT /image/0, with fields such as whiteBlance, exposure, imageAdjustment in the body. Web side: http://10.0.0.102/ → Image Settings.

Equivalent configuration file items (/userdata/rkipc.ini):

[isp.0.white_blance]
white_blance_style = autoWhiteBalance
white_blance_red = 50
white_blance_green = 50
white_blance_blue = 50

After modifying the ini, restart rkipc for it to take effect; prefer CGI PUT.

AI Translation Notice

This page was translated into English by AI and is provided for reference only. The original document is written in Chinese. If there is any discrepancy, the Chinese version prevails.

本页英文内容由 AI 自动翻译生成,仅供参考;原文为中文,如有差异请以中文原文为准。

查看中文原文 / View the Chinese original →