Environment Preparation
Enable AI in SDK
Enable AI configuration on RK3576 as follows:
diff --git a/BoardConfig.mk b/BoardConfig.mk
index 511b378..c7d6ea1 100644
--- a/BoardConfig.mk
+++ b/BoardConfig.mk
@@ -119,6 +121,7 @@ BUILD_BROKEN_USES_BUILD_HOST_SHARED_LIBRARY := true
BUILD_BROKEN_USES_BUILD_HOST_STATIC_LIBRARY := true
BOARD_SHOW_HDMI_SETTING ?= true
+BOARD_RKAI_SUPPORT := true
# for dynamaic afbc target
BOARD_HS_DYNAMIC_AFBC_TARGET := false
Models
RkAiService is the app for subtitle translation module, and RkAiLauncher is the floating ball app. After flashing the firmware, pull down the status bar, drag the RkAi shortcut button to the top, and click to enable it to show the desktop floating ball.
Enabling AI functionality also requires corresponding models and keys:
Model files are located at: https://pan.baidu.com/s/1f3UYjm1zoA7efFwRdUQAGQ Extraction code: 3576
Copy Scripts
Copy rkauth_tool_bin, rkauth_verify_licence, and rkdevice_info to the /system/bin/ directory
and modify them to be executable:
su;
chmod +x /system/bin/rk*
Apply for Licence
Apply for keys from RK business
One method is to burn to the corresponding ID. Use adb shell to access the machine, and use the vendor-storage-test command to burn to the specified key location (see packages/apps/RkAuth/etc/rkauth_config.json)
Super Resolution: Module name sr storageid: 60 offline storageid: 1060
Subtitle Translation: Module name asr storageid: 84 offline storageid: 1084 offline file path: /sdcard/rkai/key_asr.lic
Motion Compensation: Module name memc storageid: 62 offline storageid: 1062
Generate SR Lic and Write to Storage
rkauth_tool_bin --user=neardi_ai --passwd=yourpasswd -m "sr" --output=/sdcard/rkai/key_sr.lic
View:
rk3576_neardi_lz201:/ # cat /sdcard/rkai/key_sr.lic
############################################################
# Rockchip License
# SDK: sr
# Activate Code: neardi_ai
# Expiration: 0
############################################################
CHidzYEKFJmOTZYfMoj7F6DjOJzf/nuUTLno63av4J44jw7wDe8XaqX9cDBi
ZHhH+YNKZIUTfx/1EXvS1T5dvAhcytXDILCuScwrZZAp6/3mIuSzhxPLMq/C
h+TGHJRtsTsxoM1P70NukekQdlRSZVkmIA2zwAWOM1ROh5uZR0dDXTMwqpiV
AcDjF+2Ye/1fixLL+PsP/El5SkNRcPwztv/qTgNZ+UgdeG3DJb5YM+eL9E4+
cqo865GMPxQX1d8yisSSJfuLjYeFv7Rf7O9dbHPiUrCFmsn6d2FedM3ifv3n
EghjhSkOPOo1gUOT3Lf5
For later production, the provided should be the key, sr is online 60, offline 1060. Currently in debug phase, using username to generate lic for testing, write the lic file to the offline location
###Copy the middle content, remove line breaks, combine into one line, write to offline key location
vendor-storage-test 1060 1024 CHidzYEKFJmOTZYfMoj7F6DjOJzf/nuUTLno63av4J44jw7wDe8XaqX9cDBiZHhH+YNKZIUTfx/1EXvS1T5dvAhcytXDILCuScwrZZAp6/3mIuSzhxPLMq/Ch+TGHJRtsTsxoM1P70NukekQdlRSZVkmIA2zwAWOM1ROh5uZR0dDXTMwqpiVAcDjF+2Ye/1fixLL+PsP/El5SkNRcPwztv/qTgNZ+UgdeG3DJb5YM+eL9E4+cqo865GMPxQX1d8yisSSJfuLjYeFv7Rf7O9dbHPiUrCFmsn6d2FedM3ifv3nEghjhSkOPOo1gUOT3Lf5
Then adb reboot, note not to power off, to prevent data loss
Check remaining usage:
rk3576_neardi_lz201:/ # rkauth_tool_bin -u neardi_ai -p NlRQQAjjqQF6 -m "sr" -a 1
modules usages:
sr 1/5
Generate ASR Lic and Write to Storage
rkauth_tool_bin --user=neardi_ai --passwd=yourpasswd -m "asr" --output=/sdcard/rkai/key_asr.lic
View:
rk3576_neardi_lz201:/ # cat /sdcard/rkai/key_asr.lic
############################################################
# Rockchip License
# SDK: asr
# Activate Code: neardi_ai
# Expiration: 0
############################################################
CHidzYEKFJmOTZYfMoj7F+NToGgNgqYz7jgQMG80NnM4jw7wDe8XaqX9cDBi
ZHhH+YNKZIUTfx/1EXvS1T5dvAhcytXDILCuScwrZZAp6/3mIuSzhxPLMq/C
h+TGHJRt6V4vJ96ZyQ1HCRVqk653HpjkHh7DjsrQl/cKxa+mzgpDXTMwqpiV
AcDjF+2Ye/1fV+9XevUtoFndIiRHsm9rlFFZ73RbH2Cn4KGFKEOxotk7e5St
lMSZFWi3zZJW2CHyuFVbnZtiiRD5zFYxoK39EVlHVstCFzx+atr7ih4waz4u
DHzINw730F9Q26siL5U0
############################################################
For later production, the provided should be the key, sr is online 84, offline 1084. Currently in debug phase, using username to generate lic for testing, write the lic file to the offline location
###Copy the middle content, remove line breaks, combine into one line, write to offline key location
vendor-storage-test 1084 1024 CHidzYEKFJmOTZYfMoj7F+NToGgNgqYz7jgQMG80NnM4jw7wDe8XaqX9cDBiZHhH+YNKZIUTfx/1EXvS1T5dvAhcytXDILCuScwrZZAp6/3mIuSzhxPLMq/Ch+TGHJRt6V4vJ96ZyQ1HCRVqk653HpjkHh7DjsrQl/cKxa+mzgpDXTMwqpiVAcDjF+2Ye/1fV+9XevUtoFndIiRHsm9rlFFZ73RbH2Cn4KGFKEOxotk7e5StlMSZFWi3zZJW2CHyuFVbnZtiiRD5zFYxoK39EVlHVstCFzx+atr7ih4waz4uDHzINw730F9Q26siL5U0
Then adb reboot, note not to power off, to prevent data loss
Authorization success log:
rk3576_neardi_lz201:/ $ logcat -s SvepAuth
--------- beginning of main
02-28 03:05:53.946 322 357 I SvepAuth: Routine,line=1030, vendor.boot_completed=0, not to access /data/system/svep_key.lic
02-28 03:06:04.294 322 357 I SvepAuth: GetAuthJsonPath,line=667, CheckAuth: Find access json path = /vendor/etc/rkauth_config.json
02-28 03:06:04.298 322 357 I SvepAuth: DoAuthJson,line=730, CheckAuth: rkauth_create sr json=/vendor/etc/rkauth_config.json sucess! trial_time=1800
02-28 03:06:04.323 322 357 I SvepAuth: DoAuthJson,line=768, CheckAuth: rkauth_check auth json success.
Demo Usage
Copy SR and English Video to RK3576
adb push SR_Video_Dir /sdcard/
adb push test_video_file /sdcard/
Start Service
rk3576_neardi_lz201:/ $ su
rk3576_neardi_lz201:/ $ am startservice com.rockchip.ailauncher/.FloatballService
The floating ball will appear on the right side (with three menus: SR+, MEMC, and ASR);
130|rk3576_neardi_lz201:/ # ps -ef | grep aiservice
system 2246 527 2 13:58:26 ? 00:00:00 com.rockchip.aiservice
The aiservice main service is also started;
Play Video
- SR Experience
Open any video in the /sdcard/SR_Video_Dir directory for playback, click the AI floating box on the right, click “SR+” to experience super resolution, the top left will display:
RKNPU-SVEP-SR
Input : 1920x1080
Output : 3840x2160
- Translation Experience
Open any video in the /sdcard/test_video_file directory for playback, click the AI floating box on the right, click “ASR” to experience super resolution, the bottom will display both English and real-time translated Chinese.