Need support to build it for android arm64-v8a

I have successfully compiled the source code with demo main.cpp as a so library and ran that library using unity android. But the compilation works for armbi-v7a but not for arm64-v8a. Because some codes of the cmsis core include are written specific for 32 bit not for 64 bit. So need support for 64 bit so that can compile for all the android devices.

Hi @mmar58,

Thank you for the request. I have passed it on to the engineering team.

Hi Shawn, Do you have updates from the engineering team.
We are facing the same issue with Android for arm64-v8a. Especially now that Android 14 officially only supports 64 bits and have dropped all 32 bits.

Yes, this is what they said:

“We already use XNNPACK on Linux targets which has full HW acceleration on 64-bit Arm.”

So it sounds like you’ll need to use the .eim export for a Linux target to use 64-bit acceleration.

Please pardon me if I am saying anything wrong but XNNPACK used for using HW acceleration on linux running on 64 bit arm and android architecture is different.

More over we are not talking here about hardware or performance issue but we are here discussing for building it for 64 bit platform.

in edge-impulse-sdk\CMSIS\Core\Include\cmsis_compiler.h here is few lines
#if defined ( __CC_ARM )
#include “cmsis_armcc.h”

/*

  • Arm Compiler 6.6 LTM (armclang)
    */
    #elif defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) && (__ARMCC_VERSION < 6100100)
    #include “cmsis_armclang_ltm.h”

/*

  • Arm Compiler above 6.10.1 (armclang)
    */
    #elif defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6100100)
    #include “cmsis_armclang.h”

/*

  • GNU Compiler

Here in the lines you can see it’s defined for 32 bit only, which causing errors when building for 64 bit. May be the headers we are including in here they are also specific written for 32 bit only.

And I want to remind you that before android 14 android platform supported both 32 bit and 64 bit. But from android 14, android removed support for 32 bit. So can’t run 32 bit on the devices that running on android 14 or later.

Please help on this

@mmar58

There are a few points of confusion here I think:

  1. The baseline example that we have is example-standalone-inferencing - this repository should run on anything under the sun, but has no HW acceleration. This builds fine for me against the Android NDK cross compiler for Arm64 (aarch64-linux-android33):
$ CXX=~/Library/Android/./sdk/ndk/27.0.11902837/toolchains/llvm/prebuilt/darwin-x86_64/bin/aarch64-linux-android33-clang++ \
    CC=~/Library/Android/./sdk/ndk/27.0.11902837/toolchains/llvm/prebuilt/darwin-x86_64/bin/aarch64-linux-android33-clang \
    make -j8

... builds fine
  1. For Linux targets that require hardware acceleration we ship GitHub - edgeimpulse/example-standalone-inferencing-linux: Builds and runs an exported impulse locally (Linux) - which links (for general purpose hardware) against the full TensorFlow Lite runtime, which includes XNNPACK and has symbols for Armv7 and Arm64.
1 Like

But I am having these issues when I am trying to build for arm64

./edge-impulse-sdk/CMSIS/Core/Include/cmsis_gcc.h:299:46: error: value size does not match register size specified by the constraint and modifier
      [-Werror,-Wasm-operand-widths]
  299 |   __ASM ("rev %0, %1" : __CMSIS_GCC_OUT_REG (result) : __CMSIS_GCC_USE_REG (value) );
      |                                              ^
./edge-impulse-sdk/CMSIS/Core/Include/cmsis_gcc.h:299:15: note: use constraint modifier "w"
  299 |   __ASM ("rev %0, %1" : __CMSIS_GCC_OUT_REG (result) : __CMSIS_GCC_USE_REG (value) );
      |               ^~
      |               %w0
./edge-impulse-sdk/CMSIS/Core/Include/cmsis_gcc.h:299:77: error: value size does not match register size specified by the constraint and modifier
      [-Werror,-Wasm-operand-widths]
  299 |   __ASM ("rev %0, %1" : __CMSIS_GCC_OUT_REG (result) : __CMSIS_GCC_USE_REG (value) );
      |                                                                             ^
./edge-impulse-sdk/CMSIS/Core/Include/cmsis_gcc.h:299:19: note: use constraint modifier "w"
  299 |   __ASM ("rev %0, %1" : __CMSIS_GCC_OUT_REG (result) : __CMSIS_GCC_USE_REG (value) );
      |                   ^~
      |                   %w1
./edge-impulse-sdk/CMSIS/Core/Include/cmsis_gcc.h:315:48: error: value size does not match register size specified by the constraint and modifier
      [-Werror,-Wasm-operand-widths]
  315 |   __ASM ("rev16 %0, %1" : __CMSIS_GCC_OUT_REG (result) : __CMSIS_GCC_USE_REG (value) );
      |                                                ^
./edge-impulse-sdk/CMSIS/Core/Include/cmsis_gcc.h:315:17: note: use constraint modifier "w"
  315 |   __ASM ("rev16 %0, %1" : __CMSIS_GCC_OUT_REG (result) : __CMSIS_GCC_USE_REG (value) );
      |                 ^~
      |                 %w0
./edge-impulse-sdk/CMSIS/Core/Include/cmsis_gcc.h:315:79: error: value size does not match register size specified by the constraint and modifier
      [-Werror,-Wasm-operand-widths]
  315 |   __ASM ("rev16 %0, %1" : __CMSIS_GCC_OUT_REG (result) : __CMSIS_GCC_USE_REG (value) );
      |                                                                               ^
./edge-impulse-sdk/CMSIS/Core/Include/cmsis_gcc.h:315:21: note: use constraint modifier "w"
  315 |   __ASM ("rev16 %0, %1" : __CMSIS_GCC_OUT_REG (result) : __CMSIS_GCC_USE_REG (value) );
      |                     ^~
      |                     %w1
./edge-impulse-sdk/CMSIS/Core/Include/cmsis_gcc.h:333:48: error: value size does not match register size specified by the constraint and modifier
      [-Werror,-Wasm-operand-widths]
  333 |   __ASM ("revsh %0, %1" : __CMSIS_GCC_OUT_REG (result) : __CMSIS_GCC_USE_REG (value) );
      |                                                ^
./edge-impulse-sdk/CMSIS/Core/Include/cmsis_gcc.h:333:17: note: use constraint modifier "w"
  333 |   __ASM ("revsh %0, %1" : __CMSIS_GCC_OUT_REG (result) : __CMSIS_GCC_USE_REG (value) );
      |                 ^~
      |                 %w0
./edge-impulse-sdk/CMSIS/Core/Include/cmsis_gcc.h:333:79: error: value size does not match register size specified by the constraint and modifier
      [-Werror,-Wasm-operand-widths]
  333 |   __ASM ("revsh %0, %1" : __CMSIS_GCC_OUT_REG (result) : __CMSIS_GCC_USE_REG (value) );
      |                                                                               ^
./edge-impulse-sdk/CMSIS/Core/Include/cmsis_gcc.h:333:21: note: use constraint modifier "w"
  333 |   __ASM ("revsh %0, %1" : __CMSIS_GCC_OUT_REG (result) : __CMSIS_GCC_USE_REG (value) );
      |                     ^~
      |                     %w1
./edge-impulse-sdk/CMSIS/Core/Include/cmsis_gcc.h:981:45: error: value size does not match register size specified by the constraint and modifier
      [-Werror,-Wasm-operand-widths]
  981 |   __ASM volatile ("MRS %0, control" : "=r" (result) );
      |                                             ^
./edge-impulse-sdk/CMSIS/Core/Include/cmsis_gcc.h:981:24: note: use constraint modifier "w"
  981 |   __ASM volatile ("MRS %0, control" : "=r" (result) );
      |                        ^~
      |                        %w0
./edge-impulse-sdk/CMSIS/Core/Include/cmsis_gcc.h:1009:46: error: value size does not match register size specified by the constraint and modifier
      [-Werror,-Wasm-operand-widths]
 1009 |   __ASM volatile ("MSR control, %0" : : "r" (control) : "memory");
      |                                              ^
./edge-impulse-sdk/CMSIS/Core/Include/cmsis_gcc.h:1009:33: note: use constraint modifier "w"
 1009 |   __ASM volatile ("MSR control, %0" : : "r" (control) : "memory");
      |                                 ^~
      |                                 %w0
./edge-impulse-sdk/CMSIS/Core/Include/cmsis_gcc.h:1037:42: error: value size does not match register size specified by the constraint and modifier
      [-Werror,-Wasm-operand-widths]
 1037 |   __ASM volatile ("MRS %0, ipsr" : "=r" (result) );
      |                                          ^
./edge-impulse-sdk/CMSIS/Core/Include/cmsis_gcc.h:1037:24: note: use constraint modifier "w"
 1037 |   __ASM volatile ("MRS %0, ipsr" : "=r" (result) );
      |                        ^~
      |                        %w0
./edge-impulse-sdk/CMSIS/Core/Include/cmsis_gcc.h:1051:42: error: value size does not match register size specified by the constraint and modifier
      [-Werror,-Wasm-operand-widths]
 1051 |   __ASM volatile ("MRS %0, apsr" : "=r" (result) );
      |                                          ^
./edge-impulse-sdk/CMSIS/Core/Include/cmsis_gcc.h:1051:24: note: use constraint modifier "w"
 1051 |   __ASM volatile ("MRS %0, apsr" : "=r" (result) );
      |                        ^~
      |                        %w0
./edge-impulse-sdk/CMSIS/Core/Include/cmsis_gcc.h:1065:42: error: value size does not match register size specified by the constraint and modifier
      [-Werror,-Wasm-operand-widths]
 1065 |   __ASM volatile ("MRS %0, xpsr" : "=r" (result) );
      |                                          ^
./edge-impulse-sdk/CMSIS/Core/Include/cmsis_gcc.h:1065:24: note: use constraint modifier "w"
 1065 |   __ASM volatile ("MRS %0, xpsr" : "=r" (result) );
      |                        ^~
      |                        %w0
./edge-impulse-sdk/CMSIS/Core/Include/cmsis_gcc.h:1079:42: error: value size does not match register size specified by the constraint and modifier
      [-Werror,-Wasm-operand-widths]
 1079 |   __ASM volatile ("MRS %0, psp"  : "=r" (result) );
      |                                          ^
./edge-impulse-sdk/CMSIS/Core/Include/cmsis_gcc.h:1079:24: note: use constraint modifier "w"
 1079 |   __ASM volatile ("MRS %0, psp"  : "=r" (result) );
      |                        ^~
      |                        %w0
./edge-impulse-sdk/CMSIS/Core/Include/cmsis_gcc.h:1107:42: error: value size does not match register size specified by the constraint and modifier
      [-Werror,-Wasm-operand-widths]
 1107 |   __ASM volatile ("MSR psp, %0" : : "r" (topOfProcStack) : );
      |                                          ^
./edge-impulse-sdk/CMSIS/Core/Include/cmsis_gcc.h:1107:29: note: use constraint modifier "w"
 1107 |   __ASM volatile ("MSR psp, %0" : : "r" (topOfProcStack) : );
      |                             ^~
      |                             %w0
./edge-impulse-sdk/CMSIS/Core/Include/cmsis_gcc.h:1133:41: error: value size does not match register size specified by the constraint and modifier
      [-Werror,-Wasm-operand-widths]
 1133 |   __ASM volatile ("MRS %0, msp" : "=r" (result) );
      |                                         ^
./edge-impulse-sdk/CMSIS/Core/Include/cmsis_gcc.h:1133:24: note: use constraint modifier "w"
 1133 |   __ASM volatile ("MRS %0, msp" : "=r" (result) );
      |                        ^~
      |                        %w0
./edge-impulse-sdk/CMSIS/Core/Include/cmsis_gcc.h:1161:42: error: value size does not match register size specified by the constraint and modifier
      [-Werror,-Wasm-operand-widths]
 1161 |   __ASM volatile ("MSR msp, %0" : : "r" (topOfMainStack) : );
      |                                          ^
./edge-impulse-sdk/CMSIS/Core/Include/cmsis_gcc.h:1161:29: note: use constraint modifier "w"
 1161 |   __ASM volatile ("MSR msp, %0" : : "r" (topOfMainStack) : );
      |                             ^~
      |                             %w0
./edge-impulse-sdk/CMSIS/Core/Include/cmsis_gcc.h:1214:45: error: value size does not match register size specified by the constraint and modifier
      [-Werror,-Wasm-operand-widths]
 1214 |   __ASM volatile ("MRS %0, primask" : "=r" (result) );
      |                                             ^
./edge-impulse-sdk/CMSIS/Core/Include/cmsis_gcc.h:1214:24: note: use constraint modifier "w"
 1214 |   __ASM volatile ("MRS %0, primask" : "=r" (result) );
      |                        ^~
      |                        %w0
./edge-impulse-sdk/CMSIS/Core/Include/cmsis_gcc.h:1242:46: error: value size does not match register size specified by the constraint and modifier
      [-Werror,-Wasm-operand-widths]
 1242 |   __ASM volatile ("MSR primask, %0" : : "r" (priMask) : "memory");
      |                                              ^
./edge-impulse-sdk/CMSIS/Core/Include/cmsis_gcc.h:1242:33: note: use constraint modifier "w"
 1242 |   __ASM volatile ("MSR primask, %0" : : "r" (priMask) : "memory");
      |                                 ^~
      |                                 %w0
17 errors generated.
make: *** [C:/Users/USER/AppData/Local/Android/Sdk/ndk/27.0.11718014/build/../build/core/build-binary.mk:422: obj/local/arm64-v8a/objs/test/edge-impulse-sdk/dsp/dct/fast-dct-fft.o] Error 1

Can you tell me how can I resolve the issues

I don’t know. Posting your actual build command and compiler options might help. The command I gave in Need support to build it for android arm64-v8a - #6 by janjongboom works against latest NDK :person_shrugging:

#!/bin/sh
echo ""
echo "Compiling NativeCode.c..."
C:/Users/USER/AppData/Local/Android/Sdk/ndk/27.0.11718014/ndk-build.cmd NDK_PROJECT_PATH=. NDK_APPLICATION_MK=Application.mk $*
# mv libs/armeabi/libnative.so ..

# echo ""
# echo "Cleaning up / removing build folders..."  #optional..
# rm -rf libs
# rm -rf obj

# echo ""
# echo "Done!"

With this command I am compiling using application.mk and android.mk

APP_OPTIM        := release
APP_SHORT_COMMANDS := true
APP_ABI          := arm64-v8a
APP_PLATFORM     := android-21
APP_BUILD_SCRIPT := Android.mk
APP_STL := c++_static    # or c++_shared
NDK_TOOLCHAIN_VERSION := clang
APP_CPPFLAGS := -std=c++17 -fexceptions

this is Application.mk
For armbi-7a it build successfully but not for arm64-8a