Issue working with "ml-edgeimpulse-project-builder"

Hi there,

My recent project is trying to integrate the machine learning model trained on the Edge Impulse with my existing project developed in MPLAB (ver. 6.0.0) with xc32-gcc (ver.4.2.0).

The MCU I am using is ATSAMD21J16B.

I was generally following this two instructions:

I so far I was able to use docker to build the Edge Impulse model that is supposedly ready to be integrated to the MPLAB project.

However, when I try to compile the library with the project, I ran into the following issue:

…/src/ML/edge-impulse-sdk/dsp/numpy.hpp:32:10: fatal error: cfloat: No such file or directory
#include <cfloat>
^~~~~~~~
compilation terminated.
make[2]: *** [build/default/production/_ext/818654064/drv_usbfsv1_device.o] Error 255
make[2]: *** Waiting for unfinished jobs…

After some google search, it seems like cfloat is obsolete now, which is unfortunate considering the “ml-edgeimpulse-project-builder” repo was last updated a year ago.

I was assuming, the repo is pretty up to date and should be pretty “plug and play” sort to speak.

Has anyone work with " “ml-edgeimpulse-project-builder”, would you shed some lights please?

Could it be the issue with the edge impulse library or something to dig more with MPLAB?

Appreciate any insights, thanks in advanced.

Cheers,
Jordan

Hi @lhjordanlh

Thanks for informing us, I’m not aware of this project builder integration. Checking with our technical team.

Are you trying to change the compiler settings in MPLAB? If you are unable to get the correct compiler version to run in MPLAB with the version that project is expecting, you may be best to ask the question on their git repo.

Best,

Eoin

Hi @lhjordanlh

As we wait to see if there is any further info please try updating your compiler in MPLAB. Follow the steps here: Configuring Project Build Options - Developer Help

Let me know if this resolves your issue, and if you get any help on their forum please link back here. Thanks!

Best

Eoin

Hi Eoin,

Thanks for your reply. After more digging and messing around, it doesn’t seem to solve the issue.
First of all, the document you shared with me is obsolete with the latest version of MPLAB. This one seems to be the more updated version: https://ww1.microchip.com/downloads/aemDocuments/documents/DEV/ProductDocuments/UserGuides/MPLAB-XC32-Compiler-UG-PIC32C-DS-50002895.pdf
However, it doesn’t seem to have other options for 32 bits compilers that I can use. I then tried using old ATMEL Arm compiler toolchain 6.3.1 and it doesn’t help the case either: Build MPLAB Harmony v3 project with ARM GCC toolchain in MPLAB X IDE | Microchip MPLAB Harmony Quick Documentation help

When manually linking the , multiple other files are also missing.

Does EdgeImpulse have a tutorial or other resources to help integrating ML model outputted from your platform to work with MPLAB ver 6.XX with ATSAM series MCU?

cheers,
Jordan

Hi @lhjordanlh

No we don’t yet unfortunately, I’ve checked with the tech team and we are only learning of this integration.

I’m not very familiar with microchip and their IDE/SDK. Tried following along with the setup with a fresh project, but didn’t hit the same problem. (if anyone else is reading this with microchip experience and wants to give advice please do)

I installed 6.15 and the only thing I noticed was their command needs to be updated to specify the version 6.15 etc you install for the SDK/IDE. Other than that I cant really give much else here.

MPLABX_VERSION=6.15 XC_VERSION=4.00 XC_NUMBER_BITS=32 ./build.sh ATSAME54P20A libedgeimpulse .

Did you try asking on their forum or the git repo?

Best

Eoin

Hi Eoin,
Thanks for you efforts.
When you say you haven’t encountered the same issue, were you able to compile the example project in MAPLAB?

What other resources would you recommend if I were to integrate model generated from Edge Impulse with MPLAB?

I have filed an issue in the repo and also posted on the forum, I have not heard back from Microchip yet.

Cheers,
Jordan

Hi Eoin,

I have not heard back from you, but I have in fact inquired with Microchip and was told that the builder is not up to date.

It seems like they recommend using their own ML training platform: https://www.microchip.com/en-us/tools-resources/develop/mplab-machine-learning-development-suite and ask us to ditch Edge Impulse all together.

However, we already have the setup and are still interested in deploying the model to our existing MCU if possible. Do you have other resources or recommendation for us to build the model with our MCU without their build tool?

Cheers,
Jordan

Hi Eoin,

Not sure if you are still able to look a little bit further into this issue.

I was trying to just run the model in Arduino Nano 33 BLE, and run into the following issue:

C:\Users\lhjor\AppData\Local\Temp\arduino\sketches\EC5BB9A52BCFE2A5CE49941D702B8F24\sketch\objs.a(static_buffer.ino.cpp.o):(.data.ei_dsp_blocks+0x2c): undefined reference to `extract_swipe_features_extraction_features(ei::ei_signal_t*, ei::ei_matrix*, void*, float)’
collect2.exe: error: ld returned 1 exit status

Using library SWIPE_Detection_inferencing at version 1.0.5 in folder: C:\Users\lhjor\Documents\Arduino\libraries\SWIPE_Detection_inferencing
exit status 1

Compilation error: exit status 1

Do you have any clue why? Is there something wrong about the library itself?

Cheers,
Jordan

Hi @lhjordanlh

Let me check into the nano one for you first, as I don’t have any hardware to fully test the Microchip integration.

Arduino Nano

You need to copy and paste your raw features into the Raw features array e.g.:

Click on the ‘Copy to clipboard’ button next to ‘Raw features’. On the processing This will copy the raw values from this validation file, before any signal processing or inferencing happened.

static const float features[] = {
    -19.8800, -0.6900, 8.2300, -17.6600, -1.1300, 5.9700, ...
};

You can read more on developing for the nano in this guide:

Microchip Integration

Hopefully we can hear from them officially. As we open up the possibility to build Edge AI solutions for all vendors and architectures. It would be great to have their integration working. I tested the MAPLAB integration by following the instructions to try to get the same error as you had, but couldn’t hit it. Possibly the pathway, different OS, or lack of hardware.

In the meantime perhaps we can troubleshoot it a bit deeper, I have created a fork of that repo we can debug on:

There are some build args that are not honoured throughout the running of the docker command, which need to be updated if you change the MPLAB version from the one in the script e.g. MPLABX_VERSION when changed does not update the wget command later used by the docker container:

MPLABX_VERSION=**6.15** XC_VERSION=4.00 XC_NUMBER_BITS=32 ./build.sh ATSAME54P20A libedgeimpulse .

=> CANCELED [ 3/13] RUN wget -qO /tmp/mplabx-installer.tar “http://ww1.microchip.com/downloads/en/DeviceDoc/MPLABX-**v6.00**-linux-installer.tar” & 0.4s

Perhaps you can verify these parameters are all correct for your system, and we can update accordingly.

Best

Eoin

1 Like

Hi Eoin,

I have opened a technical support case with Microchip, and they have been trying to help us to get your C++ generic library to work with their IDE as well, but with no avail.
The latest message I got from Microchip is:

There is still an error in compilation with this project due to the source code from the Edge Impulse SDK. We recommend you ask Edge Impulse about this error.

     In file included from ../src/edge-impulse-sdk/classifier/ei_fill_result_struct.h:25,

     from ../src/edge-impulse-sdk/classifier/inferencing_engines/tflite_eon.h:26,

     from ../src/edge-impulse-sdk/classifier/ei_run_classifier.h:41,

     from ../src/main.cpp:27:

     ../src/model-parameters/model_variables.h:95:1: error: converting overloaded function 'extract_swipe_features_extraction_features' to type 'int (*)(ei::signal_t*, ei::matrix_t*, void*, float)' {aka 'int (*)(struct ei::ei_signal_t*, struct ei::ei_matrix*, void*, float)'} is ambiguous

I wonder if that is indeed something to do with EI library missing some files?

If we can’t get this to work this week, we will have no other option but to try Microchip’s own Machine Learning Development Suite…

Best,
Jordan

Hi @lhjordanlh

I’m currently in the process of writing documentation for this Microchip integration you can review. I will PM you a link. Be aware its work in progress, and will be updated to reflect the following, and what we discover in this thread.

Can you send me some detail on your company, and the time sensitive project? Perhaps we can set up time with one of our solutions engineers for you.

The project library / SDK / build.sh script appears to be outdated
It would appear that the project built in the shared error was either exported long ago, or is using an older SDK. They need to rebuild and export a current build of the project library, and update the build.sh script.

ml-edgeimpulse-project-builder/build.sh needs to be updated

Needs to include the latest as you can see in that file it mentions the list is pulled directly from the example-stand-alone-inferencing example. That list includes model-parameters which is what appears to have caused the overloaded function call error. The list of included files also should now be longer, I have updated the list in the fork here:

Edge Impulse’s New Features
We recently added a new features to our product for multi parameter models etc:

Development OS - Only Linux/Ubuntu was Tested, OSX, Windows needs modification / manual installation
Finally I realise now that from what was shared so far appears like you are using a linux based system, but you may be using an incompatible type for the dockerfile in this repository. They have hard coded many paths to make this work for Linux and Linux 64 based OS’s. When in fact on Mac they should be pulling the .dmg for the installer etc. This is something I will note in the documentation.
e.g. .run is included in the url where the IDE and compiler installer is pulled from instead of .dmg for users on Mac OSX

On the call we can manually go through this, and get your integration / installation set up if it is for OSX or Windows.

Best

Eoin

1 Like

Hi Eoin,

I have sent an email to your work email.

Cheers,
Jordan

Hi @Eoin and @brianmcfadden ,

Just a little bit of an update. Microchip seems to be certain that the issue lies with the EI sdk.

Here is the latest response I got:

Error is specific to one of the edge impulse-generated functions in the model_variable.h file. I am checking internally regarding this issue.

In the meantime, please check with the edge impulse team as well, I think this is a better way to get a solution faster to this issue.

In case the above information can be useful somehow.

Cheers,
Jordan

Hi @lhjordanlh

From the previous observation it seems that it’s an older version of our SDK, as is listed in the github comments.

They hard coded a list of our libraries rather than pulling in the contents of the folder.

Best

Eoin