Set up a remote compilation and execution environment and use NetBeans to debug code running on a Raspberry Pi

2018-01-24



Introduction

This is part three of my quest to build BlueTooth Low Energy Peripherals for fun.

The first part showed how to create a rudimentary Peripheral on a Mac. But really, it was to learn about how it’s done on a Mac, and I don’t see much interest in turning your Mac into a Peripheral.

The second part showed how to set up a cross-compilation development environment on a Mac with step-debugging code on the Pi.

This installment is, again, a prep phase, since the method in the second installment does not really work for building a Bluetooth stack on a Mac with cross-compile intentions. This is because the Linux dependencies needed to compile and link the app are not available for the Mac, and implementing them would basically mean implementing a Linux hci and dbus emulator. That would be fun, but my goal is to build a Peripheral…

Sorry, my #fail

So this installment is about setting up NetBeans to actually compile and step through code on the Pi. Yes, I said it was slow, but what choice does a BlueTooth n00b dev have?

The goal of this phase in our Sprint zero, is to have a way to hit “build” on the Mac, have the Pi do the actual build and then run the debugger to step through code that’s running on it.

Here goes:

The revised development workflow is:

  • Use the Mac to write code on the Pi. This post is about setting up NetBeans to do so.
  • Use the Mac to build (compile and link) the code on the Pi (using its native tool-chain, no more cross-compiling).
  • Use NetBeans to debug the code running on the Pi (remotely).

Setup

Right click on the project’s root node to get to its preferences and go from there:

Set up a new Build Host

Set up a new Build Host

Configure the remote build host

Configure the remote build host

Set up the local and remote directory paths

Configure the remote build host

Set up the source folder

Set up the source folder

Set up the build host

Set up the build host

Set up make working directory

Set up make working directory

Running & debugging remotely

Running the debugger on the Pi

gdbserver :1234 welcome_1

Here you’re telling gdbserer to run the welcome app on port 1234.

Attaching and stepping through the code from the Mac

From the menu, select “Debug”/”Attach debugger” and fill in the form:

  • For debugger, select “remote debugger”
  • For target, type “remote pi :1234” ‘pi’ is the pi’s host name (I put mine in /etc/hosts) ‘:1234’ is the port with which NetBeans will communicate on your Pi. This has to be the same port number that you selected in the gdbserver command above.

Attach remote session

Here’s bunget in action.

debugging

I hope you find the post useful!

Happy hacking!



Other Tags

API GW
AWS
ActiveRecord
Agile
Alexa
Analysis
Ansible
BDD
BLE
C
CAB
CloudFormation
CloudFront
CloudWatch
Cross-compile
Cucumber
DevOps
Devops
DotNet
Embedded
Fitbit
GNU
GitHub Actions
Governance
How-to
Inception
IoT
Javascript
Jest
Lambda
Mac OS X
MacRuby
Metrics
MySQL
NetBeans
Objective-C
PMO
Product Management
Programme management
Project Management
Quality Assurance
Rails
Raspberry Pi
Remote compilation
Remote debugging
Remote execution
Risk Assessment
Route 53
Ruby
S3
SPA
Self Organising Teams
SpecFlow
TDD
Unit testing
VSM
Value
arm
contract testing
inception
nrf51
pact
planning
rSpec
ruby
ssh