How to develop a Linux binary for the BeagleBone (any colour) on Windows in CCS, auto-deploy it to the BB and remotely debug.

No hardware debugger needed - all runs over TCP/IP

The great PRU blog from Fred27 inspired me to pick up the BeagleBone Green again. Because he uses CCS as development environment, it makes sense to also use CCS for Linux native C and C++ development.

 

I've blogged before on  how to set up a BeagleBone C/C++ environment with the ARM DS-5 suite.

Both DS-5 and CCS are Eclipse based. Things are not that different, and it's no surprise that I could get the CCS flavour working.

Functionally, there's no gain with this exercise if you are already happily developing with DS-5. I did it to have everything in a single IDE.

 

Software needed

  • Code Composer Studio. I used version 9 but earlier versions will very likely work too.
  • Cross-compile GCC toolchain. I used gcc-linaro-5.3-2016.02-i686-mingw32_arm-linux-gnueabihf .
    I could not get newer version 7.x to work. Download this archive if you want to use the same setup as me: gcc-linaro-5.3-2016.02-i686-mingw32_arm-linux-gnueabihf.tar.xz
    attention: run your extract program (e.g.: 7-Zip) as Administrator when you extract the toolchain tar or you will not get a working toolchain.

 

Create a Project: Blinky

 

Start Code Composer Studio and start a New -> Project

Select an Empty project, with Cross GCC as toolchain.

 

Press Next until you are asked for the toolchain details.

The prefix: arm-linux-gnueabihf-

Path: the bin folder of the location where you extracted the toolchain (in my case: D:\users\jancu\Documents\elektronica\arm\linaro\gcc-linaro-5.3-2016.02-i686-mingw32_arm-linux-gnueabihf\bin)

 

Finish.

 

Now add a src folder in the root of your project.

in that folder, create a new C++ file called bb_gpio_test.cpp

For the content, I used Derek Molloy's C++ makeLED example: Beaglebone: Controlling the on-board LEDs using C++ | derekmolloy.ie | derekmolloy.ie

 

 

Copy the source and paste it in the cpp file you just created.

Save.

 

Build the Project

 

Try to build it straight away. If everything works, be happy.

If CCS complains it can't find make, go to Properties -> C/C++ Build -> Builder settings.

First try the Internal builder and build again.

 

If that step fails, manually select the builder.

Uncheck the Use Default build command.

Enter the path of the CCS make utility: ${CCS_UTILS_DIR}/bin/gmake -k -j 8

 

Set the CCS_UTILS_DIR to the ccs\utils subdirectory of Eclipse.

 

Build. You should now get a Binaries folder in your project, with the Linux native executable.

 

 

Deploy and Debug

 

Go to Run -> Debug configurations, and add a new C/C++ Remote Configuration.

 

When you select the project, it will automatically find your executable too.

Press the New... button next to Connection, and make a connection to your BB. The host name of your BB should be beaglebone.local.

You can use user name and password (debian/xxx) - or if you have enabled secure key logon with your BB, you can use your private certificate.

When the connection is entered, you can Browse... for the location on the BB where you want CCS to deploy the binary.

I created a bin folder in my BB home, so I select /home/debian/bin.

 

In the Arguments tab, you can the arguments that the debugger will pass to your application at start.

Derek's app expects one parameter that tells it what to do with the LED. I passed flash as argument. It will flash the led in a half second on - half second off pace.

 

Then define the debugger (GDB client) installed on your computer. The one of the Linaro toolchain isn't called gdb but arm-linux-gnueabihf-gdb.

You should not have to install the debug server on the BB if you use a recent Debian image. It's there already.

(Fred27' Debian did not have it by default. It can be installed by executing sudo apt-get install gdbserver).

 

Push Apply.

 

Go!

 

Push the Debug button. CCS will upload your executable to the BB, load the main file in the debugger and stop at the first instruction.

Now play with it. You can check variables, expressions, memory.

You can step through the code.

The Console shows the output from the Linux console.

The Debugger Console (Window -> New -> Debugger Console) shows debug info (experts can type gdb commands here).

 

If all is OK, you should, after some stepping, find yourself here:

 

else if (cmd=="flash"){
    fs.open (LED0_PATH "/trigger", std::fstream::out);
    fs << "timer";
    fs.close();
    fs.open (LED0_PATH "/delay_on", std::fstream::out);
    fs << "50";
    fs.close();
    fs.open (LED0_PATH "/delay_off", std::fstream::out);
    fs << "50";
    fs.close();
}

 

It's the blink code. Watch the green user LED (fun fact: on the BB Green the green LED is blue). It will blink.

 

Enjoy!

(also works for a Raspberry Pi)

 

Related Blog
BeagleBone - Cross Compile c++ on Windows
BeagleBone: Build and Debug a Linux C++ Program with Code Composer Studio
BeagleBone: Develop and Debug with Derek Molloy's GPIO Lib and Code Composer Studio