Compiling for Teensy 4.1

Hello,

I’'m running into a problem with compiling my Edge Impulse model for the Teensy 4.1. It is running file on the Arduino Nano 33 BLE Sense.

This is the error I get:

In file included from src/edge-impulse-sdk/CMSIS/Core/Include/cmsis_compiler.h:54:0,
             from src/edge-impulse-sdk/CMSIS/DSP/Include/arm_math.h:382,
             from src/edge-impulse-sdk/dsp/spectral/../numpy.hpp:37,
             from src/edge-impulse-sdk/dsp/spectral/processing.hpp:28,
             from src/edge-impulse-sdk/dsp/spectral/spectral.hpp:27,
             from src\edge-impulse-sdk/classifier/ei_run_dsp.h:27,
             from src\edge-impulse-sdk/classifier/ei_run_classifier.h:30,
             from src\main.cpp:6:
src/edge-impulse-sdk/CMSIS/Core/Include/cmsis_gcc.h:196:44: error: macro "__enable_irq" passed 1 arguments, but takes just 0
 __STATIC_FORCEINLINE void __enable_irq(void)
                                        ^
src/edge-impulse-sdk/CMSIS/Core/Include/cmsis_gcc.h:207:45: error: macro "__disable_irq" passed 1 arguments, but takes just 0
 __STATIC_FORCEINLINE void __disable_irq(void)
                                         ^
Compiling .pio\build\teensy41\FrameworkArduino\usb_serial3.c.o
Compiling .pio\build\teensy41\FrameworkArduino\usb_touch.c.o
Compiling .pio\build\teensy41\FrameworkArduino\yield.cpp.o
src/edge-impulse-sdk/CMSIS/Core/Include/cmsis_gcc.h:196:27: error: variable or field '__enable_irq' declared void
 __STATIC_FORCEINLINE void __enable_irq(void)
                       ^
src/edge-impulse-sdk/CMSIS/Core/Include/cmsis_gcc.h:41:50: error: expected primary-expression before '__asm'
   #define __ASM                                  __asm
                                              ^
src/edge-impulse-sdk/CMSIS/Core/Include/cmsis_gcc.h:198:3: note: in expansion of macro '__ASM'
   __ASM volatile ("cpsie i" : : : "memory");
   ^
src/edge-impulse-sdk/CMSIS/Core/Include/cmsis_gcc.h:41:50: error: expected '}' before '__asm'
   #define __ASM                                  __asm
                                              ^
src/edge-impulse-sdk/CMSIS/Core/Include/cmsis_gcc.h:198:3: note: in expansion of macro '__ASM'
   __ASM volatile ("cpsie i" : : : "memory");
   ^
src/edge-impulse-sdk/CMSIS/Core/Include/cmsis_gcc.h:207:27: error: variable or field '__disable_irq' declared void
 __STATIC_FORCEINLINE void __disable_irq(void)
                       ^
src/edge-impulse-sdk/CMSIS/Core/Include/cmsis_gcc.h:41:50: error: expected primary-expression before '__asm'
   #define __ASM                                  __asm
                                              ^
src/edge-impulse-sdk/CMSIS/Core/Include/cmsis_gcc.h:209:3: note: in expansion of macro '__ASM'
   __ASM volatile ("cpsid i" : : : "memory");
   ^
src/edge-impulse-sdk/CMSIS/Core/Include/cmsis_gcc.h:41:50: error: expected '}' before '__asm'
   #define __ASM                                  __asm
                                              ^
src/edge-impulse-sdk/CMSIS/Core/Include/cmsis_gcc.h:209:3: note: in expansion of macro '__ASM'
   __ASM volatile ("cpsid i" : : : "memory");
   ^
src/edge-impulse-sdk/CMSIS/Core/Include/cmsis_gcc.h:210:1: error: expected declaration before '}' token
 }
 ^

Can someone help me out with this?

Hi @Jurg, looks like another version cmsis_gcc.h is already in your build path. Are you building with the Arduino IDE using the Teensyduino extension?

Building works for me on Arduino 1.8.13 / Teensy 4.1

Ok, deploying a new model results in similar issues you are experiencing. Our SDK depends on the math functions in cmsis_gcc.h where also functions for enabling / disabling the interrupts are declared. The Teensy has declared those functions as macro inside the processor header file (imxrt.h).

A quick fix would be to check if the macro already exist in cmsis_gcc.h like:

/**
  \brief   Enable IRQ Interrupts
  \details Enables IRQ interrupts by clearing the I-bit in the CPSR.
           Can only be executed in Privileged modes.
 */
#ifndef __enable_irq
__STATIC_FORCEINLINE void __enable_irq(void)
{
  __ASM volatile ("cpsie i" : : : "memory");
}
#endif


/**
  \brief   Disable IRQ Interrupts
  \details Disables IRQ interrupts by setting the I-bit in the CPSR.
           Can only be executed in Privileged modes.
 */
#ifndef __disable_irq
__STATIC_FORCEINLINE void __disable_irq(void)
{
  __ASM volatile ("cpsid i" : : : "memory");
}
#endif

You can find the file in the extracted library folder: src/edge-impulse-sdk/CMSIS/Core/Include/cmsis-gcc.h

The #ifndef's dit it for me. My code only compiled on an hourly build of the Arduino IDE (1.8.14), (The filename or extension is too long on IDE 1.8.13). Thank you so much for helping me out!

1 Like

@Jurg thanks for reporting back, we’re evaluating a patch in the SDK to deal with this, so you don’t have to patch your core - just need to make sure this does not have any unintended consequences on other dev boards.