Building and downloading a robot project to the cRIO
Using the C++ IDE there are two ways to load programs onto the cRIO
- "Deploy" it onto the cRIO flash and run it on a reboot. This will keep the program in the cRIO's persistent memory and will load it each time the device reboots, but will not allow any of the debugging discussed above. This method is covered in this article
- Attach to the cRIO and run the program using the debugger from your development system directly to the cRIO memory. This method will allow you to set breakpoints, step through code, view variable values and perform other debugging operations, however the code will not persist when the cRIO is rebooted. When the cRIO reboots, no code will be running! This method is covered in the next article, "Debugging a Robot Program".
For tournaments you should always Deploy the program so that it will be there when the robot is restarted and the match is played.
Building a robot program
Before downloading your program to the cRIO it must be built. To do this right-click on the project in the Project Explorer and select "Build Project". This will compile and link the project files.
Verify that no User Code is running
Be sure to not use the Run/Debug configuration if you have a robot program deployed and thus starting up automatically in the background. Having two robot programs trying to run at the same time gives very confusing symptoms and doesn't work. Use the Undeploy menu item if you think there is already a deployed program. Verify that no code is running by opening the FRC Driver Station and checking that the Communications indicator is green and the Robot Code indicator is red, if the Robot Code indicator is green and you have Undeployed the program, reset the cRIO to clear the running code.
Locating the .OUT file for download to the cRIO
When you build a project with WindRiver Workbench it creates a cRIO executable file in the project directory. It has the extension .OUT and can be seen in the above example. This is the file that you need to use in the next step when setting the FIRST downloader preferences. In this case it's called SimpleTemplate.out - the file name matches the project name. You can find it project directory in the workspace. By default it's in the C:\WindRiver\Workspace directory.
Setting the FIRST downloader preferences
To set up Workbench to load your program using the FIRST downloader be sure to setup the FIRST Downloader Preferences. You must fill in the team number and the location of the .OUT file that is generated on building the project.
Note: a common mistake is to have the wrong file selected. In this case, you will be making changes to one project, but running a different project and your changes will never be applied.
Loading a program to run on robot startup
To have the program run automatically each time the cRIO boots, it must be loaded in the cRIO flash memory. For tournaments you should always download the program so that it will be there when the robot is restarted and the match is played. To do this, make sure that the correct .out file is set in the FIRST Downloader Preferences as shown in the next step. Then select the FIRST menu and click Deploy to load the program into the cRIO. To undo this action so you can Run/Debug the code from the computer, return to the same menu and select Undeploy, then reboot the cRIO.
After the Deploy dialog completes you must reboot the cRIO before the new code will begin running.