There are many opinions on the good and bad of debugging. I use it constantly. My development is a constant round-trip between editor and debugger. I like to step through code in a debugger to grasp what's happening in firmware.

 

This blog explains how I set up my tool chain to debug the SensorTag Out-of-box firmware while the device is in a Bluetooth conversation.

 

        

 

 

The SimpleLink SensorTag is a tiny evaluation kit with an ARM Cortex controller with embedded BLE, and a number of sensors.

Out of the box, it runs an application that collects environmental data and send the measurements over Bluetooth Low Energy.

In my exercise, the receiving part is an Android smartphone with an App that shows the data.

 

You need a hardware debugger to do this exercise. I use the SimpleLink Debug DevPack - made specific for the SensorTag.

 

image obviously adapted from TI product page I never succeed in making such flashy images myself

 

The Breakpoint

 

Both the Android App and the SensorTag firmware have many source files, in multiple folders, with loads of code.

Finding a good breakpoint isn't just a straightforward exercise (believe me, I've read umphteen source files and tried many breakpoints before I found a good one)

But once we have a good breakpoint, a world opens. We can trace back in the stack to see how we got at this point in code, and we can step through to learn what's next.

 

The breakpoint I've chosen is in the code of the IR Sensor - the part that glues the sensor driver to the BLE stack.

There are many other good candidates (each sensor has a similar setup).

But I settled for this one because

  • it's a good one for digging in the stack and
  • you can see that the app is halted while you are halting the firmware in the debugger - a good visual cue.

 

We'll see in the next section how to get at the project, but here's the give-away if you have that already working:

You'll find the breakpoint in the sensor_WriteAttrCB() function in source file PROFILES/irtempservice.c of the project SensorTag.

 

Where to Get the Firmware?

 

trick:

 

You can use the TI Cloud tools to do this exercise. You only need the SensorTag, the debugger and a computer with browser and one USB port. You don't need an IDE.

Navigate to the Resource Explorer, then import these two SensorTags in CCS cloud:

- SensorTag

- SensorTagStack

 

 

Build and Debug SensorTagStack project (this step is needed to get the stack uploaded to the Tag)

Change the properties of the SensorTag project to set the optimize level to 0,

 

To do that, follow the instructions of this help request I raised at e2e: asked the question on the TI E2E forum.

 

Build and Debug it and put the breakpoint as described above.

 

Kick off the debugger

Take your phone and connect to the tag.

Watch the debugger stop. Have Fun!

 

 

If you want to run this exercise from a CCS installation on your computer:

 

On the SensorTag's product page, there's a link to a software download that contains the BLE stack, Documentation and Sample applications.

Check under the Software section, and click on Bluetooth Low Energy Software Stack.

You will have to give your personal info and why you'll use this software - the same as for CCS.

I have kept all settings default when installing. Just take care that you know where you've installed it, because our firmware projects are in that folder.

 

I didn't do a full check on dependencies, because I've been working with this tag for a while.

Here is a relevant plug-in that I have installed in CCS (check via View -> CCS App Center).

I can't remember if I selected it via App Center or that it came via the Bluetooth Low Energy Software Stack.

 

 

 

Load and Fine-Tune the Projects

 

The projects can b found in the install folder of the SensorTag software pack.

On my PC, it's at C:\ti\simplelink\ble_cc26xx_2_00_00_42893\Projects\ble\SensorTag\CC26xx\CCS.

The simplest way to import both the SensorTag and SensorTag projects is via the Resource Explorer (Veiw -> Resource Explorer)

 

 

The wizard will help you trough all the steps.

  • Import both.
  • Check if the debugger is set to XDS110 for both projects,

 

 

 

  • For the SensorTag project, set optimize level to 0 after importing.

 

  • Build both
  • First debug SensorTagStack. This will get the stack loaded on your tag.
  • Stop the debugger.
  • Then debug SensorTag. Set the breakpoint as indicated in the beginning of the blog.
  • Kick off the debugger?
  • Start your SmartApp. Connect to the tag.
  • The app will detect the services on your tag. Then your program will halt.
  • The display of the app will not show data before you continue the program in the debugger.

 

Happy Debugging. The video at the beginning of the blog shows what to expect.