...
Table of Contents
Table of Contents | |||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
1. NPU Driver
The SP7350 Linux includes the NPU driver by default, supporting three versions: 6.4.13.8, 6.4.15.9, and 6.4.18.5. By default, version 6.4.15.9 is selected.
1.1. Changing the Version
To switch to a different version, run the ‘make kconfig’ command in the project's top directory. When the Linux Kernel Configuration menu appears, move cursor to select the desired driver version. The path is:
Code Block |
---|
Device Drivers ->
Multimedia support ->
Media drivers ->
ML Inference Processor VIP9000_NPU |
Refer to the snapshot of the NPU Version choice menu below:
...
After selecting the desired driver version, complete the Linux compilation process by running the ‘make’ command.
1.2. Power Management
The NPU driver supports power management, allowing it to power . When loading the NPU driver with the ‘powerManagement=0’ parameter, the NPU power is turned on when the driver probes is probed and power turned off when the driver is removed. To enable this function, insert further save power, load the NPU driver with the ‘powerManagement=1’ parameter. Use . This ensures that the NPU power is only turned on when the NPU is actively running.
1.3. Loading the NPU driver
To load the NPU driver (module), use the ‘modprobe’ command as shown below:
Code Block | ||
---|---|---|
| ||
modprobe galcore powerManagement=1 |
or:
Code Block |
---|
modprobe galcore powerManagement=0 |
Here, 'galcore' is the module name of the NPU driver. The Linux kernel message when When the NPU driver is probing will look like thisbeing probed, the Linux kernel message will appear as follows:
Code Block |
---|
[ 29.498289] galcore f8140000.galcore: NPU get power success [ 29.498971] galcore f8140000.galcore: galcore irq number is 44 [ 29.499073] galcore f8140000.galcore: NPU clock: 900000000 [ 29.503967] Galcore version 6.4.15.9.700103 [ 29.509197] galcore f8140000.galcore: _SetPower 0 0 enable [ 29.518719] galcore f8140000.galcore: regulator enable success [ 29.519415] galcore f8140000.galcore: NPU ISO disable [ 29.524477] galcore f8140000.galcore: NPU HW reset SMS [ 29.529566] galcore f8140000.galcore: NPU HW reset deassert [ 29.535127] galcore f8140000.galcore: NPU HW clock enable [ 29.540803] galcore f8140000.galcore: _SetPower enable ret=0 [ 29.546162] galcore f8140000.galcore: NPU clock enable success [ 29.559172] galcore f8140000.galcore: NPU clock disable success [ 29.559227] galcore f8140000.galcore: _SetPower 0 0 disable [ 29.563427] galcore f8140000.galcore: NPU HW clock disabled [ 29.568980] galcore f8140000.galcore: NPU HW reset assert [ 29.574355] galcore f8140000.galcore: NPU ISO enable [ 29.579308] galcore f8140000.galcore: regulator disable success [ 29.585206] galcore f8140000.galcore: _SetPower disable ret=0 |
...
Code Block | ||
---|---|---|
| ||
modprobe galcore |
Upon successful NPU driver probing, the NPU device ('galcore') will appear in the Linux device directory '/dev'.
Code Block |
---|
~ # ls -l /dev/galcore crw-rw---- 1 root root 199, 0 Jan 1 00:00 /dev/galcore |
2. NN Shared Libraries
Neural network (NN) applications cannot directly interact with the NPU but instead rely on the NPU driver and prebuilt NN shared libraries. These libraries, along with relevant header files, are stored in the source project directory of the SP7350 for different versions.
Code Block |
---|
wells@wells-linux:~/Q654$ ll linux/rootfs/initramfs/prebuilt/vip9000sdk total 2820 drwxrwxr-x 7 wells wells 4096 Jun 12 21:31 ./ drwxrwxr-x 9 wells wells 4096 Jun 12 21:31 ../ drwxrwxr-x 4 wells wells 4096 Jun 12 21:31 6.4.13.8/ drwxrwxr-x 4 wells wells 4096 Jun 12 21:31 6.4.15.9/ drwxrwxr-x 4 wells wells 4096 Jun 12 21:31 6.4.18.5/ linux/rootfs/initramfs/prebuilt/vip9000sdk |
The ‘include’ subdirectory includes the relevant header files:
...
Upon selecting a version of the NPU driver, the corresponding NN shared libraries are automatically copied to the '/lib' or '/lib64' directory of the root file system on the target SP7350 system. This ensures that the required libraries are readily accessible for NN applications.
3. NN Applications
Neural network (NN) applications leverage the NPU to execute complex neural network operations by invoking functions within NN shared libraries.
3.1. Compiling NN Applications
When compiling NN applications, users must include the appropriate header files and shared libraries, as demonstrated below:
Code Block | ||
---|---|---|
| ||
INCLUDES+=-I$(VIVANTENN_SDK_DIR)/include/HAL \ -I$(VIVANTENN_SDK_DIR)/include/CL \ -I$(VIVANTENN_SDK_DIR)/include/VX \ -I$(VIVANTENN_SDK_DIR)/include/ovxlib \ -I$(VIVANTENN_SDK_DIR)/include/jpeg LIBS+=-lOpenVX -lOpenVXU -lCLC -lVSC -lGAL -ljpeg -lovxlib |
3.2. Running NN Application
During runtime, ensure that the NN shared libraries are accessible by setting the library path accordingly:
...