This page shows you how to:
- Get set-up for Linux Application Development
- Create a simple application
- Debug applications on Linux
Setup
To get setup, you will need to:
- Determine the toolchain and SDK you need
- Install the toolchain and SDK
- Install and setup an IDE
A toolchain is needed to build custom applications. You can use:
- A pre-built toolchain for our XFCE demo image, or
- Build one yourself using the YOCTO tools we provide.
The download link for this is on the releases page. Grab the latest version and put it XXXX.
To install
If you have the YOCTO bits installed from this page, you can use it to generate a toolchain.
Execute the following commands:
$ cd fsl-community-bsp
$ source setup-environment build
$ bitbake opal6-image-base -c populate_sdk
To install, do the following:
$ cd ~/fsl-community-bsp/build/tmp/deploy/sdk
$ ./poky-glibc-x86_64-meta-toolchain-cortexa9hf-vfp-neon-toolchain-2.0.1.sh
The actual installer name may be different to that used above. Just follow the prompts to complete the installation. In most cases you can simply accept the defaults.
IDE Setup
We use the CodeBlocks IDE for development and this section details how to set it up.
First, download and install CodeBlocks. Use the Ubuntu Software Centre, or the following command line:
$ sudo apt-get install codeblocks codeblocks-contrib
To configure CodeBlocks for our toolchain:
We need to configure CodeBlocks to use our toolchain and sysroot so do the following:
- Start CodeBlocks
- Open Settings->Compiler
- Choose ‘GNU GCC for ARM’ from ‘Selected Compiler’ and click ‘Copy’
- Give your new compiler a name e.g. YOCTO compiler for Opal-6
- Now click the ‘Toolchain executables’ tab and browse to your sdk installation directory. You are looking for the parent to the compilers bin directory which in our case is: /opt/poky/2.0.1/sysroots/x86_64-pokysdk-linux/usr/bin/arm-poky-linux-gnueabi
- Now fill in the Program Files by prepending ‘arm-poky-linux-gnueabi-’ to each of gcc, g++ and ar. You should end up with the following:
Debugger Setup
Debugging applications on Opal-6 requires two components:
- gdbserver running on Opal-6
- gdb client running on the VM
The Opal-6 images include the gdbserver components, so we just need to configure CodeBlocks to connect via the gdb client:
- Start CodeBlocks
- Open Settings→Deugger
- Click the 'GDB/CDG debugger' option from the left side menu
- Click 'Creage Config' button and enter a name for this debugger. e.g. "Opal-6" and press ENTER.
- Click "Opal-6" on the left hand menu and paste the path of your Opal-6 toolchain debugger into the Executable Path text box:
e.g. /opt/poky/2.0.1/sysroots/x86_64-pokysdk-linux/usr/bin/arm-poky-linux-gnueabi/arm-poky-linux-gnueabi-gdb - Press OK
To set this debugger as the default for Opal-6, do the following:
- Open Settings→Compiler
- Click the Toolchain Executables tab.
- Select the Opal-6 compuler from the menu
- Change Debugger to Opal-6 from the meny and click OK.
Creating a Linux Application
These steps will show how to create and compile a simple project for Opal-6.
First we will create the project and configure it to use the Opal-6 tools:
- Start CodeBlocks
- Select File->New->Project from the menu, then select Empty Project
- Set the title as Hello World and choose a project folder
- Click Next and set the compiler to YOCTO Compiler for Opal-6
- Click Finish
Now we need to add a file:
- Select File->New->File and select C/C++ Source
- Press Next and select C
- Press '...' and then Finish
- Paste the following code into the editor:
#include <stdio.h>
int main(int argc, char **argv)
{
printf("Hello World!\n");
return 0;
}
5. Press Build (gearwheel icon) to compile the project.
Deploying the Application
You can deploy your application manually to Opal-6, or configure CodeBlocks to automatically deploy when you build.
Manually Deployment
You can manually deploy applications to Opal-6 using scp.
To deploy your Hello World application, open a terminal on your PC and type the following commands:
$ cd Projects/HelloWorld
$ scp bin/Debug/helloworld root@192.168.1.150:~/
You will need to
Deployment using CodeBlocks
Debugging
Add Comment