Undefined reference to `_impure_ptr'

I’m trying to run an edge impulse model locally on the Spresense board using the tutorial in the link below.

Whenever I try to compile the code, I run through the following error:

C:\Program Files (x86)\GNU Tools ARM Embedded\8 2018-q4-major\bin\arm-none-eabi-ld.exe: c:/program files (x86)/gnu tools arm embedded/8 2018-q4-major/bin/../lib/gcc/arm-none- eabi/8.2.1/../../../../arm-none-eabi/lib/thumb/v7e-m+fp/hard/libstdc++.a(vterminate.o): in function '__gnu_cxx::__verbose_terminate_handler()': vterminate.cc:(.text._ZN9__gnu_cxx27__verbose_terminate_handlerEv+0xf4): undefined reference to '_impure_ptr' Memory region Used Size Region Size %age Used ram: 420408 B 1536 KB 26.73% make: *** [Makefile:230: build/firmware.elf] Error 1

I’m using a Windows 10 OS, running “MSYS2 MSYS” to compile the code.

I made sure that I have “GNU ARM Embedded Toolchain 8-2018-q4-major” installed using the link provided in the tutorial:

I made sure that I only have 1 GNU ARM Embedded Toolchain installed in my system and I also have tried running the command

$ CROSS_COMPILE=~/toolchains/gcc-arm-none-eabi-8-2018-q4-major/bin/arm-none-eabi- make -j

as instructed in the README file for the specified error mentioned above.

Can someone help out with this issue? Thank you

Hi @OutlandAdmin,

I’ve just tried replicating the issue with MSYS2 MSYS and was not able to reproduce the issue.

  • I installed it and followed steps up to 8.
  • Installed GNU ARM Toolchain 8-2018-q4-major.
  • Cloned the latest https://github.com/edgeimpulse/firmware-sony-spresense.
  • NOTE: Makefile does not handle paths with spaces well (this will be patched soon) so ensure that the location where the firmware was cloned does not contain spaces (or special characters) otherwise " " variables in Makefile appropriately.

Then I build the application successfully (similarly like you):

make clean
CROSS_COMPILE=/c/Program\ Files\ \(x86\)/GNU\ Tools\ ARM\ Embedded/8\ 2018-q4-major/bin/arm-none-eabi- make -j

Here’s the output of $PATH:

$ echo $PATH

Hi @rjames,

Thank you for the reply. I apologize for not specifying which repository I am working on.
I cloned the repository https://github.com/edgeimpulse/example-standalone-inferencing-spresense

The code does build successfully at first. However, as soon as I add the raw data into the features[] variable in ei_main.cpp line 28 that matches with the size of the window from my edge impulse model as specified in the tutorial from

The code runs through the error I mentioned earlier. Any other size (or empty) the variable holds would maker the code successfully build, but fail to run through the classifier.

I confirmed that my PATH is the same and have compiled in the same way as you did using CROSS_COMPILE.

I also made sure that the paths don’t contain any spaces / special characters.

I’m not sure what else I can do.

Hi @OutlandAdmin,

I was able to build and run the example standalone successfully with raw features copied from Live Classification page.

Can you mentioned which error you get when run the classifier?
Can you share your project ID so we can take a better look.

Hi @rjames,

I tested the example standalone with raw features and it also successfully worked on my end. I’m wondering if the model we created is the problem. The project ID is 52615. Would you be able to check the example standalone with our project to make sure the error is occurring from the model and not the code? Thank you.

Hi @OutlandAdmin

I’m able to reproduce the issue with your model and example-standalone-inferencing-spresense firmware.

I’ve yet to find a solution but a work-around is to decrease your window size < 2500 ms.
2500 ms at 16 kHz results in 40000 features in the feature array. This seems to cause this issue with the spresense build system. I don’t see this occuring with other standalone examples (e.g. example-standalone-inferencing or example-standalone-inferencing-ti-launchxl).

In the meantime will track this bug. I hope this helps.

// Raul

I have a patch/fix.
Do you mind giving this a try: https://github.com/edgeimpulse/example-standalone-inferencing-spresense/tree/fix-impure-ptr ?

Hey @rjames,

I checked out your patch/fix and I managed to get it working on my end. Thank you for your help.