Issue while building the project:

Hello,

I was trying to run TFLM custom code on Thingy:53 device and while building I have faced these warnings.

1. Could you please help me to understand Why I am facing these warning?

2. How can I Remove solve these problems?

Regards,

Divya

Parents
  • Hi Divya,

    1. This is telling you that asserts are enabled. If you look through the code files in nRF Connect SDK you will find __ASSERT is used several places. This is used to give a runtime error based on a check. You can read more about this here: Software Errors Triggered in Source Code.

    2. You can disable asserts by setting the following in prj.conf: CONFIG_ASSERT=n

    Best regards,

    Marte

  • Hello Marte,

    Thank you so much for the response. I hope you have noticed that I have updated the question with more warnings while building the code. Could you please help me to solve those issues too!!

  • Thanks for the quick reply.

    Actually I want to add a.cc file in the src folder and then want to call inside the main.c file.

    But it is showing an error that : No Sorce given to the target: app cmake in line 418. So, what should I do to include a .cc file inside main.c file.

    Does calling a C++ file inside a C is really support by Thingy?

    If not then is there any possibilty to build and Flash Thingy with a C++ file like main.cc in place of main.c?

    Regards,

    Divya

  • Hi Divya,

    Are you trying to include the C++ file directly or through a header file? You cannot include source files, so you must include the header file in main.c.

    Also, you cannot use C++ code in C files. If you put a C function (from your C++ file) in an extern "C" block in your header file, then you can use it in your C file, but you cannot use C++ classes and many other C++ features in a C file. If you search online you will be able to find a lot of information about this, and about how to use extern "C". If you want to use C++ features then you should have your main file as a C++ file instead of C. This is for example done for Matter samples in nRF Connect SDK, so you can look there for examples (nrf/samples/matter).

    Best regards,

    Marte

  • Hello Marte,

    I have followed the same solution as you have mentioned above, I will explore more about the matter example. Thank you for sharing.

    Now after adding C++ header file along with other header files I am facing some issues. it seems like I am not able to add libraries from other folder.

    So, I have cloned a repository inside the src directory in a separate folder named tensorflow inside "src" and it is showing me the error like:

    As you mentioned earlier I can add all the extra file in the CMakelist.txt. So, I have added them like:

    can you please help me why I am not able to access the header file inside the tensorflow folder? I have checked and verified that these files are at the mentioned location.

    Regards,

    Divya

  • Hello Marte, 

    I guess I might know the problem now but still I am confuse with adding the a folder inside src folder. 

    I followed the steps as mentioned in this link here:

    devzone.nordicsemi.com/.../392032

    but the problem is still not resolved. I can not access the folder that I have added inside the src.

    Do you think writing the CMakelist like this is fine?

    Regards,

    Divya

  • Hi Divya,

    You need to add the actual path to the source files and to the directory where the header file is. Additionally, you should not add the header files to target_sources, only the source files. For the header files you should add the directory they are in to zephyr_include_directories.

    For example:

    target_sources(app PRIVATE
        src/main.c
        src/tensorflow/lite/micro/micro_error_reporter.cc
        src/tensorflow/lite/micro/micro_interpreter.cc
        src/tensorflow/lite/schema/schema_generated.cc
    )
    
    zephyr_library_include_directories(
        src/tensorflow/lite/micro
        src/tensorflow/lite/schema
    )

    Here I have just guessed the file names and paths from your pictures to give you an example. You must use the actual file names and paths of your files.

    With this you only need the filename in the #include in your main file, and not the whole path:

    #include "micro_error_reporter.h"

    #include "micro_interpreter.h"

    etc.

    Best regards,

    Marte

Reply
  • Hi Divya,

    You need to add the actual path to the source files and to the directory where the header file is. Additionally, you should not add the header files to target_sources, only the source files. For the header files you should add the directory they are in to zephyr_include_directories.

    For example:

    target_sources(app PRIVATE
        src/main.c
        src/tensorflow/lite/micro/micro_error_reporter.cc
        src/tensorflow/lite/micro/micro_interpreter.cc
        src/tensorflow/lite/schema/schema_generated.cc
    )
    
    zephyr_library_include_directories(
        src/tensorflow/lite/micro
        src/tensorflow/lite/schema
    )

    Here I have just guessed the file names and paths from your pictures to give you an example. You must use the actual file names and paths of your files.

    With this you only need the filename in the #include in your main file, and not the whole path:

    #include "micro_error_reporter.h"

    #include "micro_interpreter.h"

    etc.

    Best regards,

    Marte

Children
  • Okay, I have followed the instruction and updated the CMakelist like this:

    but the problem is still the same:

    Where am I doing the mistake?

    Regards.

    Divya

  • Hello Marte,

    Ok, so there are two things.

    So, The above error I have mentioned are from from main_function.cc file not from the main.c file.

    Somehow it is not showing the error when I include the whole path for few files:

    but it is still showing the error for the file saved inside the tensorflow folder:

     

    Other point, When I checked the main.c file then I have noticed it also has the main_function.h inside it. But even after adding the directory for the header file the problem is still the same for main.c file as well.

    So, again when I am keeping the whole path and then it is not showing the error:

    I have kept all the required header files inside the folder name extra_files.

    I do not know what is wrong with the calling of header files.

    It seems like that CMakelist file is not adding any folder.

    because even if I made a blank folder and then tried including that inside the directory I can not see that blcnk folder too. So i guess it is something wrong with CMakelit but again I do not understand what it is.

    Regards,

    Divya

  • Hi Divya,

    Have you tried building the project? Do you actually get errors with that the files cannot be found when building the project?

    The errors you are showing here are not from the build, but from the C/C++ Intellisense extension in VS Code. They just mean that Intellisense is not able to find the files, but Intellisense has nothing to do with the building of the project.

    Best regards,

    Marte

  • Hello Marte,

    I have tried to do some changes and then try to build the project.

    The build is still not able to identify the tensorflow folder inside the include folder so the build is failing all the time.

    Also, I have another question is that, I have noticed that there is already a folder inside the ncs-v2.1.2:

    C:\Users\DIVYA\ncs-v2.1.2\v2.1.2\modules\lib\tflite-micro\tensorflow\lite\micro

    Because I am trying to add this path in the code:

    Then it is showing me an error like:

    That is the same folder I want to call inside my code. SO, is there any possibility if I can call the files from this folder to my project code?

    Regards,

  • Hi,

    Please try using the following paths instead

    #include "tensorflow/lite/micro/micro_error_reporter.h"
    #include "tensorflow/lite/micro/micro_interpreter.h"
    #include "tensorflow/lite/schema/schema_generated.h"
    #include "tensorflow/lite/micro/all_ops_resolver.h"

    Best regards,

    Marte

Related