Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   C/C++ (http://www.chiefdelphi.com/forums/forumdisplay.php?f=183)
-   -   C++ - No Code? (http://www.chiefdelphi.com/forums/showthread.php?t=98830)

rbmj 14-12-2011 14:13

C++ - No Code?
 
So my team is moving to C++ away from LabVIEW (which makes me want to bang my head against the wall). I've been trying to get some very simple code working (demos). Since I don't have WindRiver (my team lost the disk), I'm using ucpp to compile through the gccdist. Everything compiles/links fine, so I have a FRC_UserProgram.out , which I ftp up to the cRIO (just reimaged for C++). Then, driver station says Comm works, but claims No Robot Code even after a restart. I've verified that the .out file has uploaded successfully to /ni-rt/system .

So any ideas why the driver station still claims that there is no code?

Thanks!

PS: I've looked at the .ini files, and it appears that lvrt.out (which I assume means labview runtime) and startup.rtexe (the name of compiled labview code) are still set for startup. Don't want to toss out a red herring, but could this be it? FRC_ImageVersion.ini has Language=C, so I assume it isn't and I'm not deploying correctly (though the only file the compiler gives me is the .out file; I'm not exactly sure what I need in this case).

Anyways, thanks again.

Mark McLeod 14-12-2011 14:54

Re: C++ - No Code?
 
Without the Wind River installation your generic compiler is probably targeting Windows rather than the VxWorks that runs on the cRIO.

Your code on the cRIO is probably starting and immediately dying on the first Windows call.

You can use Netconsole for the cRIO to check the error messages being generated. That gets installed with the FRC Utilities package. Just make sure the cRIO is setup for Netconsole (a choice during the cRIO imaging process).

The LabVIEW leftovers won't matter.

rbmj 14-12-2011 15:27

Re: C++ - No Code?
 
No, I'm 99% sure it's targeting cRIO. For one, the build directory is for PPC. I'm using the cross-compiler provided by NI (gccdist) and the very nice ucpp project (https://github.com/nikitakit/ucpp). The makefile is virtually identical to the standard one given by NI.

I would use WindRiver, if I had it. But I wasn't able to get another copy of the license file. I need to make sure that everything works correctly before build season starts though, so necessity dictates I hack something together.

byteit101 14-12-2011 17:01

Re: C++ - No Code?
 
is the cRIO imaged for C++ or LabVIEW?
just open up the imaging tool, change it, and hit apply.

Ether 14-12-2011 17:09

Re: C++ - No Code?
 

Quote:

Originally Posted by byteit101 (Post 1091166)
is the cRIO imaged for C++ or LabVIEW?

original post:
Quote:

Originally Posted by rbmj (Post 1091129)
(just reimaged for C++)


AustinSchuh 14-12-2011 22:56

Re: C++ - No Code?
 
I second viewing either NetConsole or the serial port output. If you have trouble interpreting it, feel free to post it here and I will do my best to help.

The ucpp project targets the cRIO, and should build code correctly. I have been using that toolchain (under Linux) for years without issues, and with a similar Makefile.

rbmj 15-12-2011 11:10

Re: C++ - No Code?
 
OK. I was able to get NetConsole working after manually changing the default gateway in ni-rt.ini to 10.6.12.4.

More interestingly, it fails to lode the code due to undefined symbol errors. The symbols look like the mangled names of WPILib functions (_Z...WatchdogC1EPi), so i assume that ucpp is not linking in WPILib.

Where is the WPILib file? I assume I could add it to StartupDlls in ni-rt.ini, or change the makefile to run wine ldppc.exe (I too am on linux) or something of the like to statically link them together.

Or have I just missed a step. Again, I haven't modified the toolchain from the default linux ucpp.

Thanks for your help.

EDIT: Found the WPILib.a file. It looks like it *should* be linked in (glancing at the makefile). Why am I getting undefined symbol errors then?

rbmj 15-12-2011 12:21

Re: C++ - No Code?
 
Got it to work - An update to version 30 of the firmware did the trick (I was using version 29).

Thanks!

Mark McLeod 15-12-2011 12:26

Re: C++ - No Code?
 
Great.
A mismatch of the library/image versions causing the error makes sense.

jhersh 15-12-2011 13:41

Re: C++ - No Code?
 
Technically WPILib was being linked in. The failure was coming from a mismatch of symbol names between WPILib.a and the NI_FPGA.out binary that exposes symbols to access the FPGA.

jhersh 15-12-2011 13:43

Re: C++ - No Code?
 
Quote:

Originally Posted by rbmj (Post 1091411)
Got it to work - An update to version 30 of the firmware did the trick (I was using version 29).

Would you care to write up a document describing what you used and how you put it together (potentially including the Makefile you ended up with) so that others on Linux can get a head start?

Thanks,
-Joe

AustinSchuh 15-12-2011 14:38

Re: C++ - No Code?
 
Quote:

Originally Posted by jhersh (Post 1091436)
Would you care to write up a document describing what you used and how you put it together (potentially including the Makefile you ended up with) so that others on Linux can get a head start?

Thanks,
-Joe

The ucpp project is just that. It is nicely packaged to make it easy to use.

https://github.com/nikitakit/ucpp

Code:

Universal compiling scripts for FRC

System Requirements:
  For Linux: wine, wput
  For Windows: MSYSgit or Cygwin

Installation instructions:
 - Add the "ucpp/ucpp" folder to your system PATH
 - Run the ucpp setup script
      $ ucpp setup -t <team-number>

Creating a project
 $ ucpp init
        Configures the current directory as an FRC C++ project
        that deploys code to your team's robot.

        The ucpp build system aims to be fully compatible with
        development in WindRiver. You can initialize any existing
        WindRiver project as a ucpp project, as well as any folder
        that contains C++ files.

Building and deploying code
 $ ucpp configure
        Generates a Makefile for your project
        For additional options, run "ucpp configure help"
 $ make
        Compile the project
 $ make deploy
        Deploy code to the robot


jhersh 15-12-2011 15:03

Re: C++ - No Code?
 
Quote:

Originally Posted by AustinSchuh (Post 1091442)
The ucpp project is just that. It is nicely packaged to make it easy to use.

Excellent. Somehow I had not seen this before. Nice work.

-Joe

rbmj 16-12-2011 13:51

Re: C++ - No Code?
 
Note that the main version by nikitakit doesn't work for me - it calls python2 which is only python on some boxes. Ozzloy added a few commits to detect where python2 was installed and call that through a shell variable, so his fork might work better for many users. He submitted a pull request a long time ago but upstream hasn't merged them in.

I made some patches to some of the scripts as well, as I was getting syntax errors on my computers (Debian & openSUSE). I have a fork at github (https://github.com/rbmj/ucpp) that has ozzloy's changes as well as mine until upstream merges them in. I've also requested that ozzloy merge my changes into his repo.

byteit101 16-12-2011 15:49

Re: C++ - No Code?
 
Quote:

Originally Posted by rbmj (Post 1091636)
Note that the main version by nikitakit doesn't work for me - it calls python2 which is only python on some boxes. Ozzloy added a few commits to detect where python2 was installed and call that through a shell variable, so his fork might work better for many users. He submitted a pull request a long time ago but upstream hasn't merged them in.

I made some patches to some of the scripts as well, as I was getting syntax errors on my computers (Debian & openSUSE). I have a fork at github (https://github.com/rbmj/ucpp) that has ozzloy's changes as well as mine until upstream merges them in. I've also requested that ozzloy merge my changes into his repo.

Did not realize that, I though that was pulled a while ago. submit the pull request to nikitakit/ucpp (I just pulled ozzloy's)

rbmj 16-12-2011 17:36

Re: C++ - No Code?
 
Quote:

Originally Posted by byteit101 (Post 1091675)
Did not realize that, I though that was pulled a while ago. submit the pull request to nikitakit/ucpp (I just pulled ozzloy's)

Since I forked from ozzloy, my pull request went to him.

The main issue was that the parsing of the team number into an ip address in ucpp-init. Since the method used in ucpp-setup worked, I changed ucpp-init to parse its arguments in the same manner. I also cleaned up the detect python function, as in my case it was outputting the found python twice. Also there was no need to use the output of that function to set ucpp_python_bin, as the variable is globally scoped. Last I included the found python in the settings file so it could be used from other scripts.

runfrodorun 26-12-2011 23:36

Re: C++ - No Code?
 
Hey: this may seem a bit off topic, but is there somewhere I could get information on compiling code targeting VxWorks on a ppc 603 cpu like you did without windriver? I'm running unix and I'm trying to figure out how to download code to out cRIO without a license for windriver.

I've started working on compiling my own cross tools to target the different CPU architecture, but I really don't know where to start. Any help appreciated!

rbmj 27-12-2011 00:35

Re: C++ - No Code?
 
Quote:

Originally Posted by runfrodorun (Post 1093914)
Hey: this may seem a bit off topic, but is there somewhere I could get information on compiling code targeting VxWorks on a ppc 603 cpu like you did without windriver? I'm running unix and I'm trying to figure out how to download code to out cRIO without a license for windriver.

As stated earlier in the thread, the ucpp project is just that. You don't even have to compile the compiler - it downloads the windows binaries and runs them through wine. Yes, it's more difficult, but it's much easier than managing all of the configuration for the build of the new compiler. And if you're a windows person, you can either run ucpp through cygwin or download the gccdist provided by NI (https://decibel.ni.com/content/docs/DOC-14237) and run it yourself. Then you grab the latest version of WPILib from FIRSTForge, edit the sample makefile in the gccdist to suit your project, change the makefile to statically link in WPILib, and off you go.

Quote:

I've started working on compiling my own cross tools to target the different CPU architecture, but I really don't know where to start. Any help appreciated!
Again, if you want a native compiler, more power to you. But the easy way out is already there. Just a few scripts away. If you want more power (I myself wouldn't completely miss a compiler with c++0x support, but I don't want to have to worry about a non-standard toolchain screwing up things at competition) feel free to compile your own compiler, just remember that it is the harder way, you may get screwed by it, and few (er?) people will be able to help you.

AustinSchuh 27-12-2011 02:53

Re: C++ - No Code?
 
Quote:

Originally Posted by runfrodorun (Post 1093914)
I've started working on compiling my own cross tools to target the different CPU architecture, but I really don't know where to start. Any help appreciated!

I already got GCC 4.5.3 compiling on Linux and targeting the cRIO. My patches and build script are here. Thanks to Ross Light for cleaning it up and getting it to run on OSX. It is unsupported, but seems to work well. This also builds my own version of libstdc++v3 that seems to work on the cRIO. It would be nice to integrate this into ucpp at some point.

http://hg.zombiezen.com/vxworks-gcc-patches/overview

nikitakit 27-12-2011 03:10

Re: C++ - No Code?
 
Hi rbmj. Thanks for the changes to ucpp - I've pulled them in.

Right now I'm in college, away from my team, so unfortunately that means I'm somewhat out of the loop on FRC and don't have a real robot to test code on. I'm probably not the best person to be maintaining ucpp at the moment.

That said, I'm still around online, and I'm still very much interested in seeing ucpp remain usable throughout the next competition. It's really a shame for teams not to be able to program on Linux when the tools are there, and have been there for quite a while.

byteit101 - do you plan to continue working on ucpp throughout the next year? It will need some updates after kick-off for everything to work with the new versions of WPILib, etc.

byteit101 27-12-2011 13:48

Re: C++ - No Code?
 
Quote:

Originally Posted by nikitakit (Post 1093945)
byteit101 - do you plan to continue working on ucpp throughout the next year? It will need some updates after kick-off for everything to work with the new versions of WPILib, etc.

I do. I've been busy recently, but will probably work on it some more after kickoff.

rbmj 28-12-2011 01:08

Re: C++ - No Code?
 
Quote:

Originally Posted by AustinSchuh (Post 1093944)
I already got GCC 4.5.3 compiling on Linux and targeting the cRIO. My patches and build script are here. Thanks to Ross Light for cleaning it up and getting it to run on OSX. It is unsupported, but seems to work well. This also builds my own version of libstdc++v3 that seems to work on the cRIO. It would be nice to integrate this into ucpp at some point.

http://hg.zombiezen.com/vxworks-gcc-patches/overview

That's awesome that you have a newer version of GCC. I personally would *love* to be able to use some of the new features of C++11 (I've already gotten used to using them in my personal code, and it's kind of sad that I can't use them on FRC code), but I have reservations.

Primarily, I know that in order to pass inspection your robot must be running a certain version of the firmware. Now, I know that you could image the cRIO and then overwrite all of the libraries, but could you be disqualified for doing this? Anyone happen to know what the rules say on this? GCC 3 is so old... it seems like FIRST *should* encourage teams to innovate.

Also, at some point maybe I could modify ucpp to allow users to optionally install ucpp for their whole system. We could also look at integrating build scripts - if nothing else we could find the source for the same version of GCC that gccdist uses - this _in_theory_ should not have any issues and be fully compatible with the stock image.

AustinSchuh 28-12-2011 04:24

Re: C++ - No Code?
 
It is fully legal. You are not replacing any librarys. You are only generating a binary that has a second version of the library symbols that have been re-named to avoid a namespace collision. There is no need to modify the firmware to get this to work. This is similar to writing your own printf and friends and using those.

If you want, it is also possible to use the old version of the standard libraries that comes with the cRIO and use the newer compiler with them. This will produce a number of warnings in the header files, but it will still work. This is the route that 971 went last year, since I hadn't gotten the symbol renaming worked out.

nikitakit 07-01-2012 15:50

Re: C++ - No Code?
 
I've updated ucpp-setup so that it pulls in 2012 WPILib. The default robot seems to compile fine. I have no idea what the Kinect libraries are all about though.

newkidd-sagar 07-01-2012 16:33

Re: C++ - No Code?
 
Hey there, I was wondering if your team was able to get the FIRST menu option in the 2012 WindRiver Installation. Are there any WPILib updates online that I need to install? I also don't have any examples or templates like "SimpleRobot" etc.

Thanks for your help.

newkidd-sagar 07-01-2012 16:38

Re: C++ - No Code?
 
Never mind I found the update.

It is located here:

http://firstforge.wpi.edu/sf/go/pkg1109

BradAMiller 07-01-2012 19:20

Re: C++ - No Code?
 
Quote:

Originally Posted by newkidd-sagar (Post 1098243)
Hey there, I was wondering if your team was able to get the FIRST menu option in the 2012 WindRiver Installation. Are there any WPILib updates online that I need to install? I also don't have any examples or templates like "SimpleRobot" etc.

Thanks for your help.

For Workbench you need to install the updates from FIRSTForge on the WPILib project. Go to http://firstforge.wpi.edu, then select the WPILib project, and look at "File releases". The update is there. There is also documentation in the "Documents" area.

Brad

rbmj 07-01-2012 20:10

Re: C++ - No Code?
 
The kinect stuff should be to get kinect data from the driver station.

As far as I know, it's impossible (well not impossible, but impractical) to get the kinect to work ON robot in it's original capacity. That would require implementing a full USB Host driver on two DIO ports AFAIK, which is theoretically possible but would be extremely hard (it'd probably leave you little time to code up the actual robot drive code).

If anyone has information/knows more, please say so. But it seems like the kinect isn't all too useful, and is more of a marketing gimmick (not that I'm complaining, it's a cool sensor to play with) on Microsoft's part, as most of the autonomous code can be done via vision onboard the robot without the need for much human intervention. I'm sure someone will do something completely novel with it though, so I'll have to wait and see.

rbmj 15-02-2012 20:34

Re: C++ - No Code?
 
I don't know if this is necromancy or not - still kind of new to CD.

I wanted to ask Austin Schuh how he got libstdc++ to build. I've successfully build gcc & friends using a combination of the patches and a little messing with compile flags. However, I get an error on the libstdc++-v3 configure script:

checking for shl_load... configure: error: Link tests are not allowed after GCC_NO_EXECUTABLES.

And when I try and build the configured portions, I get butloads of errors, some of which appear to be related to pthreads. I also incorporated jmesmon's patches, but am still getting errors.


All times are GMT -5. The time now is 12:39.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi