How to run galcore.ko of aml_npu_sdk.tgz on Ubuntu18.04+VIM3 Pro

Dear technical supporter,

I installed VIM3_Ubuntu-xfce-bionic_Linux-4.9_arm64_SD-USB_V20190830.7z on microSDcard + VIM3 Pro board. In order to use NPU facility of VIM3 Pro board, I downloaded the aml_npu_sdk.tgz file at https://www.khadas.com/npu-toolkit-vim3. Then, I found the galcore.ko file at linux_sdk/linux_sdk_6.3.3.4/build/sdk/ReadMe.txt file after decompressing aml_npu_sdk.tgz file.
The ReadMe.txt describes how to run “galcore.ko” file with the “insmod” command as follows.

dmesg log messages

[138716.608197] galcore irq number is 36.
[138716.608208] Galcore version 6.3.3.210826
[138716.608211] Galcore options:
[138716.608215]   irqLine           = 36
[138716.608218]   registerMemBase   = 0xFF100000
[138716.608222]   registerMemSize   = 0x00020000
[138716.608226]   contiguousSize    = 0x00400000
[138716.608229]   contiguousBase    = 0xFFFFFFFFFFFFFFFF
[138716.608232]   externalSize      = 0x00000000
[138716.608236]   externalBase      = 0x00000000
[138716.608239]   bankSize          = 0x00000000
[138716.608242]   fastClear         = -1
[138716.608245]   compression       = 15
[138716.608248]   powerManagement   = 1
[138716.608252]   baseAddress       = 0x00000000
[138716.608255]   physSize          = 0x00000000
[138716.608258]   recovery          = 1
[138716.608261]   stuckDump         = 0
[138716.608264]   gpuProfiler       = 0
[138716.608268]   userClusterMask   = 0x0
[138716.608271]   smallBatch        = 1
[138716.608274]   irqs              = 36, -1, -1, -1, -1, -1, -1, -1, -1, -1,
[138716.608306]   registerBases     = 0xFF100000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
[138716.608338]   registerSizes     = 0x00020000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
[138716.608403]   chipIDs           = 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
[138716.608435]   core 0 sRAMBases = 0xFFFFFFFFFFFFFFFF, 0xFF000000, 0xFFFFFFFF,
[138716.608449]   core 1 sRAMBases = 0xFFFFFFFFFFFFFFFF, 0xFFFFFFFFFFFFFFFF, 0xFFFFFFFFFFFFFFFF,
[138716.608463]   core 2 sRAMBases = 0xFFFFFFFFFFFFFFFF, 0xFFFFFFFFFFFFFFFF, 0xFFFFFFFFFFFFFFFF,
[138716.608477]   core 3 sRAMBases = 0xFFFFFFFFFFFFFFFF, 0xFFFFFFFFFFFFFFFF, 0xFFFFFFFFFFFFFFFF,
[138716.608490]   core 4 sRAMBases = 0xFFFFFFFFFFFFFFFF, 0xFFFFFFFFFFFFFFFF, 0xFFFFFFFFFFFFFFFF,
[138716.608504]   core 5 sRAMBases = 0xFFFFFFFFFFFFFFFF, 0xFFFFFFFFFFFFFFFF, 0xFFFFFFFFFFFFFFFF,
[138716.608518]   core 6 sRAMBases = 0xFFFFFFFFFFFFFFFF, 0xFFFFFFFFFFFFFFFF, 0xFFFFFFFFFFFFFFFF,
[138716.608531]   core 7 sRAMBases = 0xFFFFFFFFFFFFFFFF, 0xFFFFFFFFFFFFFFFF, 0xFFFFFFFFFFFFFFFF,
[138716.608545]   core 8 sRAMBases = 0xFFFFFFFFFFFFFFFF, 0xFFFFFFFFFFFFFFFF, 0xFFFFFFFFFFFFFFFF,
[138716.608559]   core 9 sRAMBases = 0xFFFFFFFFFFFFFFFF, 0xFFFFFFFFFFFFFFFF, 0xFFFFFFFFFFFFFFFF,
[138716.608573] Build options:
[138716.608576]   gcdGPU_TIMEOUT    = 20000
[138716.608580]   gcdGPU_2D_TIMEOUT = 4000
[138716.608583]   gcdINTERRUPT_STATISTIC = 1
[138716.610957] request mem galcore contiguous memory(0xffffffffffffffff - 0x3ffffe) failed
[138716.611247] galcore: probe of ff100000.galcore failed with error -22
[139161.482930] galcore: disagrees about version of symbol module_layout

Question1: However, when I run “insmod /galcore.ko registerMemBase=0x80000000 irqLine=104 contiguousSize=0x400000”, I could not find “/dev/galcore” file. And, when I type the “dmesg” command, I get the below error message. How can I fix this issue? And
Is the galcore.ko of the aml_npu_sdk.tgz file valid?

Running applications on the target machine
==========================================

1. Copy the libraries to the target
    On the target machine:
    cp galcore.ko /
    cp libEGL.so libGLESv1_CM.so libGAL.so libGLSLC.so libGLESv2.so /lib

2. Install the kernel driver
    insmod /galcore.ko registerMemBase=<REG_MEM_BASE> irqLine=<IRQ> contiguousSize=<CONTIGUOUS_MEM_SIZE>

    eg. On ARM EB development board:
    insmod /galcore.ko registerMemBase=0x80000000 irqLine=104 contiguousSize=0x400000

Question 2: I could not find “samples” folder after decompressing the aml_npu_sdk.tgz file. Could you tell me the location of the “samples” folder?

3. Run the application
    eg.
    cd $SDK_DIR/samples/vdk; ./tutorial1

@leemgs If you used the firmware which is V20190830, you should follow this page to use NPU with ubuntu.

1 Like

@Frank, Do you mean that the “linux_sdk/linux_sdk_6.3.3.4/build/sdk/ReadMe.txt” of the “aml_npu_sdk.tgz” file is out-of-date?

@leemgs No, but we have made some adaptations, and you can use them normally according to our steps

1 Like

Got it. At that time, I thought that an up-to-date guide was the ReadMe.txt to use aml_npu_sdk.tgz file (It could be downloaded at https://www.khadas.com/npu-toolkit-vim3). Thanks.

eg. On ARM EB development board:
insmod /galcore.ko registerMemBase=0x80000000 irqLine=104 contiguousSize=0x400000

@Frank, If you know, could you tell me the exact information of (1)registerMemBase, (2)irqLine, and (3)contiguousSize in case of the VIM3 Pro board?

I checked the arguments of galcore.ko by using the https://dl.khadas.com/repos/vim3/pool/main/l/linux-4.9.190/linux-image-amlogic-4.9_0.7-4_arm64.deb (This file includes galcore.ko).
And then, I tried to run galcore.ko that is included in the aml_npu_sdk.tgz. The result is failed. Cannot I use “contiguousBase=0x88800000” option?

Case study:

vim3$ sudo rmmod galcore
vim3$ sudo insmod ./galcore.ko registerMemBase=0xFF100000 irqLine=36 contiguousSize=0x400000  contiguousBase=0x88800000 
vim3$ sudo dmesg | tail -n 50

 *** Omission ***

[  871.978269]   core 0 sRAMBases = 0xFFFFFFFFFFFFFFFF, 0xFF000000, 0xFFFFFFFF,
[  871.978276]   core 1 sRAMBases = 0xFFFFFFFFFFFFFFFF, 0xFFFFFFFFFFFFFFFF, 0xFFFFFFFFFFFFFFFF,
[  871.978283]   core 2 sRAMBases = 0xFFFFFFFFFFFFFFFF, 0xFFFFFFFFFFFFFFFF, 0xFFFFFFFFFFFFFFFF,
[  871.978289]   core 3 sRAMBases = 0xFFFFFFFFFFFFFFFF, 0xFFFFFFFFFFFFFFFF, 0xFFFFFFFFFFFFFFFF,
[  871.978295]   core 4 sRAMBases = 0xFFFFFFFFFFFFFFFF, 0xFFFFFFFFFFFFFFFF, 0xFFFFFFFFFFFFFFFF,
[  871.978302]   core 5 sRAMBases = 0xFFFFFFFFFFFFFFFF, 0xFFFFFFFFFFFFFFFF, 0xFFFFFFFFFFFFFFFF,
[  871.978308]   core 6 sRAMBases = 0xFFFFFFFFFFFFFFFF, 0xFFFFFFFFFFFFFFFF, 0xFFFFFFFFFFFFFFFF,
[  871.978315]   core 7 sRAMBases = 0xFFFFFFFFFFFFFFFF, 0xFFFFFFFFFFFFFFFF, 0xFFFFFFFFFFFFFFFF,
[  871.978321]   core 8 sRAMBases = 0xFFFFFFFFFFFFFFFF, 0xFFFFFFFFFFFFFFFF, 0xFFFFFFFFFFFFFFFF,
[  871.978328]   core 9 sRAMBases = 0xFFFFFFFFFFFFFFFF, 0xFFFFFFFFFFFFFFFF, 0xFFFFFFFFFFFFFFFF,
[  871.978335] Build options:
[  871.978336]   gcdGPU_TIMEOUT    = 20000
[  871.978338]   gcdGPU_2D_TIMEOUT = 4000
[  871.978339]   gcdINTERRUPT_STATISTIC = 1
[  871.982506] request mem galcore contiguous memory(0xffffffffffffffff - 0x3ffffe) failed
[  871.982653] galcore: probe of ff100000.galcore failed with error -22

@leemgs Maybe @numbqq can help you about that.