RK3566 使能NPU

一、硬件

确定VDD_NPU所用的电源

RK3566 使能NPU_第1张图片

RK3566 使能NPU_第2张图片 用的是PMIC的DC-DC2

 二、SDK

1、修改板级配置DTS文件

配置vdd_gpu

    			vdd_gpu: DCDC_REG2 {
				regulator-always-on;
				regulator-boot-on;
				regulator-min-microvolt = <500000>;
				regulator-max-microvolt = <1350000>;
				regulator-init-microvolt = <900000>;
				regulator-ramp-delay = <6001>;
				regulator-initial-mode = <0x2>;
				regulator-name = "vdd_gpu";
				regulator-state-mem {
					regulator-off-in-suspend;
				};
			};

 使能npu相关节点

&bus_npu {
	bus-supply = <&vdd_logic>;
	pvtm-supply = <&vdd_cpu>;
	status = "okay";
};

&rknpu {
	rknpu-supply = <&vdd_gpu>;
	status = "okay";
};

&rknpu_mmu {
	status = "okay";
};

2、使能驱动

cd到kernel目录,执行

make menuconfig ARCH=arm64

Device Drivers  ---> 

                 RKNPU  ---> 

                         <*> ROCKCHIP_RKNPU 

然后save,再复制.config文件。

cp .config arch/arm64/configs/rockchip_linux_defconfig

rockchip_linux_defconfig为编译时TARGET_KERNEL_CONFIG指定的文件。

3、重新编译kernel,然后烧录到主板

4、测试

主板启动之后cd到/rockchip_test/npu2目录执行测试脚本

[root@RK356X:/]# cd /rockchip_test/npu2
[root@RK356X:/rockchip_test/npu2]# ls
lib    npu_freq_scaling.sh  npu_test.sh   rknn_mobilenet_demo
model  npu_stress_test.sh   rknn_demo.sh
[root@RK356X:/rockchip_test/npu2]# ./npu_test.sh 
*****************************************************
***                                               ***
***            NPU TEST                           ***
***                                               ***
*****************************************************
***********************************************************
npu stress test:                                        1
npu scale frequency test:                       2
rknn demo test:                                 3
***********************************************************
1
I RKNN: set log level to 0
model input num: 1, output num: 1
input tensors:
index=0 name=input n_dims=4 dims=[3 224 224 1] n_elems=150528 size=150528 fmt=0 type=2 qnt_type=2 fl=0 zp=0 scale=0.007812
output tensors:
index=0 name=MobilenetV1/Predictions/Reshape_1 n_dims=2 dims=[0 0 1001 1] n_elems=1001 size=2002 fmt=0 type=1 qnt_type=2 fl=0 zp=0 scale=1.000000
rknn_run
 --- Top5 ---
156: 0.597656
155: 0.227173
205: 0.077576
752: 0.017227
880: 0.015472

你可能感兴趣的:(linux系统及驱动开发,算法,RK3566,NPU)