I understand that CMSIS-NN, allows integration of machine learning (neural-networks) using ARM Cortext M processors.
I have been struggling to #include the <arm_nnfunctions.h> header file based found in the original pack ARM CMSIS-5 library.
I tried multiple things but they didn’t work.
Appreciate the help.
Please upload the current state of your PlatformIO project to github or somewhere else so that we can see what multiple things you tried and we can reproduce them.
Apologies for not doing this in my basic post.
- ARM board: STM32 L476VG
- Selected mbed as the framework when creating PlatformIO project as that was the only option for this board
- As CMSIS-NN was not detected by the PlatformIO ‘Libraries’ search feature, downloaded the ARM.CMSIS.5.4.0 folder structure and stored on my hard-drive (Ref. image.1)
Here are the things I tried in order as none of them worked:
- Modified the c_cpp_properties.json file (.vscode project folder) to include the path that had arm_nnfunctions.h (Image.2)
- Within the platformio.ini, used PlatformIO lib_deps option to list the dependent libraries by listing the folders where arm_nnfunctions.h was stored (Image.3)
- Went back to using the Libraries feature (Image.4). It was able to find the CMSIS Core library and when that didn’t work, also tried loading the CMSIS DSP. With this I was hoping that the basic functions will be found.
- Finally, I changed the board to another board, which allowed choosing the cmsis as the framework when using the PlatformIO New-Project dialog box
[I later realized as a new user I can only upload one image]
This will surely make VSCode see that include path, but the compilation process will not see it unless you add
build_flags = -I lib/ARM.CMSIS.5.3.0/CMSIS/NN/Include -I .... in your
platformio.ini . Can you just quickly upload the project to github or google drive?
Firstly thank you for taking up this issue and helping.
Google Drive upload > Link
So I tried all day - unfortunately it still does not work
I looked up the build_flags documentation and I even tried other flags after trying the “-I” flag you suggested.
I tried the following two flags:
And also a include flag with the absolute path.
Please find error output that I keep getting eblow:
Hi Max @maxgerhardt
Hope you are able to see my earlier post (with Google drive upload and images). I had a lot of trouble connecting with this page (and entire forum) earlier in the day.
Of course if you have seen the post - please ignore this post - don’t mean to bother you. Just hoping you can help me out.
I compiled the program and will test on the board in another 6-7 hours time and give you an update. The good news is that it compiled without errors! It was able to find the headers.
Thank you so much for taking this up.
I did try connecting the card and downloading the successfully compiled code. However it gave the error (image below).
I tried to look for where this 500 Hz setting is - but I did not find it.
I then tried to see what the difference in your project set up was against my very simple program and spotted the CMSIS_NN folder. I picked it up as in and pasted in my project and that compiled successfully and also downloaded the firmware.
Is the error below related to Serial connection? The board I use - I do not need to do any of that and I am able to simply put a printf() and it shows in my Serial.Monitor.
If you help me with where I can change the settings/code I will do that and retry downloading your compiled code and give you an update.
Once again - Thank you very much for helping.
upload_protocol = stlink line from pio-cmsis-nn/platformio.ini at master · maxgerhardt/pio-cmsis-nn · GitHub and retry please. What upload method is it using in your project where the upload is working?
Okay so great the CMSIS-NN library is working The baud rate of the my example (which is exactly ARM’s cifar10 example) is at 115200 baud, not 9600. So I wanted to see if the ARM example is able to run on the board. But if the library works for you, it’s all done I guess.
Can you please confirm then - that copying the CMSIS-NN folder into the project structure is what solved it?
Mighty thanks for all the help Max!
Yes exactly. Starting from CMSIS_5/CMSIS/NN at develop · ARM-software/CMSIS_5 · GitHub, I created a new lib folder
include/ files from
src/ file from
Source/. That way the library headers are found automatically and there’s no need to hack include flags or library dependencies or something. Note that CMSIS-NN depends on
CMSIS-DSP, which mbed-os has (here). When using this without mbed-os one must create / copy the CMSIS-DSP library, too.
Ok then Max - thank you Have a good day!