NI Linux Real-Time Discussions

cancel
Showing results for 
Search instead for 
Did you mean: 

Cross-compiling a C++ code that uses openssl libraries for cRIO 9068

Solved!
Go to solution

Thank you BradM,

what do you mean with release?

Everything what I've found in MAX is:

Modell: myRIO-1900

Firmware-Verion: 2.1.0f0

Operating-System: NI Linux Real-Time ARMv7-A 3.2.35-rt52-2.0.0f0

And I'm using Labview 2013 (Version 13.0f2 (32-bit)).

Thank you for your suggestion to make everything on the target itself. But it's kind of my task to make it by cross-compilation. And as I saw that there are people who can manage it, I think that I can also manage it;).

Do you know which configurations has to be done to get everything working? It's enough for me to get one small project running with a small extern library.

Thank you,

Oemer

0 Kudos
Message 11 of 24
(2,353 Views)

oemergoecer, if you're bent on cross-compiling it, then it doesn't really matter the release of the firmware you're using (that 2.1.0f0 version number is what I was looking for).

I would start at the start: setup and build a simple program that does not need to be linked to an external library. Make sure that runs on the target. Just make sure that the project and cross-compile toolchain are both setup to make sure you don't have to battle those issues. Of course, it sounds like you already got this setup.

Next, I would pick a particular library that you'd like to target. Pick one of the ones you listed, say,  boost. This happens to exist in the software package manager (the system used to install external, 3rd-party, opensource software on these targets), or, more correctly, the package feed server that the system is configured to install from. Install the package on the controller. There are instructions on these forums on how to install software from the package manager (opkg).

Once you've gotten the librar(y|ies) on the target, make the headers and libraries available to your eclipse project. This means using headers of the same general version of the libraries installed on the controller. This also means that you need to grab the libraries off of the controller and make them available on the Windows machine that you will be cross-compiling on. You then need to configure your Eclipse project to pull in the headers (modifying the "-I", or "minus upper-case eye" options for looking in additional directories for headers) as well as modifiying the linker configuration (modifying both the location directives, "-L", to include the folder that contains the new library as well as the linking directive, "-l" or "minus lower-case ell", to tell the tools to include the noted library when attempting to resolve symbols). There are tons of great, thorough tutorials on how to do just this for both regular as well as cross-compilation projects with Eclipse.

At this point, you're looking pretty good, but some of the libraries that you've mentioned do not exist in the package manager feed repositories. You will need to download the source for these libraries, create a library-type cross-compile project in Eclipse, and import the source into that project. Compile that. In this case, it actually will be easier to make Eclipse use this project when compiling the project that depends on this. It already knows about the library and where to find it, you simply need to direct Eclipse to use the library project within the project that depends on the library.

Repeat this process, finding the solutions to whatever issues you encounter as you progress along, until all of the dependent libraries are accounted for and the binary you are interested in has successfully compiled. Copy the libraries that you've used to the target (being sure to place them in a directory that is examined by the ldconfig tool), re-run ldconfig to rebuild the ld.so.cache file (a cache of the locations and names of all of the libraries on the system that are in one of the system library folders), copy the binary over to the target, and that should just about do it.

Message 12 of 24
(2,353 Views)

Thank you BradM for your long description! I'm still trying to get it working. I had a good progress so far but now I've a big problem. My myRIO doesn't boot anymore. Status LED is continuously flashing red. It happened after I used rsync to synchronize my cross compiled libraries from my pc to myRIO with this command line in Ubuntu "sudo rsync -avP --numeric-ids /home/oemer/myRIOroot/usr/ admin@172.22.11.2:/usr". After I could see that everything is at its right path. But after rebooting myRIO I recognized that something was wrong.

In the myRIO-1900 manual stays that I have to contact National Instruments in that case. Is it ok that I contact you for that problem or do I have to ask someone else?

I think that there should be a way to make a factory reset. But I didn't find anything like that in the web.

0 Kudos
Message 13 of 24
(2,353 Views)

Hey oemergoecer -

I want to confirm that the device is in a state with an unrecoverable error. You mentioned that the Status LED is blinking continuously. Is this a steady and continuous blinking? Is there a brief pause between a sequence of the blinking?

If the device is blinking continuously without pause then I would go ahead and start a service request with our Support team: http://www.ni.com/support/

They will get you the necessary files to get your NI myRIO into recovery mode. Then we can get you back to synchronizing those cross-compiled libraries

0 Kudos
Message 14 of 24
(2,353 Views)

Let me add another thing for you to try. As per the manual:

Pressing and holding the Reset button for 5 seconds, then releasing it, restarts the processor and

the FPGA and forces the NI myRIO-1900 into safe mode. In safe mode, the NI myRIO-1900

launches only the services necessary for updating configuration and installing software.

You can try and see if rebooting into safemode and reinstalling the software helps the whole blinking situation.

0 Kudos
Message 15 of 24
(2,354 Views)

Thank you Tamdemonium,

it's a continuously blinking without pause. I had already read the manual. I just wanted to give my request first here this community because I hope to get a fast solution for my problem. Now, I've already made a support request at http://www.ni.com/support/.

I can start into safe mode without problems. But I don't know what to do to fix this problem. Which software am I supposed to install and how? Firmware update?

0 Kudos
Message 16 of 24
(2,354 Views)

I managed it to make a factory reset. My myRIO is now working without any problems. I made it as described in the following link which NI support sent me.

http://www.ni.com/white-paper/7191/en/0

First I will tell you exactly how I tried to make it. I installed rsync on myRIO over opkg and on Ubuntu over apt-get. After that I used rsync command on Ubuntu to synchronize from myRIO to Ubuntu.Like this:

sudo rsync -avP --numeric-ids --exclude='/dev' --exclude='/proc' --exclude='/sys' --exclude='/bin' --exclude='/boot' --exclude='/c' --exclude='/etc' --exclude='/home' --exclude='/lib' --exclude='/media' --exclude='/mnt' --exclude='/natinst' --exclude='/run' --exclude='/sbin' --exclude='/tmp' --exclude='/var'  admin@172.22.11.2:/ /home/oemer/myRIOroot/

I need to do that because I need some libraries which I installed with opkg to build other libraries.

After that I build (with cross compiling) the external libraries which I couldn't find in the opkg feeds. And installed (with "make install")  them to the myRIOroot folder on Ubuntu.

Now it's time for synchronizing this myRIOroot folder from Ubuntu to myRIO. I think that it should be easier to synchronize from Ubuntu to Linux RT than from Windows to Linux RT. Otherwise I can also copy my created myRIOroot folder in Ubuntu to Windows.

As described in my recent post I tried this with using this command on Ubuntu.

sudo rsync -avP --numeric-ids /home/oemer/myRIOroot/usr/ admin@172.22.11.2:/usr

I can imagine that I changed some permission settings during synchronizing. Do you know a better way to synchronize the cross compiled libraries? Or do I have to execute the "make install" command on myRIO?

0 Kudos
Message 17 of 24
(2,354 Views)

It would be helpful to enable the serial console out and check to see why it fails to boot completely, but that's not really answering your question.

To address your particular use case, as I said before, if it were me I would be building things on the target. You've said you would rather not do this, and that's fine.

My next approach would be to use sshfs on your Ubuntu machine instead of shlepping the files from your myRIO to Ubuntu then back again. Use sshfs to mount the myRIO root filesystem locally on the Ubuntu machine over ssh and, when building, direct the tools to include the myRIO sshfs mount.

E.g.

sshfs IP_OF_MYRIO😕 myrio_mountpoint

arm-whatever-linux-gnueabi-gcc -I myrio_mountpoint/usr/lib/include -L myrio_mountpoint/lib -L myrio_mountpoint/usr/lib ...

...

Without trying anything locally (not really able to ATM), your commands look fine from a quick glance, but clearly there's something amiss.

Message 18 of 24
(2,354 Views)

Thank you! My C++ Code is now running on myRIO with third party libraries.

I used sshfs on Ubuntu to mount myRIO on my machine, as you told me.

The next step will be to make a shared library from my C++ code and to use functions out of this C++ code in Labview. I will post here if I have any problems;)

0 Kudos
Message 19 of 24
(2,354 Views)

Glad to see you got things working. This is definitely one of the more ambitious uses of cross-compilation and utilizing the open-source resources that are available for Linux that I'm aware of for our targets, so kudos to you indeed.

0 Kudos
Message 20 of 24
(2,354 Views)