---
# System prepended metadata

title: cross-compiling VIOx 筆記
tags: [學習, Work]

---

---
title: 'cross-compiling VIOx 筆記'
disqus: hackmd
---

cross-compiling VIOx 筆記
===

## Table of Contents

[TOC]

## Porting
  * cross-compiling
    ```C++
    export ANDROID_NDK=/home/dennis/project/prerequists/android-ndk-r21e
    ```
    ```C++
    cmake -DCMAKE_TOOLCHAIN_FILE=$ANDROID_NDK/build/cmake/android.toolchain.cmake     -DANDROID_ABI=arm64-v8a     -DANDROID_PLATFORM=android-29     -DANDROID_NATIVE_API_LEVEL=29     -DANDROID_STL=c++_shared   -DDEBUG_PLOT=OFF -DPRINT_LOG=OFF -DOUTPUT_POSE=OFF -DOUTPUT_RELATIVE_POSE=OFF  ..
    
    make -j32
    ```

    ```C++
    adb push test_viox/test_viox /data/local/tmp/vio/test_viox/
    adb push vio_system/vio_system /data/local/tmp/vio/test_viox/
    ```
  * run G90
    ```C++
    adb shell
    ``` 


    ```C++
    cd /data/local/tmp/vio/test_viox/
    ```    
    ```C++
    export LD_LIBRARY_PATH=/data/local/tmp/violib
    
    ./test_viox ../config/vio_config_a1m_0204_g90.json 1612405614109 50000       ``` 
    
    ./test_viox ../config/vio_config_a1m_0316_g90.json 1615859507165 10000   
    ./vio_system ../config/vio_config_a1m_0423_g90.json 1619161850035 100000 
    
  * run A1M   
    ```C++
    ssh dennis@172.19.134.22
    pw: 0
    adb devices 
    adb -s MTK0001903220243220 shell 
    
    /// 丟檔案到matlab那台
    sshfs dennis@172.19.134.22:/home/dennis/vio  /home/dennis/Job/1/
    adb -s MTK0001903220243220 push vio_system /data/local/tmp/vio/test_viox/
    
    /A55
    taskset 1 ./vio_system ../config/vio_config_a1m_0423_g90.json 1619161850035 100000
    /A76
    taskset 40 ./vio_system ../config/vio_config_a1m_0423_g90.json 1619161850035 100000
    /all
    taskset ff ./vio_system ../config/vio_config_a1m_0423_g90.json 1619161850035 100000
    
    // take file
    adb -s MTK0001903220243220 pull /data/local/tmp/vio/test_viox/cbtn_mem_cpu.txt /home/dennis/vio/
    
    scp dennis@172.19.134.22:/home/dennis/vio/cbtn_mem_cpu.txt  /home/dennis/Job/
    ``` 
    ![](https://i.imgur.com/7yG9C0E.png)
  * get run time result file
    ```C++
    adb pull /data/local/tmp/vio/test_viox/frontend_time.csv
    ```  
      
      
  * Set which core to run program
   ```C++
    # Find the program PID
    ps -ef | grep [task name]
   ```  

   ```C++
    # Set specific core to run program
    $ taskset -p 1 [program PID]  # run on cpu1
    $ taskset -p 2 [program PID]  # run on cpu2
    $ taskset -p 4 [program PID]  # run on cpu3
    $ taskset -p 8 [program PID]  # run on cpu4
    ...
    $ taskset -p 64 [program PID]  # run on cpu7   <--- USE A76
    $ taskset -p 128 [program PID]  # run on cpu8
    $ taskset -p 192 [program PID]  # run on cpu7,8 (64+128=192)
    
     For g90, cpu 1-6 are Arm Cortex-55  cpu 7,8 are Arm Cortex-76 
     # on other devices which has taskset -c command
    $ taskset -cp 3-5 [program PID]  # run on cpu 3-5
   ```  
  
### 編譯openCV staic without NEON
```C++
$ cd opencv
$ mkdir build && cd build
$ export ANDROID_NDK=/your/path/to/android-ndk-r21d/
$ export DEST=/your/path/to/viox/lib/opencv

$ cmake .. -DCV_DISABLE_OPTIMIZATION=ONcmake -DCMAKE_TOOLCHAIN_FILE=$ANDROID_NDK/build/cmake/android.toolchain.cmake         -DANDROID_ABI=arm64-v8a         -DANDROID_PLATFORM=android-29         -DANDROID_NATIVE_API_LEVEL=29         -DCMAKE_BUILD_TYPE=RELEASE         -D BUILD_EXAMPLES=OFF         -D BUILD_opencv_apps=OFF         -D BUILD_DOCS=OFF         -D BUILD_PERF_TESTS=OFF         -D BUILD_TESTS=OFF         -D CMAKE_BUILD_TYPE=Release         -D WITH_NVCUVID=OFF         -D WITH_CUDA=OFF         -D WITH_OPENCL=OFF                -DBUILD_PROTOBUF=OFF         -D BUILD_opencv_dnn=OFF         -D BUILD_opencv_python=OFF         -D WITH_PYTHON=OFF         -D BUILD_opencv_python2=OFF         -D WITH_PYTHON2=OFF         -D WITH_PYTHON3=OFF         -D BUILD_opencv_python3=OFF         -DBUILD_JAVA=OFF         -D WITH_IPP=OFF         -D CMAKE_INSTALL_PREFIX=$DEST/opencv         -DBUILD_ANDROID_EXAMPLES=OFF -DCV_DISABLE_OPTIMIZATION=ON -DENABLE_NEON=OFF  -DBUILD_SHARED_LIBS=OFF .. 

$ make -j32
$ make install
```  


###### tags: `Work` `學習`
