[build] Use aarch64 for arm64 (#9417)
author오형석/On-Device Lab(SR)/Staff Engineer/삼성전자 <hseok82.oh@samsung.com>
Mon, 9 Dec 2019 01:43:59 +0000 (10:43 +0900)
committerGitHub Enterprise <noreply-CODE@samsung.com>
Mon, 9 Dec 2019 01:43:59 +0000 (10:43 +0900)
Change naming arm64 to aarch64
Naming arm64 is used for external tools and libraries
Update build rootfs script

Signed-off-by: Hyeongseok Oh <hseok82.oh@samsung.com>
16 files changed:
Makefile.template
docs/nnfw/howto/CrossBuildForAarch64.md
docs/nnfw/howto/CrossBuildForAndroid.md
docs/nnfw/howto/CrossBuildForArm.md
infra/cmake/modules/IdentifyPlatform.cmake
infra/cmake/packages/ARMComputeConfig.cmake
infra/nnfw/cmake/buildtool/config/config_aarch64-android.cmake [moved from infra/nnfw/cmake/buildtool/config/config_arm64-android.cmake with 90% similarity]
infra/nnfw/cmake/buildtool/cross/toolchain_aarch64-android.cmake [moved from infra/nnfw/cmake/buildtool/cross/toolchain_arm64-android.cmake with 93% similarity]
infra/nnfw/cmake/buildtool/cross/toolchain_aarch64-linux.cmake
infra/nnfw/cmake/buildtool/cross/toolchain_aarch64-tizen.cmake
infra/nnfw/cmake/options/options_aarch64-android.cmake [moved from infra/nnfw/cmake/options/options_arm64-android.cmake with 96% similarity]
runtime/contrib/android_benchmark_app/README.md
tools/cross/aarch64/sources.list.bionic [new file with mode: 0644]
tools/cross/aarch64/sources.list.trusty [moved from tools/cross/arm64/sources.list.trusty with 100% similarity]
tools/cross/aarch64/sources.list.xenial [moved from tools/cross/arm64/sources.list.xenial with 100% similarity]
tools/cross/build_rootfs.sh

index 9ff5e11..ef3a44c 100644 (file)
@@ -16,15 +16,16 @@ BUILD_TYPE_LC=$(shell echo $(BUILD_TYPE) | tr A-Z a-z)
 # we need base name 'arm` for all arm arch
 TARGET_ARCH_BASE=$(TARGET_ARCH_LC)
 ifneq (,$(findstring arm64,$(TARGET_ARCH_BASE)))
-       # arm64 as target-arch comes from Android
-       TARGET_ARCH_BASE=arm64
-       # For now Android is the only option for arm64
-       TARGET_OS:=android
+       TARGET_ARCH_LC=aarch64
 else ifneq (,$(findstring arm,$(TARGET_ARCH_BASE)))
-       TARGET_ARCH_BASE=arm
+       TARGET_ARCH_LC=armv7l
 else ifneq (,$(findstring aarch64,$(TARGET_ARCH_BASE)))
-       # aarch64 as target-arch comes from all except for Android
-       TARGET_ARCH_BASE=aarch64
+       TARGET_ARCH_LC=aarch64
+endif
+ifneq (,$(findstring android,$(TARGET_OS)))
+       # Anndroid only allow aarch64 target-arch
+       TARGET_ARCH_LC=aarch64
+       TARGET_OS=android
 endif
 # Set CROSS_BUILD=1 when ROOTFS_DIR is given, and TARGET_ARCH is different to HOST_ARCH.
 ifneq ($(ROOTFS_DIR),)
@@ -125,9 +126,7 @@ distclean:
 ###
 configure_internal:
        NNFW_WORKSPACE="$(WORKSPACE)" NNFW_INSTALL_PREFIX=$(INSTALL_PATH) ./nnfw configure \
-               -DCMAKE_BUILD_TYPE=$(BUILD_TYPE_LC) -DTARGET_ARCH=$(TARGET_ARCH_LC) \
-               -DHOST_OS=$(HOST_OS) \
-               -DTARGET_OS=$(TARGET_OS) \
+               -DCMAKE_BUILD_TYPE=$(BUILD_TYPE_LC) \
                -DNNFW_OVERLAY_DIR=$(OVERLAY_FOLDER) \
                $(OPTIONS)
        touch $(TIMESTAMP_CONFIGURE)
index f3dc552..9f0af85 100644 (file)
@@ -1,10 +1,6 @@
-# Cross building for AARCH64
+# Cross building for AARCH64 (ARM64)
 
-In nnfw, we use both `ARM64` and `AARCH64` on build files such as Makefile, CMakeLists.txt and so on.
-- `ARM64`: only for Android
-- `AARCH64`: all except for Android
-
-However we use only one term `ARM64` in RootFS. Use `ARM64` if you need a RootFS for `AARCH64`.
+In nnfw, we use `AARCH64` on build files such as Makefile, CMakeLists.txt and so on.
 
 ## Prepare Ubuntu RootFS
 
@@ -17,9 +13,9 @@ sudo apt-get install qemu qemu-user-static binfmt-support debootstrap
 Use `build_rootfs.sh` script to prepare Root File System. You should have `sudo`
 
 ```
-sudo ./tools/cross/build_rootfs.sh arm64
+sudo ./tools/cross/build_rootfs.sh aarch64
 ```
-- supports `arm`(default) and `arm64` architecutre for now
+- supports `arm`(default) and `aarch64` architecutre for now
 - supports `xenial`(default) and `trusty` release
 
 To see the options,
@@ -27,14 +23,14 @@ To see the options,
 ./tools/cross/build_rootfs.sh -h
 ```
 
-RootFS will be prepared at `tools/cross/rootfs/arm64` folder.
+RootFS will be prepared at `tools/cross/rootfs/aarch64` folder.
 
 ### Prepare RootFS at alternative folder
 
 Use `ROOTFS_DIR` to a full path to prepare at alternative path.
 
 ```
-ROOTFS_DIR=/home/user/rootfs/arm64-xenial sudo ./tools/cross/build_rootfs.sh arm64
+ROOTFS_DIR=/home/user/rootfs/aarch64-xenial sudo ./tools/cross/build_rootfs.sh aarch64
 ```
 
 ### Using proxy
@@ -43,9 +39,9 @@ If you need to use proxy server while building the rootfs, use `--setproxy` opti
 
 ```
 # for example,
-sudo ./tools/cross/build_rootfs.sh arm64 --setproxy="1.2.3.4:8080"
+sudo ./tools/cross/build_rootfs.sh aarch64 --setproxy="1.2.3.4:8080"
 # or
-sudo ./tools/cross/build_rootfs.sh arm64 --setproxy="proxy.server.com:8888"
+sudo ./tools/cross/build_rootfs.sh aarch64 --setproxy="proxy.server.com:8888"
 ```
 
 This will put `apt` proxy settings in `rootfs/etc/apt/apt.conf.d/90proxy` file
@@ -76,6 +72,6 @@ CROSS_BUILD=1 TARGET_ARCH=aarch64 make install
 If you used `ROOTFS_DIR` to prepare in alternative folder,
 you should also give this to makefile.
 ```
-CROSS_BUILD=1 ROOTFS_DIR=/home/user/rootfs/arm64-xenial TARGET_ARCH=aarch64 make
-CROSS_BUILD=1 ROOTFS_DIR=/home/user/rootfs/arm64-xenial TARGET_ARCH=aarch64 make install
+CROSS_BUILD=1 ROOTFS_DIR=/home/user/rootfs/aarch64-xenial TARGET_ARCH=aarch64 make
+CROSS_BUILD=1 ROOTFS_DIR=/home/user/rootfs/aarch64-xenial TARGET_ARCH=aarch64 make install
 ```
index 86c2e9d..ab9d04e 100644 (file)
@@ -1,6 +1,6 @@
 # Cross building for Android
 
-Supported Architecture : ARM64 only (ARM32 is not supported yet)
+Supported Architecture : AARCH64 only (ARM32 is not supported yet)
 
 ## Prepare Android NDK
 
@@ -33,19 +33,18 @@ libarm_compute.so
 ### Build and install the runtime
 
 Some tools/libs are still not supported and those are not built by default - mostly due to dependency on Boost library.
-Please refer to `infra/nnfw/cmake/options/options_arm64-android.cmake` for details.
+Please refer to `infra/nnfw/cmake/options/options_aarch64-android.cmake` for details.
 
 Different from cross build for linux,
 
 - `NDK_DIR` is required
-- `TARGET_ARCH` must be `arm64`, not `aarch64`.
 
 Here is an example of using Makefile.
 
 ```bash
 cp -n Makefile.template Makefile
 
-TARGET_ARCH=arm64 \
+TARGET_OS=android \
 CROSS_BUILD=1 \
 NDK_DIR=/path/android-tools/r20/ndk \
 EXT_ACL_FOLDER=/path/arm_compute-v19.05-bin-android/lib/android-arm64-v8a-neon-cl \
index 8d0a25f..07b4a17 100644 (file)
@@ -13,8 +13,8 @@ Use `build_rootfs.sh` script to prepare Root File System. You should have `sudo`
 ```
 sudo ./tools/cross/build_rootfs.sh arm
 ```
-- supports `arm`(default) and `arm64` architecutre for now
-- supports `xenial`(default) and `trusty` release
+- supports `arm`(default) and `aarch` architecutre for now
+- supports `xenial`(default) `trusty`, and `bionic` release
 
 To see the options,
 ```
@@ -110,18 +110,8 @@ make all install    # do normal build
 TARGET_ARCH = armv7l make all install    # do cross build
 ```
 
-If you want to build neurun, you should switch on `BUILD_NEURUN` option in `cmake/CfgOptionFlags.cmake`
-```
-option(BUILD_NEURUN "Build neurun" ON)
-```
-
 ## Run test
-- PureACL
-```
- ./tests/scripts/test_driver.sh --artifactpath=.
-```
 
-- neurun
 ```
  ./tests/scripts/test_driver.sh --artifactpath=. \
  --frameworktest_list_file=tests/scripts/list/neurun_frameworktest_list.armv7l.acl_cl.txt
index 9313eef..69fe48c 100644 (file)
@@ -1,27 +1,42 @@
 # set host platform to build
 if(NOT HOST_ARCH OR "${HOST_ARCH}" STREQUAL "")
-  set(HOST_ARCH ${CMAKE_HOST_SYSTEM_PROCESSOR})
+  string(TOLOWER ${CMAKE_HOST_SYSTEM_PROCESSOR} HOST_ARCH)
+else()
+  string(TOLOWER ${HOST_ARCH} HOST_ARCH)
 endif()
 
 # set target platform to run
 if(NOT TARGET_ARCH OR "${TARGET_ARCH}" STREQUAL "")
-  set(TARGET_ARCH "${HOST_ARCH}")
+  string(TOLOWER ${CMAKE_SYSTEM_PROCESSOR} TARGET_ARCH)
+else()
+  string(TOLOWER ${TARGET_ARCH} TARGET_ARCH)
 endif()
 
 if(NOT DEFINED HOST_OS)
   string(TOLOWER ${CMAKE_HOST_SYSTEM_NAME} HOST_OS)
+else()
+  string(TOLOWER ${HOST_OS} HOST_OS)
 endif()
 
 if(NOT DEFINED TARGET_OS)
-  set(TARGET_OS "${HOST_OS}")
+  string(TOLOWER ${CMAKE_SYSTEM_NAME} TARGET_OS)
+else()
+  string(TOLOWER ${TARGET_OS} TARGET_OS)
+endif()
+
+# If HOST_ARCH, TARGET_ARCH from CMAKE_HOST_SYSTEM_PROCESSOR, CMAKE_SYSTEM_NAME is arm64
+# Change ARCH name to aarch64
+if("${HOST_ARCH}" STREQUAL "arm64")
+  set(HOST_ARCH "aarch64")
+endif()
+if("${TARGET_ARCH}" STREQUAL "arm64")
+  set(TARGET_ARCH "aarch64")
 endif()
 
 if("${HOST_ARCH}" STREQUAL "x86_64")
   set(HOST_ARCH_BASE ${HOST_ARCH})
 elseif("${HOST_ARCH}" STREQUAL "armv7l")
   set(HOST_ARCH_BASE "arm")
-elseif("${HOST_ARCH}" STREQUAL "arm64")
-  set(HOST_ARCH_BASE "arm64")
 elseif("${HOST_ARCH}" STREQUAL "aarch64")
   set(HOST_ARCH_BASE "aarch64")
 else()
@@ -32,8 +47,6 @@ if("${TARGET_ARCH}" STREQUAL "x86_64")
   set(TARGET_ARCH_BASE ${TARGET_ARCH})
 elseif("${TARGET_ARCH}" STREQUAL "armv7l")
   set(TARGET_ARCH_BASE "arm")
-elseif("${TARGET_ARCH}" STREQUAL "arm64")
-  set(TARGET_ARCH_BASE "arm64")
 elseif("${TARGET_ARCH}" STREQUAL "aarch64")
   set(TARGET_ARCH_BASE "aarch64")
 else()
index ef70574..f014f3e 100644 (file)
@@ -121,11 +121,6 @@ function(_ARMCompute_Build ARMCompute_INSTALL_PREFIX)
     set(BUILD_DIR "${BUILD_ARCH}-${TARGET_OS}.${SCON_BUILD_TYPE}")
   endif()
 
-  if(TARGET_ARCH STREQUAL "arm64")
-    set(BUILD_ARCH "arm64-v8a")
-    set(BUILD_DIR "${BUILD_ARCH}-${TARGET_OS}.${SCON_BUILD_TYPE}")
-  endif()
-
   #### Platform-specific configurations
   #### TODO Support android
 
@@ -3,7 +3,7 @@ include("cmake/buildtool/config/config_linux.cmake")
 # On Android, pthread is contained in bionic(libc)
 set(LIB_PTHREAD "")
 
-# SIMD for arm64
+# SIMD for aarch64
 set(FLAGS_COMMON ${FLAGS_COMMON}
     "-ftree-vectorize"
     )
@@ -20,3 +20,6 @@ set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY NEVER)
 
 # Use the toolchain file that NDK provides
 include(${NDK_DIR}/build/cmake/android.toolchain.cmake)
+
+set(TARGET_OS "android")
+set(TARGET_ARCH "aarch64")
index 8eb9b20..3356aa7 100644 (file)
@@ -11,7 +11,7 @@ set(CMAKE_CXX_COMPILER aarch64-linux-gnu-g++)
 
 # where is the target environment
 set(NNAS_PROJECT_SOURCE_DIR "${CMAKE_CURRENT_LIST_DIR}/../../../../..")
-set(ROOTFS_AARCH64 "${NNAS_PROJECT_SOURCE_DIR}/tools/cross/rootfs/arm64")
+set(ROOTFS_AARCH64 "${NNAS_PROJECT_SOURCE_DIR}/tools/cross/rootfs/aarch64")
 include("${NNAS_PROJECT_SOURCE_DIR}/infra/cmake/modules/OptionTools.cmake")
 
 envoption(ROOTFS_DIR ${ROOTFS_AARCH64})
index 4129cc1..4d5d7ac 100644 (file)
@@ -6,14 +6,14 @@ include(CMakeForceCompiler)
 set(CMAKE_SYSTEM_NAME Linux)
 set(CMAKE_SYSTEM_PROCESSOR aarch64)
 
-set(CMAKE_C_COMPILER   aarch64-linux-gnu-gcc-5)
-set(CMAKE_CXX_COMPILER aarch64-linux-gnu-g++-5)
+set(CMAKE_C_COMPILER   aarch64-linux-gnu-gcc)
+set(CMAKE_CXX_COMPILER aarch64-linux-gnu-g++)
 
 set(TIZEN_TOOLCHAIN "aarch64-tizen-linux-gnu/6.2.1")
 
 # where is the target environment
 set(NNAS_PROJECT_SOURCE_DIR "${CMAKE_CURRENT_LIST_DIR}/../../../../..")
-set(ROOTFS_AARCH64 "${NNAS_PROJECT_SOURCE_DIR}/tools/cross/rootfs/arm64")
+set(ROOTFS_AARCH64 "${NNAS_PROJECT_SOURCE_DIR}/tools/cross/rootfs/aarch64")
 include("${NNAS_PROJECT_SOURCE_DIR}/infra/cmake/modules/OptionTools.cmake")
 
 envoption(ROOTFS_DIR ${ROOTFS_AARCH64})
@@ -1,4 +1,4 @@
-# arm64 android cmake options
+# aarch64 android cmake options
 #
 option(BUILD_ARMCOMPUTE "Build ARM Compute from the downloaded source" OFF)
 # NOTE BUILD_ANDROID_TFLITE(JNI lib) is disabled due to BuiltinOpResolver issue.
index d53a56c..2868e0a 100644 (file)
@@ -9,7 +9,7 @@ You can run with two engines.
 
 ## Build
 
-In addition to arm64-Android build, you need to specify more parameters.
+In addition to aarch64-Android build, you need to specify more parameters.
 
 - `ANDROID_BUILD_TOOLS_DIR` : Android `build-tools` directory (You may find it in Android SDK directory)
 - `ANDROID_SDK_DIR` : Android SDK directory
@@ -21,7 +21,7 @@ In addition to arm64-Android build, you need to specify more parameters.
 Example:
 
 ```bash
-make TARGET_ARCH=arm64 \
+make TARGET_OS=android \
     CROSS_BUILD=1 \
     BUILD_TYPE=RELEASE \
     NDK_DIR=/home/hanjoung/ws/android-tools/r20/ndk \
@@ -44,7 +44,7 @@ Before installing the package you probably need to sign the package.
 ```bash
 apksigner sign \
     --ks ~/.android/debug.keystore \
-    --in Product/arm64-android.release/obj/contrib/android_benchmark_app/android-benchmark.unsigned.pkg \
+    --in Product/aarch64-android.release/obj/contrib/android_benchmark_app/android-benchmark.unsigned.pkg \
     --out tflbench.apk
 ```
 
diff --git a/tools/cross/aarch64/sources.list.bionic b/tools/cross/aarch64/sources.list.bionic
new file mode 100644 (file)
index 0000000..2109557
--- /dev/null
@@ -0,0 +1,11 @@
+deb http://ports.ubuntu.com/ubuntu-ports/ bionic main restricted universe
+deb-src http://ports.ubuntu.com/ubuntu-ports/ bionic main restricted universe
+
+deb http://ports.ubuntu.com/ubuntu-ports/ bionic-updates main restricted universe
+deb-src http://ports.ubuntu.com/ubuntu-ports/ bionic-updates main restricted universe
+
+deb http://ports.ubuntu.com/ubuntu-ports/ bionic-backports main restricted
+deb-src http://ports.ubuntu.com/ubuntu-ports/ bionic-backports main restricted
+
+deb http://ports.ubuntu.com/ubuntu-ports/ bionic-security main restricted universe multiverse
+deb-src http://ports.ubuntu.com/ubuntu-ports/ bionic-security main restricted universe multiverse
index 3aa242b..f6c59b9 100755 (executable)
@@ -4,7 +4,7 @@ set -x
 usage()
 {
     echo "Usage: $0 [BuildArch] [LinuxCodeName] [--setproxy=IP] [--skipunmount]"
-    echo "BuildArch can be: arm(default), arm64 and armel"
+    echo "BuildArch can be: arm(default), aarch64 and armel"
     echo "LinuxCodeName - optional, Code name for Linux, can be: xenial(default), trusty"
     echo "                          If BuildArch is armel, this can be tizen(default)"
     echo "--setproxy=IP - optional, IP is the proxy server IP address or url with portnumber"
@@ -18,7 +18,7 @@ __InitialDir=$PWD
 __UbuntuRepo="http://ports.ubuntu.com/"
 
 __BuildArch=arm
-__UbuntuArch=armhf
+__QemuArch=armhf
 __LinuxCodeName=xenial
 __SkipUnmount=0
 __IsProxySet=0
@@ -44,27 +44,27 @@ for i in "$@" ; do
             ;;
         arm)
             __BuildArch=arm
-            __UbuntuArch=armhf
+            __QemuArch=armhf
             ;;
-        arm64)
-            __BuildArch=arm64
-            __UbuntuArch=arm64
+        aarch64)
+            __BuildArch=aarch64
+            __QemuArch=arm64
             ;;
         armel)
             __BuildArch=armel
             __Tizen=tizen
-            __UbuntuArch=
+            __QemuArch=
             __UbuntuRepo=
             __LinuxCodeName=
             ;;
         tizen)
             if [ "$__BuildArch" != "armel" ]; then
-                echo "Tizen is available only for armel."
+                echo "Tizen rootfs is available only for armel."
                 usage;
                 exit 1;
             fi
             __Tizen=tizen
-            __UbuntuArch=
+            __QemuArch=
             __UbuntuRepo=
             __LinuxCodeName=
             ;;
@@ -112,7 +112,7 @@ if [ $__IsProxySet == 1 ] && [ "$__Tizen" != "tizen" ]; then
 fi
 
 if [[ -n $__LinuxCodeName ]]; then
-    qemu-debootstrap --arch $__UbuntuArch $__LinuxCodeName $__RootfsDir $__UbuntuRepo
+    qemu-debootstrap --arch $__QemuArch $__LinuxCodeName $__RootfsDir $__UbuntuRepo
     cp $__CrossDir/$__BuildArch/sources.list.$__LinuxCodeName $__RootfsDir/etc/apt/sources.list
     chroot $__RootfsDir apt-get update
     chroot $__RootfsDir apt-get -f -y install