Hello,
I'm trying to embed c++ code into the freertos-based firmware of the crazyflie drone, with the "app" framework and the push-demo as a basis.
I succeeded in compiling, linking, launching, but dynamic_cast<> always returns nullptr, and exceptions raised are not caught. I enabled flags such as -fexceptions, -rtti, and removed --specs=nano.specs to no avail. Something to know: it's the app task that eventually calls a c++ function which in turn does c++ stuff.
Does anybody know if the specific flags of the crazyflie firmware compilation process prevent c++ to behave correctly wrt to dynamic_cast?
(and I’m aware rtti and exceptions are not recommended in embedded apps, but I still want to try)
Best,
Stéphane
[solved] crazyflie firmware and c++
-
- Beginner
- Posts: 3
- Joined: Sun Mar 29, 2020 7:52 pm
[solved] crazyflie firmware and c++
Last edited by stefanovic on Wed Jul 15, 2020 5:18 pm, edited 1 time in total.
-
- Bitcraze
- Posts: 630
- Joined: Tue Jun 30, 2015 7:47 am
Re: crazyflie firmware and c++
Hi!
I know Arnaud looked at C++ at some point, but as far as I remember he ran into some kind of problem, not sure what though. We did not have the app layer at that time, it might be possible to get that to work?
I found this thread that might help you?
https://www.freertos.org/FreeRTOS_Suppo ... a047j.html
Please keep us posted on your work!
I know Arnaud looked at C++ at some point, but as far as I remember he ran into some kind of problem, not sure what though. We did not have the app layer at that time, it might be possible to get that to work?
I found this thread that might help you?
https://www.freertos.org/FreeRTOS_Suppo ... a047j.html
Please keep us posted on your work!
-
- Beginner
- Posts: 3
- Joined: Sun Mar 29, 2020 7:52 pm
Re: crazyflie firmware and c++
Thank you.
Unfortunately the various discussions on this on the net do not bring solutions to my problems, including the one you mention.
I opened up another discussion over at https://forums.freertos.org/t/freertos-and-c-rtti/9372
Everything happen as if the std library was not initialized somehow: dynamic_cast returns nullptr, stl containers are faulty, no initialization of c++ global objects etc.
still trying to no avail...
Unfortunately the various discussions on this on the net do not bring solutions to my problems, including the one you mention.
I opened up another discussion over at https://forums.freertos.org/t/freertos-and-c-rtti/9372
Everything happen as if the std library was not initialized somehow: dynamic_cast returns nullptr, stl containers are faulty, no initialization of c++ global objects etc.
still trying to no avail...
-
- Beginner
- Posts: 3
- Joined: Sun Mar 29, 2020 7:52 pm
Re: crazyflie firmware and c++
I had some free time to go back to this problem.
It turned out that it was entirely my fault, as expected.
I figured that c++ code in headers was working as intended, but not the code in object files that I was compiling externally.
This led me to the insight that I was not compiling them correctly.
Using this small command (*), I could figure out that some files were compiled with -fpic, and some were not, which made the c++ code behave incorrectly.
Case closed, sorry for the noise, and thanks for your help.
(*) echo $(CXXFLAGS) | tr " " "\n" | sort ;
It turned out that it was entirely my fault, as expected.
I figured that c++ code in headers was working as intended, but not the code in object files that I was compiling externally.
This led me to the insight that I was not compiling them correctly.
Using this small command (*), I could figure out that some files were compiled with -fpic, and some were not, which made the c++ code behave incorrectly.
Case closed, sorry for the noise, and thanks for your help.
(*) echo $(CXXFLAGS) | tr " " "\n" | sort ;
Re: [solved] crazyflie firmware and c++
thanks for the update and happy you found the solution!