I’m working on the FreeRtos projects for BLE in C and after some long hours got everything to work. I was curious to know if you have an example that uses this C based project and incorporates into a tensorFlow demo project. I’m not sure if I am forced to convert all my .C filed to .CC. Any help would be appreciated, thanks!
HI there! .cc is the extension that the tensorflow team chose for C++ files while .c is used for C files (as in the FreeRTOS examples).
C and C++ play fairly well together - you mostly need to be aware of the potential for [name-mangling.
To make the projects work together you will probably have to modify the build process significantly (to make sure all your various source files are accounted for).
Often the compiler that you use (e.g. GCC) will be able to distinguish C / C++ files by the extension. It will compile that ‘compilation unit’ into machine code. When all your C / C++ units are compiled into machine code they can be ‘linked’ which is basically cross-referencing to make sure all the necessary variables / functions exist.
So… long story short you should not have to ‘convert’ any source files - but you will need to make your own build system that incorporates all the source files that you need. You can do this with a custom makefile using the makefiles from TensorFlow and the FreeRTOS examples as guides](Name Mangling and extern "C" in C++ - GeeksforGeeks)
I see, I think that makes sense, I will try this out. As a little nudge in the right direction, what do you suggest I try as a starter project that integrates a main.c that has MLModels.cc files that the program utilizes.
I have been trying to do what you explained but came into some gaps of knowledge, if you would, could you explain where binaries fit into the equation? More specifically, I am crossreferencing the tensorflow_demo Makefile to the example1_edge_test Makefile. I added all the src files of the example1_edge_test to the tensorflow_demo but I’m not sure what the binarys are and how they fit with loading to the sparkfun edge? There’s three (two from loading, one from the tensorflow_demo I believe) I have everything the exactly the same in the Makefiles except for lines 177-185 on the left side (Changed tensor flow) as seen in the picture below.
I think I sort of understand that this binary is an already compiled program ready to be loaded so I guess I couldn’t try to load another program (with a seperate main) but what exactly happens when I comment out lines 177-180? In other words, I’m having trouble reading the Makefile syntax and what it does to the old binary that is currently present in tensorFlow_demo project. I hope my question isn’t too confusing. Any information would be of great use!
First of all I am afraid that the image you attached has come through with a very low resolution - I can’t read it at all. You could try using code tags to call out the lines you are talking about.
I would suggest trying to build your own makefile project that has both a ‘main.c’ file and some functions written in a .cc file to get a feel for it - take a step back from the TensorFlow project for the time being. I suggest that because the TensorFlow makefile is quite complicated. It would be good to get a grip on ‘make’ in a less complicated environment.
You are correct - the binaries are not ‘merged’ with new sources. Instead they are regenerated every time by the build process. There is a step that behaves similarly to that, though. Before the final binaries (.elf, .axf, or .bin) are generated each compilation unit has a corresponding object file (.o). All the object files are linked together to make the final binary. It is that step in which you can regenerate or add just one of many small components. It is also possible to save object files in a format that I know as an ‘archive’ (.a extension) which are generally meant to be distributed so that a library or some functionality can be used without needing to be compiled.
I don’t have a particular recommendation but there are many sources online that can explain make and the build process much better than I.
I apologize for the photo, I believe my original photo might have compressed, but I believe your explanation answered my original question.
I will look into getting the handle on make involving both file extensions of interest, thank you very much for your prompt and informative reply!
My pleasure, let us know how it goes for you!
I will!
Oh I finished my project if you are still interested in seeing it, not sure if you still wanted me to present it?
I’m glad you finished! If you are willing to share it then yes, we would love to see it! Can you share a link to GitHub? Or perhaps a .zip of the project? Thanks for getting back to us
To be honest, I’m a bit hesitant to share all the code just yet. I haven’t seen much come out from the starter Ambiq code that quite compares to it. I’d happily demonstrate it to you liquid and others at sparkfun (if this is where you work). I’d definitely say you had helped me, with at least the ambition and motivation learning all things FreeRTOS and Tensor. I’ve worked on this for quite some time and I’m hungry to learn more from someone that knows more concerning these modules if something like this is offered. We could take this thread somewhere more private if appropriate too?