ESP32 Compile Errors

I’m trying to run a keyword recognition example (The Static buffer example) on an ESP32, in particular the MH ET LIVE MiniKit:

I built an impulse following the tutorial and downloaded it. It compiles for the Arduino Nano 33 BLE Sensor. (I don’t have a Nano 33 - yet). When I compile for the ESP32 I get the following compile errors:

…NNSupportFunctions\arm_nn_accumulate_q7_to_q15.c:57:22: error: implicit declaration of function ‘__PKHTB’ [-Werror=implicit-function-declaration]
vo2 = (q31_t)__PKHTB(v1, v2, 16);
^
vo1 = (q31_t)__PKHBT(v2, v1, 16);
^
cc1.exe: some warnings being treated as errors

I’m using Arduino 1.8.15 and installed the ESP32 board manager from:
https://dl.espressif.com/dl/package_esp32_index.json

I get the same error when I choose any of the following boards:
MH ET LIVE ESP32MiniKit
MH ET LIVE ESP32DevKit
WEMOS D1 MINI ESP32

I see other people have successfully run on an ESP, so I suspect I’m overlooking something simple.
Can someone point me in the right direction?

Thanks!

Doug

As I know, esp32 is based on xtensa core, and maybe, i guess, EPON compiler has not cover the backend of xtensa.
As you mention, it’s might be a warning from a symbol your code not reference, you can try treat this warning not as error, and compile again to see the result.

Yes, I don’t understand why it is compiling for ARM - I specified ESP boards, and the compiler command line flags say ESP, not ARM. I will see if I can get the Arduino IDE to ignore the error.

@DougK @huntershuai We use CMSIS-DSP for all DSP code, but it has fallbacks for code on non-ARM systems. I wonder if adding this on top of your sketch works:

  /**
   * @brief definition to pack two 16 bit values.
   */
  #define __PKHBT(ARG1, ARG2, ARG3) ( (((int32_t)(ARG1) <<    0) & (int32_t)0x0000FFFF) | \
                                      (((int32_t)(ARG2) << ARG3) & (int32_t)0xFFFF0000)  )
  #define __PKHTB(ARG1, ARG2, ARG3) ( (((int32_t)(ARG1) <<    0) & (int32_t)0xFFFF0000) | \
                                      (((int32_t)(ARG2) >> ARG3) & (int32_t)0x0000FFFF)  )


  /*
   * @brief C custom defined SADD16 (by Edge Impulse)
   */
  __STATIC_FORCEINLINE uint32_t __SADD16(
  uint32_t x,
  uint32_t y)
  {
    q31_t r, s;

    r = (((((q31_t)x << 16) >> 16) + (((q31_t)y << 16) >> 16))) & (int32_t)0x0000FFFF;
    s = (((((q31_t)x      ) >> 16) + (((q31_t)y      ) >> 16))) & (int32_t)0x0000FFFF;

    return ((uint32_t)((s << 16) | (r      )));
  }

This code is already in the SDK (edge-impulse-sdk/CMSIS/DSP/Include/dsp/none.h) but guarded by some macros. I wonder if we should refine these for ESP32.