BelaPlatform / Bela

Bela: core code, IDE and lots of fun!
Other
484 stars 138 forks source link

RTDM Error when Building with Eclipse #560

Open sedurCode opened 5 years ago

sedurCode commented 5 years ago

As of the current state of the master branch, when building a simple example (scope example) using the instructions on the wiki:

https://github.com/BelaPlatform/Bela/wiki/Compiling-Bela-projects-in-Eclipse

using eclipse and building for the CTAG+Bela, I get the following error when debugging:

`root@bela:~# make --makefile=/root/Bela/Makefile stop;gdbserver :2345 /root/Bela aRemote/Debug/Bela;exit No process to kill Process /root/BelaRemote/Debug/Bela created; pid = 1360 Listening on port 2345 Remote debugging from host 192.168.1.13 Detaching from process 1361 Error: the installed rtdm_pruss_irq driver cannot be used in conjunction with McASP interrupts. Update the driver Error: unable to start PRU from Error: unable to start real-time audio Failed to join audio thread: (3) No such process

Child exited with status 1 logout `

Screenshot 2019-06-23 at 17 38 03
giuliomoro commented 5 years ago

That is because at compile time the file <linux/rtdm_pruss_irq.h> cannot be found, even though it probably is present on the board (it will be there if you are using a valid CTAG image, as you seem to be). You should copy the file from the board (/usr/include/linux/rtdm_pruss_irq.h) to the host, and adjust Eclipse's paths so that it can find it (or place it inside one of the already existing paths, e.g.: Bela/include/linux/rtdm_pruss_irq.h).

If this works, could you please update the wiki?

sedurCode commented 5 years ago

I copied the file to the BelaSysroot/usr/include folder, refreshed the project, and had the same error. I also tried the workspace/Bela/include folder, and got the same error. I then added the linux folder to the workspace/Bela/include folder, got the same problem. Clearly the file is not being seen and built into the project. So I went into the C++/general > Paths and Symbols from the dox and added the subfolder to the build path. Problem persists. There is obviously something I am missing.

giuliomoro commented 5 years ago

You need to re-trigger building of core/PRU.cpp. This can be done in a number of ways, e.g.: there may be a global "clean" button, or you can edit the file itself (e.g.: add and remove a whitespace). Make sure it gets rebuilt. Actually, to make sure it finds the file AND at the same time trigger a rebuild, open core/PRU.cpp and find these lines:

#ifdef BELA_USE_RTDM
#if __has_include(<linux/rtdm_pruss_irq.h>)
#include <linux/rtdm_pruss_irq.h>
#else /* has_include */
#define RTDM_PRUSS_IRQ_VERSION 0
#endif /* has_include */
#endif /* BELA_USE_RTDM */

the problem is that when it was built, it couldn't find linux/rtdm_pruss_irq.h, therefore the #else part of the statement was used. You don't want that to happen, because the presence of that include is necessary in order to use the CTAG. So you could add an #error line in the #else, e.g.:

#ifdef BELA_USE_RTDM
#if __has_include(<linux/rtdm_pruss_irq.h>)
#include <linux/rtdm_pruss_irq.h>
#else /* has_include */
#define RTDM_PRUSS_IRQ_VERSION 0
#error linux/rtdm_pruss_irq.h was not found
#endif /* has_include */
#endif /* BELA_USE_RTDM */
sedurCode commented 5 years ago

I had a go at this, with no success so far but I will try and figure it out. Of course adding the error line worked, confirming that eclipse isn't finding and resolving the association of the two files. Despite putting the file in a range of suitable folders, the build system just doesn't seem to pick it up.

sedurCode commented 5 years ago

Ok, so I am going to level with you. I have a slightly different setup to the eclipse guide, there I migrated the dependencies from /usr/local/linaro to be in my users space, because I already had arm compilers stored there from other projects. I went and changed the project settings to reflect this, but there was an instance in the release build settings that points to the compiler that I missed. After fixing that and re-setting the dependency path in the file, I moved onto a new set of errors.

It appears that xenomai_wrappers cannot find the dependencies rtdm/ipc.h... no surprise because that folder isn't inside my project.

In essence It looks like I am deviating from the the code-base in the guide; something I would rather avoid, as I don't want to bother you with a problem that isn't appearing for other people who are also developing through eclipse for the CTAG. If it is the case that the nice symlink file doesn't seem to include stuff you guys don't think is important for this build system to work, but that is needed for working with the CTAG, I will continue down this path. Otherwise I will go back, clean and then rebuild my tools to work 'as stock', and report how I get on. What do you think?

giuliomoro commented 5 years ago

hmm, not sure how to help here: I didn't test the Eclipse setup myself, @AndrewCapon did the docs, and probably back then the rtdm_pruss_irq.h file was not even needed, as it was added around October 2018.

My understanding is that as long as you have all the includes you need (e.g.: the BelaSysroot folder), then you should just set the paths appropriately and be fine. You can add -v to your compiler command line (e.g.: CPPFLAGS or CXXFLAGS) and then inspect the output to make sure the include paths are set appropriately, and fix as needed. It can be a tedious process sometimes, but it is definitely approachable scientifically and CAN be solved with this strategy.

Another trick would be to copy the pre-built PRU.o file from ~/Bela/build/core/PRU.o on the board to the Eclipse build folder in your computer, but the above solution is definitely better.

sedurCode commented 5 years ago

I will pump time into figuring this out if it's going to help other people. The whole reason for wanting to do this in the first place is so that I can profile that multi-channel sample playback and figure out why the computation overhead explodes when you go above 8 channels.